Fix we must add total vat on cash fence receipts (Ticket Z)

This commit is contained in:
Laurent Destailleur 2021-06-09 04:13:57 +02:00
parent f17e7a6979
commit cfa268e0d3

View File

@ -120,10 +120,9 @@ $sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CB;
$sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE; $sql.=" OR b.fk_account=".$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
$sql.=")"; $sql.=")";
*/ */
$sql = "SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code, SUM(fd.qty) as qty"; $sql = "SELECT f.rowid as facid, f.ref, f.datef as do, pf.amount as amount, b.fk_account as bankid, cp.code";
$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b,"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."bank as b";
$sql .= " ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid";
$sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement AND p.fk_bank = b.rowid AND fd.fk_facture = f.rowid";
$sql .= " AND f.module_source = '".$db->escape($posmodule)."'"; $sql .= " AND f.module_source = '".$db->escape($posmodule)."'";
$sql .= " AND f.pos_source = '".$db->escape($terminalid)."'"; $sql .= " AND f.pos_source = '".$db->escape($terminalid)."'";
$sql .= " AND f.paye = 1"; $sql .= " AND f.paye = 1";
@ -145,7 +144,6 @@ if ($syear && !$smonth) {
} else { } else {
dol_print_error('', 'Year not defined'); dol_print_error('', 'Year not defined');
} }
$sql .= " GROUP BY f.rowid, f.ref, f.datef, pf.amount, b.fk_account, cp.code";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
@ -161,8 +159,8 @@ if ($resql) {
print $langs->trans("CashControl")." - ".$langs->trans("Draft"); print $langs->trans("CashControl")." - ".$langs->trans("Draft");
} }
print "</h2>"; print "</h2>";
print $langs->trans("DateCreationShort").": ".dol_print_date($object->date_creation, 'dayhour'); print $mysoc->name;
print '<br>'.$mysoc->name; print '<br>'.$langs->trans("DateCreationShort").": ".dol_print_date($object->date_creation, 'dayhour');
$userauthor = $object->fk_user_valid; $userauthor = $object->fk_user_valid;
if (empty($userauthor)) { if (empty($userauthor)) {
$userauthor = $object->fk_user_creat; $userauthor = $object->fk_user_creat;
@ -201,7 +199,9 @@ if ($resql) {
$cash = $bank = $cheque = $other = 0; $cash = $bank = $cheque = $other = 0;
$totalqty = 0; $totalqty = 0;
$totalvat = 0;
$cachebankaccount = array(); $cachebankaccount = array();
$cacheinvoiceid = array();
$transactionspertype = array(); $transactionspertype = array();
$amountpertype = array(); $amountpertype = array();
@ -209,9 +209,7 @@ if ($resql) {
while ($i < $num) { while ($i < $num) {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$totalqty += $objp->qty; // Load bankaccount
if (empty($cachebankaccount[$objp->bankid])) { if (empty($cachebankaccount[$objp->bankid])) {
$bankaccounttmp = new Account($db); $bankaccounttmp = new Account($db);
$bankaccounttmp->fetch($objp->bankid); $bankaccounttmp->fetch($objp->bankid);
@ -223,14 +221,13 @@ if ($resql) {
$invoicetmp->fetch($objp->facid); $invoicetmp->fetch($objp->facid);
/*if ($first == "yes") if (empty($cacheinvoiceid[$objp->facid])) {
{ $cacheinvoiceid[$objp->facid] = $objp->facid; // First time this invoice is found into list of invoice x payments
print '<tr class="oddeven">'; foreach($invoicetmp->lines as $line) {
print '<td>'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").'</td>'; $totalqty += $line->qty;
print '<td></td><td></td><td></td><td class="right"><span class="amount">'.price($object->opening).'</span></td>'; $totalvat += $line->total_tva;
print '</tr>'; }
$first = "no"; }
}*/
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -378,6 +375,8 @@ if ($resql) {
} }
print $langs->trans("Total").' ('.$totalqty.' '.$langs->trans("Articles").') : <span class="amount">'.price($cash + $cheque + $bank + $other).'</span>'; print $langs->trans("Total").' ('.$totalqty.' '.$langs->trans("Articles").') : <span class="amount">'.price($cash + $cheque + $bank + $other).'</span>';
print '<br>'.$langs->trans("TotalVAT").' : <span class="amount">'.price($totalvat).'</span>';
// TODO Add total localtaxes.
print '</h2>'; print '</h2>';
print '</div>'; print '</div>';