WIP migrate num_paiement into num_payment

Fix label for free product in takepos
This commit is contained in:
Laurent Destailleur 2020-03-16 19:23:18 +01:00
parent 01724894ad
commit 73f2e9e5de
17 changed files with 70 additions and 50 deletions

View File

@ -305,6 +305,7 @@ switch ($action)
$payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice();
$payment->paiementid=$invoice->mode_reglement_id;
$payment->num_paiement='';
$payment->num_payment='';
$paiement_id = $payment->create($user);
if ($paiement_id > 0)

View File

@ -2251,10 +2251,10 @@ class Facture extends CommonInvoice
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1
* ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0
* Tag the invoice as paid completely (if close_code is filled) => this->fk_statut=2, this->paye=1
* or partialy (if close_code filled) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0
*
* @param User $user Objet utilisateur qui modifie
* @param User $user Object user that modify
* @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple)
* @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple)
* @return int <0 if KO, >0 if OK

View File

@ -115,7 +115,7 @@ if (GETPOST("orphelins", "alpha"))
{
// Payments not linked to an invoice. Should not happend. For debug only.
$sql = "SELECT p.rowid, p.ref, p.datep as dp, p.amount,";
$sql.= " p.statut, p.num_paiement,";
$sql.= " p.statut, p.num_paiement as num_payment,";
$sql.= " c.code as paiement_code";
// Add fields from hooks
$parameters=array();
@ -133,7 +133,7 @@ if (GETPOST("orphelins", "alpha"))
else
{
$sql = "SELECT DISTINCT p.rowid, p.ref, p.datep as dp, p.amount,"; // DISTINCT is to avoid duplicate when there is a link to sales representatives
$sql.= " p.statut, p.num_paiement,";
$sql.= " p.statut, p.num_paiement as num_payment,";
$sql.= " c.code as paiement_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal,";
$sql.= " s.rowid as socid, s.nom as name, s.email";
@ -323,7 +323,7 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
// Payment number
print '<td>'.$objp->num_paiement.'</td>';
print '<td>'.$objp->num_payment.'</td>';
if (!$i) $totalarray['nbfield']++;
// Account

View File

@ -64,7 +64,7 @@ if (! $sortfield) $sortfield="p.rowid";
llxHeader();
$sql = "SELECT p.rowid, p.datep as dp, p.amount, p.statut";
$sql.=", c.libelle as paiement_type, p.num_paiement";
$sql.=", 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";
if ($socid)
{
@ -119,7 +119,7 @@ if ($resql)
print '<tr class="oddeven">';
print '<td><a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"), "payment").' '.$objp->rowid.'</a></td>';
print '<td width="80" align="center">'.dol_print_date($db->jdate($objp->dp), 'day')."</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 class="center">';

View File

@ -108,9 +108,10 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y
$paiement->chid = $chid;
$paiement->datepaye = $datepaye;
$paiement->amounts = $amounts; // Tableau de montant
$paiement->paiementtype = $_POST["paiementtype"];
$paiement->num_paiement = $_POST["num_paiement"];
$paiement->note = $_POST["note"];
$paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml');
$paiement->num_payment = GETPOST("num_payment", 'alphanohtml');
$paiement->note = GETPOST("note", 'none');
$paiement->note_private = GETPOST("note", 'none');
if (!$error)
{
@ -243,7 +244,7 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>';
print '<td><input name="num_paiement" type="text" value="'.GETPOST('num_paiement').'"></td></tr>'."\n";
print '<td><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td></tr>'."\n";
print '<tr>';
print '<td class="tdtop">'.$langs->trans("Comments").'</td>';

View File

@ -484,7 +484,7 @@ class BonPrelevement extends CommonObject
$paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice
$paiement->paiementid = 3; //
$paiement->num_payment = $this->ref; // Set ref of direct debit note
$paiement->num_paiement = $this->ref; // For bacward compatibility
$paiement->num_paiement = $this->ref; // For backward compatibility
$paiement->id_prelevement = $this->id;
$paiement_id = $paiement->create($user);

View File

@ -154,6 +154,7 @@ class RejetPrelevement
$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

@ -603,7 +603,7 @@ if ($id > 0)
/*
* Payments
*/
$sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,";
$sql = "SELECT p.rowid, p.num_paiement as num_payment, datep as dp, p.amount,";
$sql .= " c.code as type_code,c.libelle as paiement_type,";
$sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal';
$sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p";
@ -647,7 +647,7 @@ if ($id > 0)
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
$labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
print "<td>".$labeltype.' '.$objp->num_paiement."</td>\n";
print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
if (!empty($conf->banque->enabled))
{
$bankaccountstatic->id = $objp->baid;

View File

@ -69,8 +69,17 @@ class PaymentSocialContribution extends CommonObject
*/
public $fk_typepaiement;
/**
* @var string
* @deprecated
*/
public $num_paiement;
/**
* @var string
*/
public $num_payment;
/**
* @var int ID
*/
@ -125,7 +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);
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->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
@ -149,11 +159,11 @@ class PaymentSocialContribution extends CommonObject
if ($totalamount != 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,";
$sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)";
$sql .= " fk_typepaiement, num_paiement as num_payment, note, fk_user_creat, fk_bank)";
$sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',";
$sql .= " '".$this->db->idate($this->datepaye)."',";
$sql .= " ".$totalamount.",";
$sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.",";
$sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.",";
$sql .= " 0)";
$resql = $this->db->query($sql);
@ -231,7 +241,7 @@ class PaymentSocialContribution extends CommonObject
$sql.= " t.datep,";
$sql.= " t.amount,";
$sql.= " t.fk_typepaiement,";
$sql.= " t.num_paiement,";
$sql.= " t.num_paiement as num_payment,";
$sql.= " t.note,";
$sql.= " t.fk_bank,";
$sql.= " t.fk_user_creat,";
@ -260,7 +270,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_paiement;
$this->num_paiement = $obj->num_payment;
$this->num_payment = $obj->num_payment;
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat;
@ -301,7 +312,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);
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->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
@ -511,8 +523,9 @@ class PaymentSocialContribution extends CommonObject
$this->datep = '';
$this->amount = '';
$this->fk_typepaiement = '';
$this->num_paiement = '';
$this->note = '';
$this->num_payment = '';
$this->note_private = '';
$this->note_public = '';
$this->fk_bank = '';
$this->fk_user_creat = '';
$this->fk_user_modif = '';

View File

@ -181,8 +181,7 @@ class pdf_paiement
switch ($this->doc_type) {
case "client":
$sql = "SELECT p.datep as dp, f.ref";
//$sql .= ", c.libelle as paiement_type, p.num_paiement";
$sql.= ", c.code as paiement_code, p.num_paiement";
$sql.= ", c.code as paiement_code, p.num_paiement as num_payment";
$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
$sql.= ", pf.amount as pf_amount";
if (! empty($conf->banque->enabled))
@ -212,8 +211,7 @@ class pdf_paiement
break;
case "fourn":
$sql = "SELECT p.datep as dp, f.ref as ref";
//$sql .= ", c.libelle as paiement_type, p.num_paiement";
$sql.= ", c.code as paiement_code, p.num_paiement";
$sql.= ", c.code as paiement_code, p.num_paiement as num_payment";
$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
$sql.= ", pf.amount as pf_amount";
if (! empty($conf->banque->enabled))
@ -257,7 +255,7 @@ class pdf_paiement
$lines[$i][0] = $objp->ref;
$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp), "day", false, $outputlangs, true);
$lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
$lines[$i][3] = $objp->num_paiement;
$lines[$i][3] = $objp->num_payment;
$lines[$i][4] = price($objp->paiement_amount);
$lines[$i][5] = price($objp->facture_amount);
$lines[$i][6] = price($objp->pf_amount);

View File

@ -2029,7 +2029,8 @@ else
$paymentexpensereportstatic->id = $objp->rowid;
$paymentexpensereportstatic->datepaye = $db->jdate($objp->dp);
$paymentexpensereportstatic->ref = $objp->rowid;
$paymentexpensereportstatic->num_paiement = $objp->num_paiement;
$paymentexpensereportstatic->num_paiement = $objp->num_payment;
$paymentexpensereportstatic->num_payment = $objp->num_payment;
$paymentexpensereportstatic->payment_code = $objp->payment_code;
print '<tr class="oddseven">';

View File

@ -388,7 +388,7 @@ class SupplierInvoices extends DolibarrApi
* @param int $paiementid {@from body} Payment mode Id {@min 1}
* @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no}
* @param int $accountid {@from body} Account Id {@min 1}
* @param string $num_paiement {@from body} Payment number (optional)
* @param string $num_payment {@from body} Payment number (optional)
* @param string $comment {@from body} Note (optional)
* @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ')
* @param string $chqbank {@from body} Issuer bank name (optional)
@ -400,7 +400,7 @@ class SupplierInvoices extends DolibarrApi
* @throws RestException 401
* @throws RestException 404
*/
public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '')
public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '')
{
global $conf;
@ -455,7 +455,7 @@ class SupplierInvoices extends DolibarrApi
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
$paiement->paiementid = $paiementid;
$paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1);
$paiement->num_payment = $num_paiement;
$paiement->num_payment = $num_payment;
$paiement->note_public = $comment;
$paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices

