diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 836dedc0dc2..bab853c35b2 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -1155,9 +1155,9 @@ if (empty($action) || $action == 'view') { } else print $accounttoshow; print ""; + // Subledger account print ""; - if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) // Type of payment with subledger { $accounttoshowsubledger = length_accounta($k); @@ -1171,7 +1171,12 @@ if (empty($action) || $action == 'view') { //print ''.$langs->trans("ThirdpartyAccountNotDefined").''; if (! empty($tabcompany[$key]['code_compta'])) { - print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).''; + if (in_array($tabtype[$key], array('payment_various'))) { + // For such case, if subledger is not defined, we won't use subledger accounts. + print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").''; + } else { + print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).''; + } } else { diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 050bd5f3b65..420d7eb2162 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -135,9 +135,9 @@ class PaymentVarious extends CommonObject if ($this->tms) $sql.= " tms='".$this->db->idate($this->tms)."',"; $sql.= " datep='".$this->db->idate($this->datep)."',"; $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " sens=".$this->sens.","; + $sql.= " sens=".(int) $this->sens.","; $sql.= " amount=".price2num($this->amount).","; - $sql.= " fk_typepayment=".$this->fk_typepayment."',"; + $sql.= " fk_typepayment=".(int) $this->fk_typepayment.","; $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; $sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " note='".$this->db->escape($this->note)."',"; @@ -145,8 +145,8 @@ class PaymentVarious extends CommonObject $sql.= " subledger_account='".$this->db->escape($this->subledger_account)."',"; $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; $sql.= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank:"null").","; - $sql.= " fk_user_author=".$this->fk_user_author.","; - $sql.= " fk_user_modif=".$this->fk_user_modif; + $sql.= " fk_user_author=".(int) $this->fk_user_author.","; + $sql.= " fk_user_modif=".(int) $this->fk_user_modif; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 2db276ebbbe..635e95b8e12 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -64,6 +64,7 @@ $object = new PaymentVarious($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('variouscard','globalcard')); + /** * Actions */ @@ -216,6 +217,20 @@ if (empty($reshook)) setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); } } + + if ($action == 'setsubledger_account') { + $result = $object->fetch($id); + + $object->subledger_account = (GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "alpha") : ""); + + $res = $object->update($user); + if ($res > 0) { + $db->commit(); + } else { + $db->rollback(); + setEventMessages($object->error, $object->errors, 'errors'); + } + } } @@ -495,9 +510,9 @@ if ($id) // Subledger account print ''; - print $langs->trans("SubledgerAccount"); + print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, $user->rights->banque->modifier, 'string', '', 0); print ''; - print $object->subledger_account; + print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, $user->rights->banque->modifier, 'string', '', 0); print ''; if (!empty($conf->banque->enabled)) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index bc6cd99caa4..bb98e38cb09 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -224,6 +224,7 @@ ListAccounts=List of the accounting accounts UnknownAccountForThirdparty=Unknown third-party account. We will use %s UnknownAccountForThirdpartyBlocking=Unknown third-party account. Blocking error ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Third-party account not defined or third party unknown. We will use %s +ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored=Third-party unknown and subledger not defined on the payment. We will keep the subledger account value empty. ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking=Third-party account not defined or third party unknown. Blocking error. UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third-party account and waiting account not defined. Blocking error PaymentsNotLinkedToProduct=Payment not linked to any product / service