FIX List of payment must be visible event they exists even if total=0
This commit is contained in:
parent
deda809dca
commit
c8d86f8a56
4 changed files with 61 additions and 48 deletions
|
|
@ -439,15 +439,15 @@ abstract class CommonInvoice extends CommonObject
|
|||
*
|
||||
* @see $error Empty string '' if no error.
|
||||
*
|
||||
* @param string $filtertype 1 to filter on type of payment == 'PRE' for the payment lines
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @param string $filtertype 1 to filter on type of payment == 'PRE' for the payment lines
|
||||
* @param int $multicurrency Return multicurrency_amount instead of amount
|
||||
* @param int $mode 0=payments + discount, 1=payments only
|
||||
* @return array<array{amount:int|float,date:int,num:string,ref:string,ref_ext?:string,fk_bank_line?:int,type:string}> Array with list of payments
|
||||
*/
|
||||
public function getListOfPayments($filtertype = '', $multicurrency = 0)
|
||||
public function getListOfPayments($filtertype = '', $multicurrency = 0, $mode = 0)
|
||||
{
|
||||
$retarray = array();
|
||||
// By default no error, list can be empty.
|
||||
$this->error = '';
|
||||
$this->error = ''; // By default no error, list can be empty.
|
||||
|
||||
$table = 'paiement_facture';
|
||||
$table2 = 'paiement';
|
||||
|
|
@ -465,40 +465,50 @@ abstract class CommonInvoice extends CommonObject
|
|||
$sharedentity = 'facture_fourn';
|
||||
}
|
||||
|
||||
$sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3 . $field4;
|
||||
$sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t";
|
||||
$sql .= " WHERE pf.".$field." = ".((int) $this->id);
|
||||
$sql .= " AND pf.".$field2." = p.rowid";
|
||||
$sql .= ' AND p.fk_paiement = t.id';
|
||||
$sql .= ' AND p.entity IN ('.getEntity($sharedentity).')';
|
||||
if ($filtertype) {
|
||||
$sql .= " AND t.code='PRE'";
|
||||
// List of payments
|
||||
if (empty($mode) || $mode == 1) {
|
||||
$sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3 . $field4;
|
||||
$sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t";
|
||||
$sql .= " WHERE pf.".$field." = ".((int) $this->id);
|
||||
$sql .= " AND pf.".$field2." = p.rowid";
|
||||
$sql .= ' AND p.fk_paiement = t.id';
|
||||
$sql .= ' AND p.entity IN ('.getEntity($sharedentity).')';
|
||||
if ($filtertype) {
|
||||
$sql .= " AND t.code='PRE'";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::getListOfPayments filtertype=".$filtertype." multicurrency=".$multicurrency." mode=".$mode, LOG_DEBUG);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($multicurrency) {
|
||||
$tmp = array('amount' => $obj->multicurrency_amount, 'type' => $obj->code, 'typeline' => 'payment', 'date' => $obj->datep, 'num' => $obj->num, 'ref' => $obj->ref);
|
||||
} else {
|
||||
$tmp = array('amount' => $obj->amount, 'type' => $obj->code, 'typeline' => 'payment', 'date' => $obj->datep, 'num' => $obj->num, 'ref' => $obj->ref);
|
||||
}
|
||||
if (!empty($field3)) {
|
||||
$tmp['ref_ext'] = $obj->ref_ext;
|
||||
}
|
||||
if (!empty($field4)) {
|
||||
$tmp['fk_bank_line'] = $obj->fk_bank;
|
||||
}
|
||||
$retarray[] = $tmp;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
dol_print_error($this->db);
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::getListOfPayments", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($multicurrency) {
|
||||
$tmp = array('amount' => $obj->multicurrency_amount, 'type' => $obj->code, 'typeline' => 'payment', 'date' => $obj->datep, 'num' => $obj->num, 'ref' => $obj->ref);
|
||||
} else {
|
||||
$tmp = array('amount' => $obj->amount, 'type' => $obj->code, 'typeline' => 'payment', 'date' => $obj->datep, 'num' => $obj->num, 'ref' => $obj->ref);
|
||||
}
|
||||
if (!empty($field3)) {
|
||||
$tmp['ref_ext'] = $obj->ref_ext;
|
||||
}
|
||||
if (!empty($field4)) {
|
||||
$tmp['fk_bank_line'] = $obj->fk_bank;
|
||||
}
|
||||
$retarray[] = $tmp;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
// look for credit notes and discounts and deposits
|
||||
// Look for credit notes and discounts and deposits
|
||||
if (empty($mode) || $mode == 2) {
|
||||
$sql = '';
|
||||
if ($this->element == 'facture' || $this->element == 'invoice') {
|
||||
$sql = "SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type";
|
||||
|
|
@ -532,14 +542,14 @@ abstract class CommonInvoice extends CommonObject
|
|||
return array();
|
||||
}
|
||||
$this->db->free($resql);
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
dol_print_error($this->db);
|
||||
return array();
|
||||
}
|
||||
|
||||
return $retarray;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
dol_print_error($this->db);
|
||||
return array();
|
||||
}
|
||||
|
||||
return $retarray;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -866,7 +866,8 @@ class pdf_crabe extends ModelePDFFactures
|
|||
$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
|
||||
|
||||
// Display Payments area
|
||||
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
|
||||
$listofpayments = $object->getListOfPayments('', 0, 1);
|
||||
if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
|
||||
$posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter);
|
||||
}
|
||||
|
||||
|
|
@ -1013,7 +1014,7 @@ class pdf_crabe extends ModelePDFFactures
|
|||
}
|
||||
|
||||
// Loop on each payment
|
||||
// TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
|
||||
// TODO Call getListOfPayments instead of hard coded sql
|
||||
$sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
|
||||
$sql .= " cp.code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
|
||||
|
|
|
|||
|
|
@ -1115,7 +1115,8 @@ class pdf_octopus extends ModelePDFFactures
|
|||
$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
|
||||
|
||||
// Display payment area
|
||||
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
|
||||
$listofpayments = $object->getListOfPayments('', 0, 1);
|
||||
if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
|
||||
$posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
|
||||
}
|
||||
|
||||
|
|
@ -1261,7 +1262,7 @@ class pdf_octopus extends ModelePDFFactures
|
|||
}
|
||||
|
||||
// Loop on each payment
|
||||
// TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
|
||||
// TODO Call getListOfPayments instead of hard coded sql
|
||||
$sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
|
||||
$sql .= " cp.code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
|
||||
|
|
|
|||
|
|
@ -1028,7 +1028,8 @@ class pdf_sponge extends ModelePDFFactures
|
|||
$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
|
||||
|
||||
// Display payment area
|
||||
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
|
||||
$listofpayments = $object->getListOfPayments('', 0, 1);
|
||||
if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
|
||||
$posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue