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

<!--

 This file is part of the Sylius package.

 (c) Sylius Sp. z o.o.

 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">

    <mapped-superclass name="Sylius\Component\Core\Model\Shipment" table="sylius_shipment">
        <field name="adjustmentsTotal" column="adjustments_total" type="integer" />

        <one-to-many field="adjustments" target-entity="Sylius\Component\Core\Model\AdjustmentInterface" mapped-by="shipment" orphan-removal="true">
            <order-by>
                <order-by-field name="id" />
            </order-by>

            <cascade>
                <cascade-all/>
            </cascade>
        </one-to-many>

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

</doctrine-mapping>
