|
|
|
|
@ -7,7 +7,7 @@
|
|
|
|
|
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
|
|
|
|
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
|
|
|
|
* Copyright (C) 2021-2022 Open-Dsi <support@open-dsi.fr>
|
|
|
|
|
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
|
|
|
|
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
|
|
|
|
|
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
@ -275,87 +275,79 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
|
|
|
|
$sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$sql) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if ($sql == 'TODO') {
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
if ($sql != 'TODO') {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG);
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG);
|
|
|
|
|
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$company_id = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['totalht'])) {
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['vat'])) {
|
|
|
|
|
$list[$assoc['company_id']]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax1'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax2'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['dtype'][] = (int) $assoc['dtype'];
|
|
|
|
|
$list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']);
|
|
|
|
|
$list[$assoc['company_id']]['datep'][] = $db->jdate($assoc['datep']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['company_name'][] = (string) $assoc['company_name'];
|
|
|
|
|
$list[$assoc['company_id']]['company_id'][] = (int) $assoc['company_id'];
|
|
|
|
|
$list[$assoc['company_id']]['company_alias'][] = (string) $assoc['company_alias'];
|
|
|
|
|
$list[$assoc['company_id']]['company_email'][] = (string) $assoc['company_email'];
|
|
|
|
|
$list[$assoc['company_id']]['company_tva_intra'][] = (string) $assoc['company_tva_intra'];
|
|
|
|
|
$list[$assoc['company_id']]['company_client'][] = (int) $assoc['company_client'];
|
|
|
|
|
$list[$assoc['company_id']]['company_fournisseur'][] = (int) $assoc['company_fournisseur'];
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_code'][] = (string) $assoc['company_customer_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_code'][] = (string) $assoc['company_supplier_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_accounting_code'][] = (string) $assoc['company_customer_accounting_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_accounting_code'][] = (string) $assoc['company_supplier_accounting_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_status'][] = (int) $assoc['company_status'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['drate'][] = $assoc['rate'];
|
|
|
|
|
$list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$assoc['company_id']]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$assoc['company_id']]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$assoc['company_id']]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$assoc['company_id']]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$assoc['company_id']]['ptype'][] = (int) $assoc['ptype'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$company_id = $assoc['company_id'];
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$company_id = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['totalht'])) {
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['vat'])) {
|
|
|
|
|
$list[$assoc['company_id']]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax1'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax2'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['dtype'][] = (int) $assoc['dtype'];
|
|
|
|
|
$list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']);
|
|
|
|
|
$list[$assoc['company_id']]['datep'][] = $db->jdate($assoc['datep']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['company_name'][] = (string) $assoc['company_name'];
|
|
|
|
|
$list[$assoc['company_id']]['company_id'][] = (int) $assoc['company_id'];
|
|
|
|
|
$list[$assoc['company_id']]['company_alias'][] = (string) $assoc['company_alias'];
|
|
|
|
|
$list[$assoc['company_id']]['company_email'][] = (string) $assoc['company_email'];
|
|
|
|
|
$list[$assoc['company_id']]['company_tva_intra'][] = (string) $assoc['company_tva_intra'];
|
|
|
|
|
$list[$assoc['company_id']]['company_client'][] = (int) $assoc['company_client'];
|
|
|
|
|
$list[$assoc['company_id']]['company_fournisseur'][] = (int) $assoc['company_fournisseur'];
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_code'][] = (string) $assoc['company_customer_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_code'][] = (string) $assoc['company_supplier_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_accounting_code'][] = (string) $assoc['company_customer_accounting_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_accounting_code'][] = (string) $assoc['company_supplier_accounting_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_status'][] = (int) $assoc['company_status'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['drate'][] = $assoc['rate'];
|
|
|
|
|
$list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$assoc['company_id']]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$assoc['company_id']]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$assoc['company_id']]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$assoc['company_id']]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$assoc['company_id']]['ptype'][] = (int) $assoc['ptype'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$company_id = $assoc['company_id'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -465,87 +457,78 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
|
|
|
|
$sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$sql) {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_thirdparty no accountancy module enabled".$sql, LOG_ERR);
|
|
|
|
|
return -1; // -1 = Not accountancy module enabled
|
|
|
|
|
}
|
|
|
|
|
if ($sql == 'TODO') {
|
|
|
|
|
return -2; // -2 = Feature not yet available
|
|
|
|
|
}
|
|
|
|
|
if ($sql != 'TODO') {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG);
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$company_id = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['totalht'])) {
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['vat'])) {
|
|
|
|
|
$list[$assoc['company_id']]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax1'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax2'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
$list[$assoc['company_id']]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['dtype'][] = $assoc['dtype'];
|
|
|
|
|
$list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']);
|
|
|
|
|
$list[$assoc['company_id']]['datep'][] = $db->jdate($assoc['datep']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['company_name'][] = (string) $assoc['company_name'];
|
|
|
|
|
$list[$assoc['company_id']]['company_id'][] = (int) $assoc['company_id'];
|
|
|
|
|
$list[$assoc['company_id']]['company_alias'][] = (string) $assoc['company_alias'];
|
|
|
|
|
$list[$assoc['company_id']]['company_email'][] = (string) $assoc['company_email'];
|
|
|
|
|
$list[$assoc['company_id']]['company_tva_intra'][] = (string) $assoc['company_tva_intra'];
|
|
|
|
|
$list[$assoc['company_id']]['company_client'][] = (int) $assoc['company_client'];
|
|
|
|
|
$list[$assoc['company_id']]['company_fournisseur'][] = (int) $assoc['company_fournisseur'];
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_code'][] = (string) $assoc['company_customer_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_code'][] = (string) $assoc['company_supplier_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_accounting_code'][] = (string) $assoc['company_customer_accounting_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_accounting_code'][] = (string) $assoc['company_supplier_accounting_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_status'][] = (int) $assoc['company_status'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['drate'][] = $assoc['rate'];
|
|
|
|
|
$list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$assoc['company_id']]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$assoc['company_id']]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$assoc['company_id']]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$assoc['company_id']]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$assoc['company_id']]['ptype'][] = (int) $assoc['ptype'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$company_id = $assoc['company_id'];
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG);
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$company_id = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['totalht'])) {
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['vat'])) {
|
|
|
|
|
$list[$assoc['company_id']]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax1'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax2'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
$list[$assoc['company_id']]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['dtype'][] = $assoc['dtype'];
|
|
|
|
|
$list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']);
|
|
|
|
|
$list[$assoc['company_id']]['datep'][] = $db->jdate($assoc['datep']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['company_name'][] = (string) $assoc['company_name'];
|
|
|
|
|
$list[$assoc['company_id']]['company_id'][] = (int) $assoc['company_id'];
|
|
|
|
|
$list[$assoc['company_id']]['company_alias'][] = (string) $assoc['company_alias'];
|
|
|
|
|
$list[$assoc['company_id']]['company_email'][] = (string) $assoc['company_email'];
|
|
|
|
|
$list[$assoc['company_id']]['company_tva_intra'][] = (string) $assoc['company_tva_intra'];
|
|
|
|
|
$list[$assoc['company_id']]['company_client'][] = (int) $assoc['company_client'];
|
|
|
|
|
$list[$assoc['company_id']]['company_fournisseur'][] = (int) $assoc['company_fournisseur'];
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_code'][] = (string) $assoc['company_customer_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_code'][] = (string) $assoc['company_supplier_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_accounting_code'][] = (string) $assoc['company_customer_accounting_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_accounting_code'][] = (string) $assoc['company_supplier_accounting_code'];
|
|
|
|
|
$list[$assoc['company_id']]['company_status'][] = (int) $assoc['company_status'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['drate'][] = $assoc['rate'];
|
|
|
|
|
$list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$assoc['company_id']]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$assoc['company_id']]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$assoc['company_id']]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$assoc['company_id']]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$assoc['company_id']]['ptype'][] = (int) $assoc['ptype'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$company_id = $assoc['company_id'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -587,88 +570,79 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
|
|
|
|
|
}
|
|
|
|
|
$sql .= " ORDER BY e.rowid";
|
|
|
|
|
|
|
|
|
|
if (!$sql) {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_thirdparty no accountancy module enabled".$sql, LOG_ERR);
|
|
|
|
|
return -1; // -1 = Not accountancy module enabled
|
|
|
|
|
}
|
|
|
|
|
if ($sql == 'TODO') {
|
|
|
|
|
return -2; // -2 = Feature not yet available
|
|
|
|
|
}
|
|
|
|
|
if ($sql != 'TODO') {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG);
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$company_id = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['totalht'])) {
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['vat'])) {
|
|
|
|
|
$list[$assoc['company_id']]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax1'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax2'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['dtype'][] = 'ExpenseReportPayment';
|
|
|
|
|
$list[$assoc['company_id']]['datef'][] = (int) $assoc['datef'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['company_name'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_id'][] = 0;
|
|
|
|
|
$list[$assoc['company_id']]['company_alias'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_email'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_tva_intra'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_client'][] = 0;
|
|
|
|
|
$list[$assoc['company_id']]['company_fournisseur'][] = 0;
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_code'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_code'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_accounting_code'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_accounting_code'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_status'][] = 0;
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['user_id'][] = (int) $assoc['fk_user_author'];
|
|
|
|
|
$list[$assoc['company_id']]['drate'][] = $assoc['rate'];
|
|
|
|
|
$list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$assoc['company_id']]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$assoc['company_id']]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$assoc['company_id']]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$assoc['company_id']]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$assoc['company_id']]['ptype'][] = 'ExpenseReportPayment';
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$company_id = $assoc['company_id'];
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG);
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$company_id = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['totalht'])) {
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['vat'])) {
|
|
|
|
|
$list[$assoc['company_id']]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax1'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$assoc['company_id']]['localtax2'])) {
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$assoc['company_id']]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['dtype'][] = 'ExpenseReportPayment';
|
|
|
|
|
$list[$assoc['company_id']]['datef'][] = (int) $assoc['datef'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['company_name'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_id'][] = 0;
|
|
|
|
|
$list[$assoc['company_id']]['company_alias'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_email'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_tva_intra'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_client'][] = 0;
|
|
|
|
|
$list[$assoc['company_id']]['company_fournisseur'][] = 0;
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_code'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_code'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_customer_accounting_code'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_supplier_accounting_code'][] = '';
|
|
|
|
|
$list[$assoc['company_id']]['company_status'][] = 0;
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['user_id'][] = (int) $assoc['fk_user_author'];
|
|
|
|
|
$list[$assoc['company_id']]['drate'][] = $assoc['rate'];
|
|
|
|
|
$list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$assoc['company_id']]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$assoc['company_id']]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$assoc['company_id']]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$assoc['company_id']]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$assoc['company_id']]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$assoc['company_id']]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$assoc['company_id']]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$assoc['company_id']]['ptype'][] = 'ExpenseReportPayment';
|
|
|
|
|
|
|
|
|
|
$list[$assoc['company_id']]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$assoc['company_id']]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$company_id = $assoc['company_id'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -836,94 +810,85 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|
|
|
|
$sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$sql) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if ($sql == 'TODO') {
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
if ($sql != 'TODO') {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
|
|
|
|
|
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$rate = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
$rate_key = $assoc['rate'];
|
|
|
|
|
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
|
|
|
|
|
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Code to avoid warnings when array entry not defined
|
|
|
|
|
if (!isset($list[$rate_key]['totalht'])) {
|
|
|
|
|
$list[$rate_key]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['vat'])) {
|
|
|
|
|
$list[$rate_key]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax1'])) {
|
|
|
|
|
$list[$rate_key]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax2'])) {
|
|
|
|
|
$list[$rate_key]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$rate_key]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
$list[$rate_key]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$rate_key]['dtype'][] = (int) $assoc['dtype'];
|
|
|
|
|
$list[$rate_key]['datef'][] = $db->jdate($assoc['datef']);
|
|
|
|
|
$list[$rate_key]['datep'][] = $db->jdate($assoc['datep']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['company_name'][] = (string) $assoc['company_name'];
|
|
|
|
|
$list[$rate_key]['company_id'][] = (int) $assoc['company_id'];
|
|
|
|
|
$list[$rate_key]['company_alias'][] = (string) $assoc['company_alias'];
|
|
|
|
|
$list[$rate_key]['company_email'][] = (string) $assoc['company_email'];
|
|
|
|
|
$list[$rate_key]['company_tva_intra'][] = (string) $assoc['company_tva_intra'];
|
|
|
|
|
$list[$rate_key]['company_client'][] = (int) $assoc['company_client'];
|
|
|
|
|
$list[$rate_key]['company_fournisseur'][] = (int) $assoc['company_fournisseur'];
|
|
|
|
|
$list[$rate_key]['company_customer_code'][] = (string) $assoc['company_customer_code'];
|
|
|
|
|
$list[$rate_key]['company_supplier_code'][] = (string) $assoc['company_supplier_code'];
|
|
|
|
|
$list[$rate_key]['company_customer_accounting_code'][] = (string) $assoc['company_customer_accounting_code'];
|
|
|
|
|
$list[$rate_key]['company_supplier_accounting_code'][] = (string) $assoc['company_supplier_accounting_code'];
|
|
|
|
|
$list[$rate_key]['company_status'][] = (int) $assoc['company_status'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$rate_key]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$rate_key]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$rate_key]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$rate_key]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$rate_key]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$rate_key]['ptype'][] = (int) $assoc['ptype'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$rate_key]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$rate_key]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$rate = $assoc['rate'];
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$rate = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
$rate_key = $assoc['rate'];
|
|
|
|
|
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
|
|
|
|
|
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Code to avoid warnings when array entry not defined
|
|
|
|
|
if (!isset($list[$rate_key]['totalht'])) {
|
|
|
|
|
$list[$rate_key]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['vat'])) {
|
|
|
|
|
$list[$rate_key]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax1'])) {
|
|
|
|
|
$list[$rate_key]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax2'])) {
|
|
|
|
|
$list[$rate_key]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$rate_key]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
$list[$rate_key]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$rate_key]['dtype'][] = (int) $assoc['dtype'];
|
|
|
|
|
$list[$rate_key]['datef'][] = $db->jdate($assoc['datef']);
|
|
|
|
|
$list[$rate_key]['datep'][] = $db->jdate($assoc['datep']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['company_name'][] = (string) $assoc['company_name'];
|
|
|
|
|
$list[$rate_key]['company_id'][] = (int) $assoc['company_id'];
|
|
|
|
|
$list[$rate_key]['company_alias'][] = (string) $assoc['company_alias'];
|
|
|
|
|
$list[$rate_key]['company_email'][] = (string) $assoc['company_email'];
|
|
|
|
|
$list[$rate_key]['company_tva_intra'][] = (string) $assoc['company_tva_intra'];
|
|
|
|
|
$list[$rate_key]['company_client'][] = (int) $assoc['company_client'];
|
|
|
|
|
$list[$rate_key]['company_fournisseur'][] = (int) $assoc['company_fournisseur'];
|
|
|
|
|
$list[$rate_key]['company_customer_code'][] = (string) $assoc['company_customer_code'];
|
|
|
|
|
$list[$rate_key]['company_supplier_code'][] = (string) $assoc['company_supplier_code'];
|
|
|
|
|
$list[$rate_key]['company_customer_accounting_code'][] = (string) $assoc['company_customer_accounting_code'];
|
|
|
|
|
$list[$rate_key]['company_supplier_accounting_code'][] = (string) $assoc['company_supplier_accounting_code'];
|
|
|
|
|
$list[$rate_key]['company_status'][] = (int) $assoc['company_status'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$rate_key]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$rate_key]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$rate_key]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$rate_key]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$rate_key]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$rate_key]['ptype'][] = (int) $assoc['ptype'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$rate_key]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$rate_key]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$rate = $assoc['rate'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CASE OF SERVICES
|
|
|
|
|
|
|
|
|
|
@ -1025,94 +990,84 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|
|
|
|
$sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$sql) {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR);
|
|
|
|
|
return -1; // -1 = Not accountancy module enabled
|
|
|
|
|
}
|
|
|
|
|
if ($sql == 'TODO') {
|
|
|
|
|
return -2; // -2 = Feature not yet available
|
|
|
|
|
}
|
|
|
|
|
if ($sql != 'TODO') {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$rate = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
$rate_key = $assoc['rate'];
|
|
|
|
|
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
|
|
|
|
|
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Code to avoid warnings when array entry not defined
|
|
|
|
|
if (!isset($list[$rate_key]['totalht'])) {
|
|
|
|
|
$list[$rate_key]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['vat'])) {
|
|
|
|
|
$list[$rate_key]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax1'])) {
|
|
|
|
|
$list[$rate_key]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax2'])) {
|
|
|
|
|
$list[$rate_key]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$rate_key]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
$list[$rate_key]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$rate_key]['dtype'][] = (int) $assoc['dtype'];
|
|
|
|
|
$list[$rate_key]['datef'][] = $db->jdate($assoc['datef']);
|
|
|
|
|
$list[$rate_key]['datep'][] = $db->jdate($assoc['datep']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['company_name'][] = (string) $assoc['company_name'];
|
|
|
|
|
$list[$rate_key]['company_id'][] = (int) $assoc['company_id'];
|
|
|
|
|
$list[$rate_key]['company_alias'][] = (string) $assoc['company_alias'];
|
|
|
|
|
$list[$rate_key]['company_email'][] = (string) $assoc['company_email'];
|
|
|
|
|
$list[$rate_key]['company_tva_intra'][] = (string) $assoc['company_tva_intra'];
|
|
|
|
|
$list[$rate_key]['company_client'][] = (int) $assoc['company_client'];
|
|
|
|
|
$list[$rate_key]['company_fournisseur'][] = (int) $assoc['company_fournisseur'];
|
|
|
|
|
$list[$rate_key]['company_customer_code'][] = (string) $assoc['company_customer_code'];
|
|
|
|
|
$list[$rate_key]['company_supplier_code'][] = (string) $assoc['company_supplier_code'];
|
|
|
|
|
$list[$rate_key]['company_customer_accounting_code'][] = (string) $assoc['company_customer_accounting_code'];
|
|
|
|
|
$list[$rate_key]['company_supplier_accounting_code'][] = (string) $assoc['company_supplier_accounting_code'];
|
|
|
|
|
$list[$rate_key]['company_status'][] = (int) $assoc['company_status'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$rate_key]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$rate_key]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$rate_key]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$rate_key]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$rate_key]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$rate_key]['ptype'][] = (int) $assoc['ptype'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$rate_key]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$rate_key]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$rate = $assoc['rate'];
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$rate = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
$rate_key = $assoc['rate'];
|
|
|
|
|
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
|
|
|
|
|
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Code to avoid warnings when array entry not defined
|
|
|
|
|
if (!isset($list[$rate_key]['totalht'])) {
|
|
|
|
|
$list[$rate_key]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['vat'])) {
|
|
|
|
|
$list[$rate_key]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax1'])) {
|
|
|
|
|
$list[$rate_key]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax2'])) {
|
|
|
|
|
$list[$rate_key]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$rate_key]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
$list[$rate_key]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$rate_key]['dtype'][] = (int) $assoc['dtype'];
|
|
|
|
|
$list[$rate_key]['datef'][] = $db->jdate($assoc['datef']);
|
|
|
|
|
$list[$rate_key]['datep'][] = $db->jdate($assoc['datep']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['company_name'][] = (string) $assoc['company_name'];
|
|
|
|
|
$list[$rate_key]['company_id'][] = (int) $assoc['company_id'];
|
|
|
|
|
$list[$rate_key]['company_alias'][] = (string) $assoc['company_alias'];
|
|
|
|
|
$list[$rate_key]['company_email'][] = (string) $assoc['company_email'];
|
|
|
|
|
$list[$rate_key]['company_tva_intra'][] = (string) $assoc['company_tva_intra'];
|
|
|
|
|
$list[$rate_key]['company_client'][] = (int) $assoc['company_client'];
|
|
|
|
|
$list[$rate_key]['company_fournisseur'][] = (int) $assoc['company_fournisseur'];
|
|
|
|
|
$list[$rate_key]['company_customer_code'][] = (string) $assoc['company_customer_code'];
|
|
|
|
|
$list[$rate_key]['company_supplier_code'][] = (string) $assoc['company_supplier_code'];
|
|
|
|
|
$list[$rate_key]['company_customer_accounting_code'][] = (string) $assoc['company_customer_accounting_code'];
|
|
|
|
|
$list[$rate_key]['company_supplier_accounting_code'][] = (string) $assoc['company_supplier_accounting_code'];
|
|
|
|
|
$list[$rate_key]['company_status'][] = (int) $assoc['company_status'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$rate_key]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$rate_key]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$rate_key]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$rate_key]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$rate_key]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$rate_key]['ptype'][] = (int) $assoc['ptype'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$rate_key]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$rate_key]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$rate = $assoc['rate'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CASE OF EXPENSE REPORT
|
|
|
|
|
|
|
|
|
|
@ -1152,81 +1107,72 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
|
|
|
|
|
}
|
|
|
|
|
$sql .= " ORDER BY e.rowid";
|
|
|
|
|
|
|
|
|
|
if (!$sql) {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql, LOG_ERR);
|
|
|
|
|
return -1; // -1 = Not accountancy module enabled
|
|
|
|
|
}
|
|
|
|
|
if ($sql == 'TODO') {
|
|
|
|
|
return -2; // -2 = Feature not yet available
|
|
|
|
|
}
|
|
|
|
|
if ($sql != 'TODO') {
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$rate = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
$rate_key = $assoc['rate'];
|
|
|
|
|
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
|
|
|
|
|
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Code to avoid warnings when array entry not defined
|
|
|
|
|
if (!isset($list[$rate_key]['totalht'])) {
|
|
|
|
|
$list[$rate_key]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['vat'])) {
|
|
|
|
|
$list[$rate_key]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax1'])) {
|
|
|
|
|
$list[$rate_key]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax2'])) {
|
|
|
|
|
$list[$rate_key]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$rate_key]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$rate_key]['dtype'][] = 'ExpenseReportPayment';
|
|
|
|
|
$list[$rate_key]['datef'][] = (int) $assoc['datef'];
|
|
|
|
|
$list[$rate_key]['company_name'][] = '';
|
|
|
|
|
$list[$rate_key]['company_id'][] = 0;
|
|
|
|
|
$list[$rate_key]['user_id'][] = (int) $assoc['fk_user_author'];
|
|
|
|
|
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$rate_key]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$rate_key]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$rate_key]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$rate_key]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$rate_key]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$rate_key]['ptype'][] = 'ExpenseReportPayment';
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$rate_key]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$rate_key]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$rate = $assoc['rate'];
|
|
|
|
|
dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG);
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$rate = -1;
|
|
|
|
|
$oldrowid = '';
|
|
|
|
|
while ($assoc = $db->fetch_array($resql)) {
|
|
|
|
|
$rate_key = $assoc['rate'];
|
|
|
|
|
if ($f_rate == 'tva_tx' && !empty($assoc['vat_src_code']) && !preg_match('/\(/', $rate_key)) {
|
|
|
|
|
$rate_key .= ' (' . $assoc['vat_src_code'] . ')';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
|
|
|
|
|
// Code to avoid warnings when array entry not defined
|
|
|
|
|
if (!isset($list[$rate_key]['totalht'])) {
|
|
|
|
|
$list[$rate_key]['totalht'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['vat'])) {
|
|
|
|
|
$list[$rate_key]['vat'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax1'])) {
|
|
|
|
|
$list[$rate_key]['localtax1'] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isset($list[$rate_key]['localtax2'])) {
|
|
|
|
|
$list[$rate_key]['localtax2'] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($assoc['rowid'] != $oldrowid) { // Si rupture sur d.rowid
|
|
|
|
|
$oldrowid = $assoc['rowid'];
|
|
|
|
|
$list[$rate_key]['totalht'] += (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat'] += (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1'] += (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2'] += (float) $assoc['total_localtax2'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['dtotal_ttc'][] = (float) $assoc['total_ttc'];
|
|
|
|
|
$list[$rate_key]['dtype'][] = 'ExpenseReportPayment';
|
|
|
|
|
$list[$rate_key]['datef'][] = (int) $assoc['datef'];
|
|
|
|
|
$list[$rate_key]['company_name'][] = '';
|
|
|
|
|
$list[$rate_key]['company_id'][] = 0;
|
|
|
|
|
$list[$rate_key]['user_id'][] = (int) $assoc['fk_user_author'];
|
|
|
|
|
$list[$rate_key]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
|
|
|
|
$list[$rate_key]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['facid'][] = (int) $assoc['facid'];
|
|
|
|
|
$list[$rate_key]['facnum'][] = (string) $assoc['facnum'];
|
|
|
|
|
$list[$rate_key]['type'][] = (int) $assoc['type'];
|
|
|
|
|
$list[$rate_key]['ftotal_ttc'][] = (float) $assoc['ftotal_ttc'];
|
|
|
|
|
$list[$rate_key]['descr'][] = (string) $assoc['descr'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['totalht_list'][] = (float) $assoc['total_ht'];
|
|
|
|
|
$list[$rate_key]['vat_list'][] = (float) $assoc['total_vat'];
|
|
|
|
|
$list[$rate_key]['localtax1_list'][] = (float) $assoc['total_localtax1'];
|
|
|
|
|
$list[$rate_key]['localtax2_list'][] = (float) $assoc['total_localtax2'];
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['pid'][] = (int) $assoc['pid'];
|
|
|
|
|
$list[$rate_key]['pref'][] = (string) $assoc['pref'];
|
|
|
|
|
$list[$rate_key]['ptype'][] = 'ExpenseReportPayment';
|
|
|
|
|
|
|
|
|
|
$list[$rate_key]['payment_id'][] = (int) $assoc['payment_id'];
|
|
|
|
|
$list[$rate_key]['payment_ref'][] = (string) $assoc['payment_ref'];
|
|
|
|
|
$list[$rate_key]['payment_amount'][] = (float) $assoc['payment_amount'];
|
|
|
|
|
|
|
|
|
|
$rate = $assoc['rate'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|