few chasnges
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user