From 6c4eed7fc73b53cd35770b4b541cf8f757e5eafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Tue, 5 Aug 2025 13:52:35 +0000 Subject: [PATCH] few chasnges --- .../amazonWDT/B2BReader.php | 3 +- .../amazonWDT/amazonWZ.php | 3 +- .../amazonWDT/localVatReader.php | 3 +- .../amazonWDT/vatLocalWZ.php | 2 + .../amazonWDT/wdtReader.php | 14 +++---- .../ecommerceInvoicesListView.php | 37 ++++++++++++++++++- .../BimIT-eCommerceInvoices/rewizor.tpl | 8 ++-- .../BimIT-eCommerceInvoices/rewizor_fvkor.tpl | 8 ++-- modules/EcmReports/ReportStocksDoc.php | 2 - 9 files changed, 58 insertions(+), 22 deletions(-) diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/B2BReader.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/B2BReader.php index 14b579a5..bcc41e42 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/B2BReader.php +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/B2BReader.php @@ -1,4 +1,5 @@ parent_address_city = 'Obrowo'; $invoice->type = 'normal'; - $date = '31.05.2025'; + $date = '30.06.2025'; $invoice->register_date = $date; $invoice->sell_date = $date; $invoice->validtill_date = $date; diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php index 28cc8051..38d1e133 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/ecommerceInvoicesListView.php @@ -118,6 +118,7 @@ function exportToRewizor($source, $date, $type) { $smarty = new Sugar_Smarty(); $invoices = getInvoices($source, $date, $type); + $accounts = array(); foreach ($invoices as &$i) { $i['register_date'] = date("Ymd000000",strtotime($i['register_date'])); $i['sell_date'] = date("Ymd000000",strtotime($i['sell_date'])); @@ -130,6 +131,22 @@ function exportToRewizor($source, $date, $type) $i['corrected_document_no'] = $fv['document_no']; $i['corrected_register_date'] = date("Ymd000000",strtotime(date('d.m.Y', strtotime($fv['register_date'])))); } + if ($source == 'amazon b2b') { + $i['category'] = 'Dostawa Wewnątrzwspólnotowa'; + $i['parent_country_code'] = substr($i['parent_nip'], 0, 2); + $i['parent_name'] = $i['parent_name'] . ' ' . $i['parent_nip']; + $i['parent_hash'] = $i['parent_nip']; //substr(md5($i['parent_name']), 0, 20); + $i['parent_short_name'] = $i['parent_name']; //substr($i['parent_name'], 0, 40); + } else { + $i['parent_country_code'] = 'PL'; + $i['parent_short_name'] = $i['parent_name']; + if (isset($i['parent_nip']) && !empty($r['parent_nip'])) { + $i['parent_name'] = $i['parent_name'] . ' ' . $i['parent_nip']; + $i['parent_hash'] = $i['parent_nip']; + } + $i['category'] = "Sprzedaż"; + } + $i['products'] = getInvoicProducts($i['id']); $i['vats'] = array(); foreach ($i['products'] as $p) { if (!isset($i['vats'][$p['vat_value']])) { @@ -138,21 +155,37 @@ function exportToRewizor($source, $date, $type) 'brutto' => 0, 'vat' => 0, ); + $i['vats'][$p['vat_value']]['vat_value'] = $p['vat_value']; + if ($source == 'amazon b2b') { + $i['vats'][$p['vat_value']]['vat_name'] = 'ue'; + } else { + $i['vats'][$p['vat_value']]['vat_name'] = $p['vat_value']; + } } $i['vats'][$p['vat_value']]['netto'] += $p['price_netto'] * $p['quantity']; $i['vats'][$p['vat_value']]['brutto'] += $p['price_brutto'] * $p['quantity']; $i['vats'][$p['vat_value']]['vat'] += ($p['price_brutto'] - $p['price_netto']) * $p['quantity']; - $i['vats'][$p['vat_value']]['vat_value'] = $p['vat_value']; + } + if (!isset($accounts['parent_hash'])) { + $accounts[$i['parent_hash']] = array ( + 'parent_hash' => $i['parent_hash'], + 'parent_name' => $i['parent_name'], + 'parent_address_city' => $i['parent_address_city'], + 'parent_address_postalcode' => $i['parent_address_postalcode'], + 'parent_address_street' => $i['parent_address_street'], + 'parent_country_code' => $i['parent_country_code'], + ); } } $smarty->assign("data", $invoices); - $result = ''; + $smarty->assign("accounts", $accounts); if ($type == 'normal') { $result = $smarty->fetch(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl'); } else { $result = $smarty->fetch(getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl'); } + //echo $result; echo mb_convert_encoding($result, 'ISO-8859-2', 'UTF-8'); } diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl index b7e457e0..6197d59a 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor.tpl @@ -3,11 +3,11 @@ {foreach from=$data item=i name=loop} [NAGLOWEK] - "FS",1,0,0,"{$i.document_no}","FS","{$i.document_no}",,,"{$i.order_no}",,"{$i.parent_hash}","{$i.parent_short_name}","{$i.parent_name}","{$i.parent_address_city}","{$i.parent_address_postalcode}","{$i.parent_address_street}","{$i.parent_nip}","Sprzedaż",,"Obrowo","{$i.register_date}","{$i.sell_date}","{$i.register_date}",1,0,,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,,,,"{$i.sell_date}",{$i.total_brutto},{$i.total_brutto},0,0,0,0,"",,,,,"PLN",,"",,,,0,,0,,,,,"",, + "FS",1,0,0,"{$i.document_no}","FS","{$i.document_no}",,,"{$i.order_no}",,"{$i.parent_hash}","{$i.parent_short_name}","{$i.parent_name}","{$i.parent_address_city}","{$i.parent_address_postalcode}","{$i.parent_address_street}","{$i.parent_nip}","{$i.category}",,"Obrowo","{$i.register_date}","{$i.sell_date}","{$i.register_date}",1,0,,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,,,,"{$i.sell_date}",{$i.total_brutto},{$i.total_brutto},0,0,0,0,"",,,,,"PLN",,"",,,,0,,0,,,,,"",, [ZAWARTOSC] {foreach from=$i.vats item=vat name=vatloop} - "{$vat.vat_value}",{$vat.vat_value},{$vat.netto},{$vat.vat},{$vat.brutto},0,0,0,0,0,0,0,0,0,0,0,0,0 + "{$vat.vat_name}",{$vat.vat_value},{$vat.netto},{$vat.vat},{$vat.brutto},0,0,0,0,0,0,0,0,0,0,0,0,0 {/foreach} @@ -17,6 +17,6 @@ "KONTRAHENCI" [ZAWARTOSC] -{foreach from=$data item=i name=loop} - 0,"{$i.parent_hash}","{$i.parent_name}","{$i.parent_name}","{$i.parent_address_city}","{$i.parent_address_postalcode}","{$i.parent_address_street}","{$parent_nip}",,,,,,,,,,,,,,,,,,,,,0 +{foreach from=$accounts item=a name=accountsLoop} + 0,"{$a.parent_hash}","{$a.parent_name}","{$a.parent_name}","{$a.parent_address_city}","{$a.parent_address_postalcode}","{$a.parent_address_street}","{$a.parent_country_code}",,,,,,,,,,,,,,,,,,,,,0 {/foreach} \ No newline at end of file diff --git a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl index b80ff8ff..34c1bdce 100644 --- a/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl +++ b/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/rewizor_fvkor.tpl @@ -3,11 +3,11 @@ {foreach from=$data item=i name=loop} [NAGLOWEK] - "KFS",1,0,0,"{$i.document_no}","FS","{$i.document_no}","{$i.corrected_document_no}","{$i.corrected_register_date}","{$i.order_no}",,"{$i.parent_hash}","{$i.parent_short_name}","{$i.parent_name}","{$i.parent_address_city}","{$i.parent_address_postalcode}","{$i.parent_address_street}","{$i.parent_nip}","Sprzedaż",,"Obrowo","{$i.register_date}","{$i.sell_date}","{$i.register_date}",1,0,,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,,,,"{$i.sell_date}",{$i.total_brutto},{$i.total_brutto},0,0,0,0,"",,,,,"PLN",,"",,,,0,,0,,,,,"",, + "KFS",1,0,0,"{$i.document_no}","FS","{$i.document_no}","{$i.corrected_document_no}","{$i.corrected_register_date}","{$i.order_no}",,"{$i.parent_hash}","{$i.parent_short_name}","{$i.parent_name}","{$i.parent_address_city}","{$i.parent_address_postalcode}","{$i.parent_address_street}","{$i.parent_nip}","{$i.category}",,"Obrowo","{$i.register_date}","{$i.sell_date}","{$i.register_date}",1,0,,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,,,,"{$i.sell_date}",{$i.total_brutto},{$i.total_brutto},0,0,0,0,"",,,,,"PLN",,"",,,,0,,0,,,,,"",, [ZAWARTOSC] {foreach from=$i.vats item=vat name=vatloop} - "{$vat.vat_value}",{$vat.vat_value},{$vat.netto},{$vat.vat},{$vat.brutto},0,0,0,0,0,0,0,0,0,0,0,0,0 + "{$vat.vat_name}",{$vat.vat_value},{$vat.netto},{$vat.vat},{$vat.brutto},0,0,0,0,0,0,0,0,0,0,0,0,0 {/foreach} @@ -17,6 +17,6 @@ "KONTRAHENCI" [ZAWARTOSC] -{foreach from=$data item=i name=loop} - 0,"{$i.parent_hash}","{$i.parent_name}","{$i.parent_name}","{$i.parent_address_city}","{$i.parent_address_postalcode}","{$i.parent_address_street}","{$parent_nip}",,,,,,,,,,,,,,,,,,,,,0 +{foreach from=$accounts item=a name=accountsLoop} + 0,"{$a.parent_hash}","{$a.parent_name}","{$a.parent_name}","{$a.parent_address_city}","{$a.parent_address_postalcode}","{$a.parent_address_street}","{$a.parent_country_code}",,,,,,,,,,,,,,,,,,,,,0 {/foreach} \ No newline at end of file diff --git a/modules/EcmReports/ReportStocksDoc.php b/modules/EcmReports/ReportStocksDoc.php index 01b8a753..66b3de0c 100644 --- a/modules/EcmReports/ReportStocksDoc.php +++ b/modules/EcmReports/ReportStocksDoc.php @@ -63,9 +63,7 @@ while ($tmp2 = $db->fetchByAssoc($r1)) { $i++; } while ($tmp = $db->fetchByAssoc($r)) { - var_dump($tmp); $ii = $db->query( "select * from ecmstockoperations where in_id='" . $tmp['id'] ."' and type=1"); - echo "select * from ecmstockoperations where in_id='" . $tmp['id'] ."' and type=1"; if ($ii->num_rows > 0) { // licz ilość dla użytych $quantity_tmp = $tmp['quantity'];