Clean code. Replace num_paiement with num_payment everywhere.

This commit is contained in:
Laurent Destailleur 2020-09-14 01:03:51 +02:00
parent a2df666d34
commit 970995d728
14 changed files with 21 additions and 42 deletions

View File

@ -476,7 +476,7 @@ class BlockedLog
$this->object_data->ref = $object->ref;
$this->object_data->date = $datepayment;
$this->object_data->type_code = dol_getIdFromCode($this->db, $paymenttypeid, 'c_paiement', 'id', 'code');
$this->object_data->payment_num = ($object->num_paiement ? $object->num_paiement : $object->num_payment);
$this->object_data->payment_num = $object->num_payment;
//$this->object_data->fk_account = $object->fk_account;
$this->object_data->note = $object->note;
//var_dump($this->object_data);exit;

View File

@ -294,9 +294,8 @@ switch ($action)
// Add the payment
$payment = new Paiement($db);
$payment->datepaye = $now;
$payment->bank_account = $conf_fkaccount;
$payment->amounts[$invoice->id] = $obj_facturation->amountWithTax();
$payment->note = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice();
$payment->note_public = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice();
$payment->paiementid = $invoice->mode_reglement_id;
$payment->num_paiement = '';
$payment->num_payment = '';

View File

@ -1285,7 +1285,7 @@ class Invoices extends DolibarrApi
* @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no}
* @param int $accountid {@from body} Account Id {@min 1}
* @param string $num_payment {@from body} Payment number (optional)
* @param string $comment {@from body} Note public (optional)
* @param string $comment {@from body} Note private (optional)
* @param string $chqemetteur {@from body} Payment issuer (mandatory if paymentcode = 'CHQ')
* @param string $chqbank {@from body} Issuer bank name (optional)
*
@ -1365,7 +1365,7 @@ class Invoices extends DolibarrApi
$paymentobj->paiementid = $paymentid;
$paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1);
$paymentobj->num_payment = $num_payment;
$paymentobj->note_public = $comment;
$paymentobj->note_private = $comment;
$payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices
if ($payment_id < 0)
@ -1405,7 +1405,7 @@ class Invoices extends DolibarrApi
* @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no}
* @param int $accountid {@from body} Account Id {@min 1}
* @param string $num_payment {@from body} Payment number (optional)
* @param string $comment {@from body} Note public (optional)
* @param string $comment {@from body} Note private (optional)
* @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ')
* @param string $chqbank {@from body} Issuer bank name (optional)
*
@ -1497,7 +1497,7 @@ class Invoices extends DolibarrApi
$paymentobj->paiementid = $paymentid;
$paymentobj->paiementcode = dol_getIdFromCode($this->db, $paymentid, 'c_paiement', 'id', 'code', 1);
$paymentobj->num_payment = $num_payment;
$paymentobj->note_public = $comment;
$paymentobj->note_private = $comment;
$payment_id = $paymentobj->create(DolibarrApiAccess::$user, ($closepaidinvoices == 'yes' ? 1 : 0)); // This include closing invoices
if ($payment_id < 0)

View File

