<?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"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                                      http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
                  xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">

    <mapped-superclass name="Sylius\Component\Order\Model\OrderItem" class="sylius_order_item">
        <id name="id" column="id" type="integer">
            <generator strategy="AUTO" />
        </id>

        <field name="quantity" column="quantity" type="integer">
            <gedmo:versioned />
        </field>
        <field name="unitPrice" column="unit_price" type="integer">
            <gedmo:versioned />
        </field>
        <field name="adjustmentsTotal" column="adjustments_total" type="integer" />
        <field name="total" column="total" type="integer" />
        <field name="immutable" column="is_immutable" type="boolean" />

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

        <one-to-many field="adjustments" target-entity="Sylius\Component\Order\Model\AdjustmentInterface" mapped-by="orderItem" orphan-removal="true">
            <cascade>
                <cascade-all/>
            </cascade>
        </one-to-many>

        <gedmo:loggable />
    </mapped-superclass>

</doctrine-mapping>
