few chasnges

This commit is contained in:
2025-08-05 13:52:35 +00:00
parent e37b4dd963
commit 6c4eed7fc7
9 changed files with 58 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
<?php
// https://crm.twinpol.com/?module=EcmInvoiceOuts&action=ecommerce&b2b=true
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
ini_set('display_errors', 1);
@@ -8,7 +9,7 @@ DELETE FROM ecommerce_invoices_products WHERE invoice_id IN (
DELETE FROM ecommerce_invoices WHERE origin='amazon b2b' AND register_date LIKE '2025-04-%';
*/
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/05-2025.csv';
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/06-2025.csv';
$handle = fopen($filename, 'r');
if ($handle === false) {
die('Cannot open file: ' . $filename);

View File

@@ -1,6 +1,7 @@
<?php
// https://crm.twinpol.com/?module=EcmInvoiceOuts&action=ecommerce&amazon-wz=true
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/amazon-wz-05-2025.csv';
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/amazon-wz-06-2025.csv';
$handle = fopen($filename, 'r');
if ($handle === false) {
die('Cannot open file: ' . $filename);

View File

@@ -1,4 +1,5 @@
<?php
// https://crm.twinpol.com/?module=EcmInvoiceOuts&action=ecommerce&local-vat=true
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
ini_set('display_errors', 1);
@@ -8,7 +9,7 @@ DELETE FROM ecommerce_invoices_products WHERE invoice_id IN (
DELETE FROM ecommerce_invoices WHERE origin='amazon vat local' AND register_date LIKE '2025-02-%';
*/
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/05-2025.csv';
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/06-2025.csv';
$handle = fopen($filename, 'r');
if ($handle === false) {
die('Cannot open file: ' . $filename);

View File

@@ -1,4 +1,6 @@
<?php
// https://crm.twinpol.com/?module=EcmInvoiceOuts&action=ecommerce&wdt=true
$invoices = getInvoices('2024');
$products = array();

View File

@@ -1,10 +1,10 @@
<?php
// show all php errors
// https://crm.twinpol.com/?module=EcmInvoiceOuts&action=ecommerce&wdt=true
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
ini_set('display_errors', 1);
// read csv file tab separated
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/05-2025.csv';
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/06-2025.csv';
$handle = fopen($filename, 'r');
if ($handle === false) {
die('Cannot open file: ' . $filename);
@@ -33,10 +33,10 @@ fclose($handle);
//}
//createInvoice('DE', $de);
if (count($cz) == 0) {
die('No data for CZ');
}
createInvoice('CZ', $cz, true);
//if (count($cz) == 0) {
// die('No data for CZ');
//}
//createInvoice('CZ', $cz);
function createInvoice($type, $products, $DO_REAL_SAVE = false)
{
@@ -57,7 +57,7 @@ function createInvoice($type, $products, $DO_REAL_SAVE = false)
$invoice->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;

View File

@@ -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');
}

View File

@@ -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}

View File

@@ -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}

View File

@@ -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'];