Skip to content
Permalink
Browse files

NEW Support tag {ccc} on payment ref

  • Loading branch information...
eldy committed Feb 3, 2019
1 parent afd53a9 commit 4b77b3ff236400431cf015210f4cfc07cf60a5e3
@@ -43,9 +43,9 @@
$confirm = GETPOST('confirm');
$facid = GETPOST('facid','int');
$socname = GETPOST('socname');
$accountid = GETPOST('accountid');
$paymentnum = GETPOST('num_paiement');
$accountid = GETPOST('accountid','int');
$paymentnum = GETPOST('num_paiement','alpha');
$socid=GETPOST('socid','int');
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
@@ -59,7 +59,6 @@
$multicurrency_amountsresttopay=array();
// Security check
$socid=0;
if ($user->societe_id > 0)
{
$socid = $user->societe_id;
@@ -219,6 +218,9 @@
$db->begin();
$thirdparty = new Societe($db);
if ($socid > 0) $thirdparty->fetch($socid);
// Clean parameters amount if payment is for a credit note
if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE)
{
@@ -238,7 +240,7 @@
if (! empty($conf->banque->enabled))
{
// Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement
if (GETPOST('accountid') <= 0)
if (GETPOST('accountid','int') <= 0)
{
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), null, 'errors');
$error++;
@@ -256,7 +258,7 @@
if (! $error)
{
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0)); // This include closing invoices and regenerating documents
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0), $thirdparty); // This include closing invoices and regenerating documents
if ($paiement_id < 0)
{
setEventMessages($paiement->error, $paiement->errors, 'errors');
@@ -280,7 +282,7 @@
{
$db->commit();
// If payment dispatching on more than one invoice, we keep on summary page, otherwise jump on invoice card
// If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card
$invoiceid=0;
foreach ($paiement->amounts as $key => $amount)
{
@@ -216,15 +216,16 @@ public function fetch($id, $ref = '', $fk_bank = '')
}
/**
* Create payment of invoices into database.
* Use this->amounts to have list of invoices for the payment.
* For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative
* Create payment of invoices into database.
* Use this->amounts to have list of invoices for the payment.
* For payment of a customer invoice, amounts are positive, for payment of credit note, amounts are negative
*
* @param User $user Object user
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @return int id of created payment, < 0 if error
* @param User $user Object user
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @param Societe $thirdparty Thirdparty
* @return int id of created payment, < 0 if error
*/
function create($user, $closepaidinvoices = 0)
function create($user, $closepaidinvoices = 0, $thirdparty = null)
{
global $conf, $langs;
@@ -274,7 +275,7 @@ function create($user, $closepaidinvoices = 0)
$this->db->begin();
$this->ref = $this->getNextNumRef('');
$this->ref = $this->getNextNumRef(is_object($thirdparty)?$thirdparty:'');
if ($way == 'dolibarr')
{
@@ -424,6 +425,7 @@ function create($user, $closepaidinvoices = 0)
// Regenerate documents of invoices
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$newlang='';
$outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
if (! empty($newlang)) {
@@ -141,11 +141,12 @@ function fetch($id, $ref = '', $fk_bank = '')
/**
* Create payment in database
*
* @param User $user Object of creating user
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @param User $user Object of creating user
* @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more
* @param Societe $thirdparty Thirdparty
* @return int id of created payment, < 0 if error
*/
function create($user, $closepaidinvoices = 0)
function create($user, $closepaidinvoices = 0, $thirdparty = null)
{
global $langs,$conf;
@@ -186,7 +187,7 @@ function create($user, $closepaidinvoices = 0)
if ($totalamount <> 0) // On accepte les montants negatifs
{
$ref = $this->getNextNumRef('');
$ref = $this->getNextNumRef(is_object($thirdparty)?$thirdparty:'');
$now=dol_now();
if ($way == 'dolibarr')
@@ -245,7 +246,8 @@ function create($user, $closepaidinvoices = 0)
// Regenerate documents of invoices
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
$outputlangs = $langs;
$newlang='';
$outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $invoice->thirdparty->default_lang;
if (! empty($newlang)) {
$outputlangs = new Translate("", $conf);
@@ -253,6 +253,9 @@
{
$db->begin();
$thirdparty = new Societe($db);
if ($socid > 0) $thirdparty->fetch($socid);
// Creation de la ligne paiement
$paiement = new PaiementFourn($db);
$paiement->datepaye = $datepaye;
@@ -263,7 +266,7 @@
$paiement->note = $_POST['comment'];
if (! $error)
{
$paiement_id = $paiement->create($user,(GETPOST('closepaidinvoices')=='on'?1:0));
$paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices')=='on'?1:0), $thirdparty);
if ($paiement_id < 0)
{
setEventMessages($paiement->error, $paiement->errors, 'errors');
@@ -285,7 +288,7 @@
{
$db->commit();
// If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card
// If payment dispatching on more than one invoice, we stay on summary page, otherwise go on invoice card
$invoiceid=0;
foreach ($paiement->amounts as $key => $amount)
{

0 comments on commit 4b77b3f

Please sign in to comment.
You can’t perform that action at this time.