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

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);