@ -265,8 +265,6 @@ if (empty($reshook))
$paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
$paiement->num_payment = GETPOST('num_paiement', 'alpha');
$paiement->note_private = GETPOST('comment', 'alpha');
$paiement->num_paiement = $paiement->num_payment; // For bacward compatibility
$paiement->note = $paiement->note_private; // For bacward compatibility
if (!$error)
{
@ -851,7 +849,7 @@ if (!GETPOST('action', 'aZ09'))
if (!$sortfield) $sortfield = 'p.datep';
$sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
$sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement';
$sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
$sql .= ', '.MAIN_DB_PREFIX.'facture as f';
$sql .= ' WHERE p.fk_facture = f.rowid';
@ -887,7 +885,7 @@ if (!GETPOST('action', 'aZ09'))
print '<tr class="oddeven">';
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n";
print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n";
print '<td>'.$objp->paiement_type.' '.$objp->num_paiement."</td>\n";
print '<td>'.$objp->paiement_type.' '.$objp->num_payment."</td>\n";
print '<td class="right">'.price($objp->amount).'</td>';
print '<td>&nbsp;</td>';
print '</tr>';

View File

@ -90,13 +90,6 @@ class Paiement extends CommonObject
*/
public $type_code;
/**
* @var string Numero du CHQ, VIR, etc...
* @deprecated
* @see $num_payment
*/
public $numero;
/**
* @var string Numero du CHQ, VIR, etc...
* @deprecated
@ -194,7 +187,6 @@ class Paiement extends CommonObject
$this->ref_ext = $obj->ref_ext;
$this->date = $this->db->jdate($obj->dp);
$this->datepaye = $this->db->jdate($obj->dp);
$this->num_paiement = $obj->num_payment; // deprecated
$this->num_payment = $obj->num_payment;
$this->montant = $obj->amount; // deprecated
$this->amount = $obj->amount;
@ -297,8 +289,8 @@ class Paiement extends CommonObject
$mtotal = $totalamount;
}
$num_payment = ($this->num_payment ? $this->num_payment : $this->num_paiement);
$note = ($this->note_public ? $this->note_public : $this->note);
$num_payment = $this->num_payment;
$note = ($this->note_private ? $this->note_private : $this->note);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", ";
@ -716,7 +708,7 @@ class Paiement extends CommonObject
$bank_line_id,
$this->id_prelevement,
DOL_URL_ROOT.'/compta/prelevement/card.php?id=',
$this->num_paiement,
$this->num_payment,
'withdraw'
);
}

View File

@ -182,7 +182,7 @@ print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($o
print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
// Numero
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_paiement.'</td></tr>';
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_payment.'</td></tr>';
// Montant
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';

View File

@ -507,7 +507,6 @@ class BonPrelevement extends CommonObject
}
$paiement->num_payment = $this->ref; // Set ref of direct debit note
$paiement->num_paiement = $this->ref; // For backward compatibility
$paiement->id_prelevement = $this->id;
$paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode

View File

@ -153,7 +153,6 @@ class RejetPrelevement
$pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1);
$pai->datepaye = $date_rejet;
$pai->paiementid = 3; // type of payment: withdrawal
$pai->num_paiement = $fac->ref;
$pai->num_payment = $fac->ref;
if ($pai->create($this->user) < 0) // we call with no_commit

View File

@ -134,9 +134,8 @@ class PaymentSocialContribution extends CommonObject
if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge;
if (isset($this->amount)) $this->amount = trim($this->amount);
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note)) $this->note = trim($this->note);
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
@ -265,9 +264,8 @@ class PaymentSocialContribution extends CommonObject
$this->datep = $this->db->jdate($obj->datep);
$this->amount = $obj->amount;
$this->fk_typepaiement = $obj->fk_typepaiement;
$this->num_paiement = $obj->num_payment;
$this->num_payment = $obj->num_payment;
$this->note = $obj->note;
$this->note_private = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_modif = $obj->fk_user_modif;
@ -305,9 +303,8 @@ class PaymentSocialContribution extends CommonObject
if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge;
if (isset($this->amount)) $this->amount = trim($this->amount);
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note)) $this->note = trim($this->note);
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
@ -326,7 +323,7 @@ class PaymentSocialContribution extends CommonObject
$sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
$sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
$sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").",";
$sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").",";
$sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
$sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
$sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").",";
$sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").",";
@ -504,7 +501,7 @@ class PaymentSocialContribution extends CommonObject
global $conf;
// Clean data
$this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
$this->num_payment = trim($this->num_payment);
$error = 0;

View File

@ -1933,7 +1933,6 @@ if ($action == 'create')
$paymentexpensereportstatic->id = $objp->rowid;
$paymentexpensereportstatic->datepaye = $db->jdate($objp->dp);
$paymentexpensereportstatic->ref = $objp->rowid;
$paymentexpensereportstatic->num_paiement = $objp->num_payment;
$paymentexpensereportstatic->num_payment = $objp->num_payment;
$paymentexpensereportstatic->payment_code = $objp->payment_code;

View File

@ -119,7 +119,6 @@ class PaiementFourn extends Paiement
$this->entity = $obj->entity;
$this->date = $this->db->jdate($obj->dp);
$this->datepaye = $this->db->jdate($obj->dp);
$this->num_paiement = $obj->num_payment;
$this->num_payment = $obj->num_payment;
$this->bank_account = $obj->fk_account;
$this->fk_account = $obj->fk_account;
@ -207,7 +206,7 @@ class PaiementFourn extends Paiement
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiementfourn (';
$sql .= 'ref, entity, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_author, fk_bank)';
$sql .= " VALUES ('".$this->db->escape($ref)."', ".$conf->entity.", '".$this->db->idate($now)."',";
$sql .= " '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.", 0)";
$sql .= " '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note_private)."', ".$user->id.", 0)";
$resql = $this->db->query($sql);
if ($resql)

View File

@ -2717,7 +2717,7 @@ if ($action == 'create')
if ($societe->localtax1_assuj == "1") $nbrows++;
if ($societe->localtax2_assuj == "1") $nbrows++;
$sql = 'SELECT p.datep as dp, p.ref, p.num_paiement, p.rowid, p.fk_bank,';
$sql = 'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
$sql .= ' c.id as paiement_type,';
$sql .= ' pf.amount,';
$sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
@ -2755,7 +2755,7 @@ if ($action == 'create')
$paymentstatic->id = $objp->rowid;
$paymentstatic->datepaye = $db->jdate($objp->dp);
$paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
$paymentstatic->num_paiement = $objp->num_paiement;
$paymentstatic->num_payment = $objp->num_payment;
$paymentstatic->payment_code = $objp->payment_code;
print '<tr class="oddeven">';
@ -2764,7 +2764,7 @@ if ($action == 'create')
print '</td>';
print '<td>'.dol_print_date($db->jdate($objp->dp), 'day').'</td>';
print '<td>';
print $form->form_modes_reglement(null, $objp->paiement_type, 'none').' '.$objp->num_paiement;
print $form->form_modes_reglement(null, $objp->paiement_type, 'none').' '.$objp->num_payment;
print '</td>';
if (!empty($conf->banque->enabled))
{

View File

@ -301,9 +301,7 @@ if (empty($reshook))
$paiement->num_payment = GETPOST('num_paiement', 'alphanohtml');
$paiement->note_private = GETPOST('comment', 'alpha');
$paiement->num_paiement = $paiement->num_payment; // For backward compatibility
$paiement->num_payment = $paiement->num_payment;
$paiement->note = $paiement->note_private; // For backward compatibility
$paiement->note_private = $paiement->note_private;
if (!$error)

View File

@ -628,7 +628,6 @@ if ($ispaymentok)
$error++; // Not yet supported
}
$paiement->paiementid = $paymentTypeId;
$paiement->num_paiement = '';
$paiement->num_payment = '';
$paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress;
$paiement->ext_payment_id = $TRANSACTIONID;