some fixes

This commit is contained in:
2025-07-10 08:04:15 +00:00
parent 34fe281e2c
commit e37b4dd963
14 changed files with 121 additions and 93 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -202,7 +202,7 @@ function createCostDocumentFromInvoice($record)
$doc->doc_symbol = $inv->document_no;
$doc->revision = 1;
$doc->category_id = 'revision_note';
$doc->category_id = 'invoice';
$doc->status = '2';
$doc->transaction_type = '1';
$doc->document_type = 'k';

View File

@@ -1,4 +1,5 @@
<?php
// created: 2025-07-10 06:50:17
$sugar_config = array (
'admin_access_control' => false,
'admin_export_only' => false,
@@ -28,7 +29,8 @@ $sugar_config = array(
'm.d.Y' => '12.23.2010',
),
'datef' => 'm/d/Y',
'dbconfig' => array(
'dbconfig' =>
array (
'db_host_name' => 'localhost',
'db_user_name' => 'root',
'db_password' => '5z#JaL',
@@ -206,8 +208,8 @@ $sugar_config = array(
'weak' => true,
'list' =>
array (
0 => 'saas-systems.pl',
1 => 'b2b-meritum.ddns.net',
0 => 'crm.twinpol.com',
1 => 'accounts.google.com',
2 => 'crm-meritum.ddns.net',
3 => '83.3.222.246',
),
@@ -335,11 +337,4 @@ $sugar_config = array(
'vcal_time' => '2',
'verify_client_ip' => false,
);
if ($_SERVER['HTTP_HOST'] == 'localhost:8080') {
$sugar_config['dbconfig']['db_host_name'] = 'twinpol-mysql56';
$sugar_config['dbconfig']['db_user_name'] = 'root';
$sugar_config['dbconfig']['db_password'] = 'rootpassword';
}
?>

View File

@@ -8,7 +8,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/04-2025.csv';
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/05-2025.csv';
$handle = fopen($filename, 'r');
if ($handle === false) {
die('Cannot open file: ' . $filename);

View File

@@ -1,6 +1,6 @@
<?php
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/amazon-wz-04-2025.csv';
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/amazon-wz-05-2025.csv';
$handle = fopen($filename, 'r');
if ($handle === false) {
die('Cannot open file: ' . $filename);

View File

@@ -8,7 +8,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/04-2025.csv';
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/05-2025.csv';
$handle = fopen($filename, 'r');
if ($handle === false) {
die('Cannot open file: ' . $filename);

View File

@@ -4,7 +4,7 @@ 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/04-2025.csv';
$filename = getcwd() . '/modules/EcmInvoiceOuts/BimIT-eCommerceInvoices/amazonWDT/files/05-2025.csv';
$handle = fopen($filename, 'r');
if ($handle === false) {
die('Cannot open file: ' . $filename);
@@ -57,7 +57,7 @@ function createInvoice($type, $products, $DO_REAL_SAVE = false)
$invoice->parent_address_city = 'Obrowo';
$invoice->type = 'normal';
$date = '30.04.2025';
$date = '31.05.2025';
$invoice->register_date = $date;
$invoice->sell_date = $date;
$invoice->validtill_date = $date;

View File

@@ -69,6 +69,7 @@ function getInvoices($source, $date, $type)
$query .= " AND i.type='$type'";
}
$query .= " ORDER BY i.register_date";
$result = $db->query($query);
$invoices = array();
while ($row = $db->fetchByAssoc($result)) {
@@ -129,6 +130,20 @@ 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']))));
}
$i['vats'] = array();
foreach ($i['products'] as $p) {
if (!isset($i['vats'][$p['vat_value']])) {
$i['vats'][$p['vat_value']] = array(
'netto' => 0,
'brutto' => 0,
'vat' => 0,
);
}
$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'];
}
}
$smarty->assign("data", $invoices);

View File

@@ -6,7 +6,6 @@
// FVKOR Polska - 17314
// FVKOR domyślna - 7689
/*
DELETE p
FROM ecommerce_invoices_products p
@@ -21,7 +20,7 @@ function importFV($seriesId)
$IMPORT_START_ID = 1531694;
$dbRes = $db->query("SELECT id FROM ecommerce_invoices WHERE origin = 'allegro' AND type = 'normal' AND series_id = '$seriesId' ORDER BY id DESC LIMIT 1");
$dbRes = $db->query("SELECT id FROM ecommerce_invoices WHERE origin = 'allegro' AND type = 'normal' AND series_id = '$seriesId' ORDER BY CAST(id AS UNSIGNED) DESC LIMIT 1");
$lastImportId = $db->fetchByAssoc($dbRes)['id'];
if ($lastImportId == null) {
$lastImportId = $IMPORT_START_ID;
@@ -30,6 +29,7 @@ function importFV($seriesId)
}
$invoicesRes = loadInvoices($baselinker_config['token'], $lastImportId, $seriesId);
$invoices = $invoicesRes->invoices;
usort($invoices, function ($a, $b) {
@@ -205,7 +205,11 @@ function getInvoiceSource($token, $orderId)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiParams));
$res = json_decode(curl_exec($curl));
if ($res->orders[0]->order_source != '') {
return $res->orders[0]->order_source;
} else {
return 'allegro'; //default
}
}
function getCorrectTotals($invoice)
{

View File

@@ -1,4 +1,4 @@
[INFO]
[INFO]
"1.05.4",0,1250,"Subiekt GT","GT","SubTest","Firma przykładowa systemu InsERT GT","Wrocław","54-445","Bławatkowa 25/3","111-111-11-11","MAG","Główny","Magazyn główny",,1,20170101000000,20170331000000,"Kowalski Jan",20170804155934,"Polska","PL",,0
{foreach from=$data item=i name=loop}
@@ -6,7 +6,10 @@
"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,,,,,"",,
[ZAWARTOSC]
"23",23,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,0,0,0,0,0,0,0,0,0,0,0,0
{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
{/foreach}
{/foreach}

View File

@@ -1,4 +1,3 @@
[INFO]
"1.05.4",0,1250,"Subiekt GT","GT","SubTest","Firma przykładowa systemu InsERT GT","Wrocław","54-445","Bławatkowa 25/3","111-111-11-11","MAG","Główny","Magazyn główny",,1,20170101000000,20170331000000,"Kowalski Jan",20170804155934,"Polska","PL",,0
@@ -7,7 +6,10 @@
"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,,,,,"",,
[ZAWARTOSC]
"23",23,{$i.total_netto},{$i.total_vat},{$i.total_brutto},0,0,0,0,0,0,0,0,0,0,0,0,0
{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
{/foreach}
{/foreach}

View File

@@ -50,7 +50,7 @@ $i=0;
$total_quantity=0;
$total_value=0;
while ($tmp2 = $db->fetchByAssoc($r1)) {
$r = $db->query("select * from ecmstockoperations where product_id='" . $tmp2['id'] . "' ".$add_where." and in_id is null and used=0 and type=0 order by counter asc");
$r = $db->query("select * from ecmstockoperations where product_id='" . $tmp2['id'] . "' ".$add_where." and in_id is null and used=0 and type=0 and deleted=0 order by counter asc");
$l = 0;
if ($r->num_rows > 0) {
$docs[$i]['unit_id'] = $app_list_strings['ecmproducts_unit_dom'][$tmp2['unit_id']];
@@ -63,8 +63,9 @@ 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'];

View File

@@ -14,8 +14,7 @@ class PurchaseCreator{
}
public function getPurchases($type){
//$query = "SELECT * FROM documents WHERE id='790f2a4d-28d7-e135-9be2-68408ca7279a'";
//$query="select * from documents where document_date>='" . $this->date_from . "' and document_date<='" . $this->date_to . "' and category_id in ('invoice','compain_note','return_note') and deleted=0";
$query="select * from documents where document_date>='" . $this->date_from . "' and document_date<='" . $this->date_to . "' and category_id in ('invoice','compain_note','return_note') and deleted=0";
if ($type == "new") {
$query .= " and exported = 0";
}

View File

@@ -136,6 +136,7 @@ $return_id = $focus->id;
$focus->ecommerce_invoices = $json->decode(htmlspecialchars_decode($_POST['ecommerce_invoices']));
if (isset($focus->ecommerce_invoices) && count($focus->ecommerce_invoices) > 0) {
$db = $GLOBALS['db'];
$q = "UPDATE ecommerce_invoices SET ecmstockdoccorrect_id = '$return_id' WHERE id IN ('" . implode("','", $focus->ecommerce_invoices) . "')";
$db->query("UPDATE ecommerce_invoices SET ecmstockdoccorrect_id = '$return_id' WHERE id IN ('" . implode("','", $focus->ecommerce_invoices) . "')");
}