Merge pull request #13211 from ATM-Marc/FIX_11.0_excess_paid_from_situation_invoice

FIX: excess paid from situation invoices not counted when calculating remain to pay
This commit is contained in:
Laurent Destailleur 2020-02-26 16:30:20 +01:00 committed by GitHub
commit ab01acfe53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -604,14 +604,14 @@ class DiscountAbsolute
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
$sql .= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received
$sql .= ' AND f.type IN (' . Facture::TYPE_STANDARD . ', ' . Facture::TYPE_CREDIT_NOTE . ', ' . Facture::TYPE_SITUATION . ')'; // Find discount coming from credit note or excess received
}
elseif ($invoice->element == 'invoice_supplier')
{
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
$sql .= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess paid
$sql .= ' f.type IN (' . Facture::TYPE_STANDARD . ', ' . Facture::TYPE_CREDIT_NOTE . ')'; // Find discount coming from credit note or excess paid
}
else
{