<vn-crud-model
vn-id="buysModel"
url="Entries/{{$ctrl.entry.id}}/getBuys"
limit="5"
data="buys"
auto-load="true">
</vn-crud-model>
<vn-card class="summary">
<h5>
    <a ng-if="::$ctrl.entryData.id"
        vn-tooltip="Go to the entry"
        ui-sref="entry.card.summary({id: {{::$ctrl.entryData.id}}})"
        name="goToSummary">
        <vn-icon-button icon="launch"></vn-icon-button>
    </a>
    <span> #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}}</span>
</h5>
<vn-horizontal>
    <vn-one>
        <vn-label-value label="Commission"
            value="{{$ctrl.entryData.commission}}">
        </vn-label-value>
        <vn-label-value label="Currency"
            value="{{$ctrl.entryData.currency.name}}">
        </vn-label-value>
        <vn-label-value label="Company"
            value="{{$ctrl.entryData.company.code}}">
        </vn-label-value>
        <vn-label-value label="Reference"
            value="{{$ctrl.entryData.reference}}">
        </vn-label-value>
        <vn-label-value label="Invoice number"
            value="{{$ctrl.entryData.invoiceNumber}}">
        </vn-label-value>
    </vn-one>
    <vn-one>
        <vn-label-value label="Reference">
            <span
                ng-click="travelDescriptor.show($event, $ctrl.entryData.travel.id)"
                class="link">
                {{$ctrl.entryData.travel.ref}}
            </span>
        </vn-label-value>
        <vn-label-value label="Agency"
            value="{{$ctrl.entryData.travel.agency.name}}">
        </vn-label-value>
        <vn-label-value label="Shipped"
            value="{{$ctrl.entryData.travel.shipped | date: 'dd/MM/yyyy'}}">
        </vn-label-value>
        <vn-label-value label="Warehouse Out"
            value="{{$ctrl.entryData.travel.warehouseOut.name}}">
        </vn-label-value>
        <vn-check
            label="Delivered"
            ng-model="$ctrl.entryData.travel.isDelivered"
            disabled="true">
        </vn-check>
        <vn-label-value label="Landed"
            value="{{$ctrl.entryData.travel.landed | date: 'dd/MM/yyyy'}}">
        </vn-label-value>
        <vn-label-value label="Warehouse In"
            value="{{$ctrl.entryData.travel.warehouseIn.name}}">
        </vn-label-value>
        <vn-check
            label="Received"
            ng-model="$ctrl.entryData.travel.isReceived"
            disabled="true">
        </vn-check>
    </vn-one>
    <vn-one>
        <vn-vertical>
            <vn-check
                label="Ordered"
                ng-model="$ctrl.entryData.isOrdered"
                disabled="true">
            </vn-check>
            <vn-check
                label="Confirmed"
                ng-model="$ctrl.entryData.isConfirmed"
                disabled="true">
            </vn-check>
            <vn-check
                label="Booked"
                ng-model="$ctrl.entryData.isBooked"
                disabled="true">
            </vn-check>
            <vn-check
                label="Raid"
                ng-model="$ctrl.entryData.travel.daysInForward"
                disabled="true">
            </vn-check>
            <vn-check
                label="Inventory"
                ng-model="$ctrl.entryData.isExcludedFromAvailable"
                disabled="true">
            </vn-check>
        </vn-vertical>
    </vn-one>
</vn-horizontal>
<vn-horizontal>
    <vn-auto name="buys">
        <h4 translate>Buys</h4>
        <table class="vn-table">
            <thead>
                <tr>
                    <th translate center field="quantity">Quantity</th>
                    <th translate center field="sticker">Stickers</th>
                    <th translate center field="packagingFk">Package</th>
                    <th translate center field="weight">Weight</th>
                    <th translate center field="packing">Packing</th>
                    <th translate center field="grouping">Grouping</th>
                    <th translate center field="buyingValue">Buying value</th>
                    <th translate center field="price3">Import</th>
                    <th translate center expand field="price">PVP</th>
                </tr>
            </thead>
            <tbody ng-repeat="line in buys">
                <tr>
                    <td center title="{{::line.quantity}}">{{::line.quantity}}</td>
                    <td center title="{{::line.stickers | dashIfEmpty}}">{{::line.stickers | dashIfEmpty}}</td>
                    <td center title="{{::line.packagingFk | dashIfEmpty}}">{{::line.packagingFk | dashIfEmpty}}</td>
                    <td center title="{{::line.weight}}">{{::line.weight}}</td>
                    <td center>
                        <vn-chip class="transparent" translate-attr="line.groupingMode == 'packing' ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 'packing'}">
                            <span>{{::line.packing | dashIfEmpty}}</span>
                        </vn-chip>
                    </td>
                    <td center>
                        <vn-chip class="transparent" translate-attr="line.groupingMode == 'grouping' ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 'grouping'}">
                            <span>{{::line.grouping | dashIfEmpty}}</span>
                        </vn-chip>
                    </vn-td>
                    <td center title="{{::line.buyingValue | currency: 'EUR':2}}">{{::line.buyingValue | currency: 'EUR':2}}</td>
                    <td center title="{{::line.quantity * line.buyingValue | currency: 'EUR':2}}">{{::line.quantity * line.buyingValue | currency: 'EUR':2}}</td>
                    <td center title="Grouping / Packing">{{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}}</td>
                </tr>
                <tr class="dark-row">
                    <td shrink>
                        <span
                            translate-attr="{title: 'Item type'}">
                            {{::line.item.itemType.code}}
                        </span>
                    </td>
                    <td shrink>
                        <span
                            ng-click="itemDescriptor.show($event, line.item.id)"
                            class="link">
                            {{::line.item.id}}
                        </span>
                    </td>
                    <td number shrink>
                        <span
                            translate-attr="{title: 'Item size'}">
                            {{::line.item.size}}
                        </span>
                    </td>
                    <td center>
                        <span
                            translate-attr="{title: 'Minimum price'}">
                            {{::line.item.minPrice | currency: 'EUR':2}}
                        </span>
                    </td>
                    <td vn-fetched-tags colspan="6">
                        <div>
                            <vn-one title="{{::line.item.concept}}">{{::line.item.name}}</vn-one>
                            <vn-one ng-if="::line.item.subName">
                                <h3 title="{{::line.item.subName}}">{{::line.item.subName}}</h3>
                            </vn-one>
                        </div>
                        <vn-fetched-tags
                            max-length="6"
                            item="::line.item"
                            tabindex="-1">
                        </vn-fetched-tags>
                    </td>
                </tr>
                <tr class="empty-row">
                    <td colspan="10"></td>
                </tr>
            </tbody>
        </table>
        <vn-pagination
            model="buysModel"
            class="vn-pt-xs">
        </vn-pagination>
    </vn-auto>
</vn-horizontal>
</vn-card>
<vn-item-descriptor-popover
vn-id="item-descriptor"
warehouse-fk="$ctrl.vnConfig.warehouseFk">
</vn-item-descriptor-popover>
<vn-travel-descriptor-popover
vn-id="travelDescriptor">
</vn-travel-descriptor-popover>