View File

@ -299,10 +299,12 @@ if (empty($reshook))
$paiement->multicurrency_amounts = $multicurrency_amounts;
$paiement->paiementid = GETPOST('paiementid', 'int');
$paiement->num_payment = GETPOST('num_paiement', 'alpha');
$paiement->num_payment = GETPOST('num_paiement', 'alphanohtml');
$paiement->note_private = GETPOST('comment', 'alpha');
$paiement->num_paiement = $paiement->num_payment; // For bacward compatibility
$paiement->note = $paiement->note_private; // For bacward compatibility
$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

@ -16,6 +16,7 @@ AddThisArticle=Add this article
RestartSelling=Go back on sell
SellFinished=Sale complete
PrintTicket=Print ticket
SendTicket=Send ticket
NoProductFound=No article found
ProductFound=product found
NoArticle=No article

View File

@ -658,6 +658,7 @@ if ($ispaymentok)
}
$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;
$paiement->ext_payment_site = $service;

View File

@ -45,6 +45,12 @@ $idproduct = GETPOST('idproduct', 'int');
$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant
$placeid = 0; // $placeid is ID of invoice
if (empty($user->rights->takepos->run)) {
access_forbidden();
}
if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout == 'phone')
{
// DIRECT LINK TO THIS PAGE FROM MOBILE AND NO TERMINAL SELECTED
@ -70,11 +76,6 @@ if ($conf->global->TAKEPOS_PHONE_BASIC_LAYOUT == 1 && $conf->browser->layout ==
<script type="text/javascript" src="js/jquery.colorbox-min.js"></script>';
}
if (empty($user->rights->takepos->run)) {
access_forbidden();
}
/**
* Abort invoice creationg with a given error message
*
@ -920,7 +921,7 @@ if ($placeid > 0)
if ($line->desc) $tooltiptext .= '<br>';
$tooltiptext .= $line->desc;
}
$htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : $line->product_ref, $tooltiptext);
$htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext);
} else {
if ($line->product_label) $htmlforlines .= $line->product_label;
if ($line->product_label != $line->desc)

View File

@ -97,7 +97,7 @@ $server->wsdl->addComplexType(
'',
array(
'amount' => array('name'=>'amount','type'=>'xsd:double'),
'num_paiement' => array('name'=>'num_paiement','type'=>'xsd:string'),
'num_payment' => array('name'=>'num_payment','type'=>'xsd:string'),
'thirdparty_id' => array('name'=>'thirdparty_id','type'=>'xsd:int'),
'bank_account' => array('name'=>'bank_account','type'=>'xsd:int'),
'payment_mode_id' => array('name'=>'payment_mode_id','type'=>'xsd:int'),
@ -167,14 +167,14 @@ function createPayment($authentication, $payment)
$soc = new Societe($db);
$res = $soc->fetch($payment['thirdparty_id']);
$new_payment = new Paiement($db);
$new_payment->amount = doubleval($payment['amount']);
$new_payment->num_paiement = $payment['num_paiement'];
$new_payment->bank_account = intval($payment['bank_account']);
$new_payment->paiementid = !empty($payment['payment_mode_id']) ? intval($payment['payment_mode_id']) : $soc->mode_reglement_id;
$new_payment->datepaye = $now;
$new_payment->author = $payment['thirdparty_id'];
$new_payment->amounts = array();
$new_payment = new Paiement($db);
$new_payment->amount = doubleval($payment['amount']);
$new_payment->num_payment = $payment['num_payment'];
$new_payment->fk_account = intval($payment['bank_account']);
$new_payment->paiementid = !empty($payment['payment_mode_id']) ? intval($payment['payment_mode_id']) : $soc->mode_reglement_id;
$new_payment->datepaye = $now;
$new_payment->author = $payment['thirdparty_id'];
$new_payment->amounts = array();
if (intval($payment['invoice_id']) > 0) {
$new_payment->amounts[ $payment['invoice_id'] ] = $new_payment->amount;