<?xml version="1.0" encoding="UTF-8"?>

<!--

 This file is part of the Sylius package.

 (c) Paweł Jędrzejewski

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                                      http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <mapped-superclass name="Sylius\Component\Order\Model\Adjustment" table="sylius_adjustment">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <field name="label" column="label" type="string" />
        <field name="description" column="description" type="string" nullable="true" />
        <field name="amount" column="amount" type="integer" />
        <field name="neutral" column="is_neutral" type="boolean" />
        <field name="locked" column="is_locked" type="boolean" />

        <field name="originId" column="origin_id" type="integer" nullable="true" />
        <field name="originType" column="origin_type" type="string" nullable="true" />

        <field name="createdAt" column="created_at" type="datetime">
            <gedmo:timestampable on="create"/>
        </field>
        <field name="updatedAt" column="updated_at" type="datetime" nullable="true">
            <gedmo:timestampable on="update"/>
        </field>

        <many-to-one field="order" target-entity="Sylius\Component\Order\Model\OrderInterface" inversed-by="adjustments">
            <join-column name="order_id" referenced-column-name="id" nullable="true" />
        </many-to-one>

        <many-to-one field="orderItem" target-entity="Sylius\Component\Order\Model\OrderItemInterface" inversed-by="adjustments">
            <join-column name="order_item_id" referenced-column-name="id" nullable="true" />
        </many-to-one>
    </mapped-superclass>

</doctrine-mapping>
