Files
kupshop/admin/templates/export/orders_pohoda.tpl
2025-08-02 16:30:27 +02:00

133 lines
7.6 KiB
Smarty

<?xml version="1.0" encoding="utf-8"?>
<dat:dataPack id="fa001" ico="{$dbcfg->shop_ico}" application="StwTest" version = "2.0" note="Import FA z wpjshop"
xmlns:dat="http://www.stormware.cz/schema/version_2/data.xsd"
xmlns:inv="http://www.stormware.cz/schema/version_2/invoice.xsd"
xmlns:typ="http://www.stormware.cz/schema/version_2/type.xsd" >
{foreach $orders as $db_order}{$order = $this->getOrder($db_order.id)}{change_currency currency=$order->currency}
{block xmlVariables}
{$flags = $order->getFlags()}
{$oss = $flags.OSS}
{/block}
<dat:dataPackItem id="{$order->order_no}" version="2.0">
<inv:invoice version="2.0">
<inv:invoiceHeader>
<inv:invoiceType>{block invoiceType}issuedInvoice{/block}</inv:invoiceType>
<inv:symVar>{block symVar}{$order->order_no}{/block}</inv:symVar>
<inv:date>{$order->date_handle|date_format:'Y-m-d'}</inv:date>
<inv:partnerIdentity>
<typ:address>
<typ:email>{$order->invoice_email}</typ:email>
<typ:company>{$order->invoice_firm}</typ:company>
{$invoice_name = $order->invoice_name|cat:' '|cat:$order->invoice_surname}
<typ:name>{substr($invoice_name, 0, 32)}</typ:name>
<typ:city>{$order->invoice_city}</typ:city>
<typ:street>{substr($order->invoice_street, 0, 32)}</typ:street>
<typ:zip>{$order->invoice_zip}</typ:zip>
<typ:ico>{$order->invoice_ico}</typ:ico>
<typ:dic>{$order->invoice_dic}</typ:dic>
<typ:icDph>{$order->invoice_dic}</typ:icDph>
<typ:country><typ:ids>{$order->invoice_country}</typ:ids></typ:country>
</typ:address>
<typ:shipToAddress>
<typ:company>{$order->delivery_firm}</typ:company>
{$delivery_name = $order->delivery_name|cat:' '|cat:$order->delivery_surname}
<typ:name>{substr($delivery_name, 0, 32)}</typ:name>
<typ:city>{$order->delivery_city}</typ:city>
<typ:street>{substr($order->delivery_street, 0, 32)}</typ:street>
<typ:zip>{$order->delivery_zip}</typ:zip>
<typ:country><typ:ids>{$order->delivery_country}</typ:ids></typ:country>
</typ:shipToAddress>
</inv:partnerIdentity>
<inv:numberOrder>{if $order->getInvoiceNo()}{$order->getInvoiceNo()}{else}{$order->order_no}{/if}</inv:numberOrder>
{block invoice_number}<inv:number><typ:numberRequested>{if $order->getInvoiceNo()}{$order->getInvoiceNo()}{else}{$order->order_no}{/if}</typ:numberRequested></inv:number>{/block}
<inv:dateOrder>{$order->date_created|date_format:'Y-m-d'}</inv:dateOrder>
<inv:paymentType>
{strip}
{if $order->getDeliveryType()->getPayment()}
{if $order->getDeliveryType()->getPayment()->getPayMethod() == 8}
<typ:ids>{substr($order->getDeliveryType()->getPayment()->getName(), 0, 24)}</typ:ids>
{else}
<typ:ids>{substr($order->getDeliveryType()->getPayment()->getName(), 0, 32)}</typ:ids>
{/if}
{else}
<typ:ids>Nevybráno</typ:ids>
{/if}
{/strip}
</inv:paymentType>
<inv:carrier>
{strip}
{if $order->getDeliveryType()->getDelivery()}
<typ:ids>{substr($order->getDeliveryType()->getDelivery()->name, 0, 20)}</typ:ids>
{else}
<typ:ids>Nevybráno</typ:ids>
{/if}
{/strip}
</inv:carrier>
<inv:note>{$order->note_user}</inv:note>
{if $oss}
<inv:MOSS>
<typ:ids>{$order->delivery_country}</typ:ids>
</inv:MOSS>
<inv:evidentiaryResourcesMOSS>
<typ:ids>A</typ:ids>
</inv:evidentiaryResourcesMOSS>
<inv:classificationVAT>
<typ:ids>UN</typ:ids>
<typ:classificationVATType>nonSubsume</typ:classificationVATType>
</inv:classificationVAT>
{/if}
</inv:invoiceHeader>
{block customParts}{/block}
{block invoiceSummary}
<inv:invoiceSummary>
{*
zatím nebylo potřeba řešit, že by vznikaly halířové rozdíly v celkové ceně v případě, kdy
se exportuje do Pohody bez položek. Pokud by bylo potřeba lze dodělat: připad rozdílovou položku - viz xml
*}
{if !isset($order->currency) or $order->currency == 'CZK'}
<inv:homeCurrency>
{if $order.status_storno == 0}
<typ:priceNone>{if $order->vats[0]}{$order->vats[0].total_price_with_vat->printFloatValue(2)}{else}0{/if}</typ:priceNone>
<typ:price3>{if $order->vats[10]}{$order->vats[10].total_price_without_vat_no_rounding->printFloatValue(4)}{else}0{/if}</typ:price3>
<typ:price3Sum>{if $order->vats[10]}{$order->vats[10].total_price_with_vat->printFloatValue(2)}{else}0{/if}</typ:price3Sum>
<typ:priceLow>{if $order->vats[15]}{$order->vats[15].total_price_without_vat_no_rounding->printFloatValue(4)}{else}0{/if}</typ:priceLow>
<typ:priceLowSum>{if $order->vats[15]}{$order->vats[15].total_price_with_vat->printFloatValue(2)}{else}0{/if}</typ:priceLowSum>
<typ:priceHigh>{if $order->vats[21]}{$order->vats[21].total_price_without_vat_no_rounding->printFloatValue(4)}{else}0{/if}</typ:priceHigh>
<typ:priceHighSum>{if $order->vats[21]}{$order->vats[21].total_price_with_vat->printFloatValue(2)}{else}0{/if}</typ:priceHighSum>
{else}
<typ:priceNone>0</typ:priceNone>
<typ:priceLowSum>0</typ:priceLowSum>
<typ:price3>0</typ:price3>
<typ:priceHighSum>0</typ:priceHighSum>
{/if}
</inv:homeCurrency>
{else}
{get_contexts currency=true assign='contexts'}
{if $contexts.currency->getDefaultId() == 'EUR'}
{$currencyRate = toDecimal(1/$order->currency_rate)}
{else}
{$currencyRate = toDecimal($order->currency_rate)}
{/if}
<inv:foreignCurrency>
<typ:currency>
<typ:ids>{$order->currency}</typ:ids>
</typ:currency>
<typ:rate>{$currencyRate->printFloatValue(3)}</typ:rate>
<typ:amount>1</typ:amount>
<typ:priceSum>{$order->total_price_array|format_price:"printcurrency=false"|replace:',':'.'|replace:' ':''}</typ:priceSum>
</inv:foreignCurrency>
{/if}
</inv:invoiceSummary>
{/block}
</inv:invoice>
</dat:dataPackItem>
{/change_currency}
{/foreach}
</dat:dataPack>