diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 5d6c1408a57..93ea4a80849 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2019 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -71,6 +71,8 @@ class PaymentVarious extends CommonObject public $accountancy_code; + public $subledger_account; + /** * @var int ID */ @@ -139,6 +141,7 @@ class PaymentVarious extends CommonObject $sql.= " label='".$this->db->escape($this->label)."',"; $sql.= " note='".$this->db->escape($this->note)."',"; $sql.= " accountancy_code='".$this->db->escape($this->accountancy_code)."',"; + $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.","; @@ -196,6 +199,7 @@ class PaymentVarious extends CommonObject $sql.= " v.label,"; $sql.= " v.note,"; $sql.= " v.accountancy_code,"; + $sql.= " v.subledger_account,"; $sql.= " v.fk_projet as fk_project,"; $sql.= " v.fk_bank,"; $sql.= " v.fk_user_author,"; @@ -215,25 +219,26 @@ class PaymentVarious extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->tms = $this->db->jdate($obj->tms); - $this->datep = $this->db->jdate($obj->datep); - $this->datev = $this->db->jdate($obj->datev); - $this->sens = $obj->sens; - $this->amount = $obj->amount; - $this->type_payment = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; - $this->label = $obj->label; - $this->note = $obj->note; - $this->accountancy_code = $obj->accountancy_code; - $this->fk_project = $obj->fk_project; - $this->fk_bank = $obj->fk_bank; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $obj->fk_account; - $this->fk_type = $obj->fk_type; - $this->rappro = $obj->rappro; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); + $this->datep = $this->db->jdate($obj->datep); + $this->datev = $this->db->jdate($obj->datev); + $this->sens = $obj->sens; + $this->amount = $obj->amount; + $this->type_payment = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->label = $obj->label; + $this->note = $obj->note; + $this->subledger_account = $obj->subledger_account; + $this->accountancy_code = $obj->accountancy_code; + $this->fk_project = $obj->fk_project; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; + $this->fk_account = $obj->fk_account; + $this->fk_type = $obj->fk_type; + $this->rappro = $obj->rappro; } $this->db->free($resql); @@ -298,6 +303,7 @@ class PaymentVarious extends CommonObject $this->amount=''; $this->label=''; $this->accountancy_code=''; + $this->subledger_account=''; $this->note=''; $this->fk_bank=''; $this->fk_user_author=''; @@ -360,6 +366,7 @@ class PaymentVarious extends CommonObject if ($this->note) $sql.= ", note"; $sql.= ", label"; $sql.= ", accountancy_code"; + $sql.= ", subledger_account"; $sql.= ", fk_projet"; $sql.= ", fk_user_author"; $sql.= ", datec"; @@ -376,6 +383,7 @@ class PaymentVarious extends CommonObject if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; $sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", '".$this->db->escape($this->accountancy_code)."'"; + $sql.= ", '".$this->db->escape($this->subledger_account)."'"; $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); $sql.= ", ".$user->id; $sql.= ", '".$this->db->idate($now)."'"; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 43e30a8e71b..429603ed4fc 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2019 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -48,9 +48,10 @@ $backtopage = GETPOST('backtopage', 'alpha'); $accountid=GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0; $label=GETPOST("label", "alpha"); $sens=GETPOST("sens", "int"); -$amount=GETPOST("amount"); -$paymenttype=GETPOST("paymenttype"); +$amount=GETPOST("amount", "alpha"); +$paymenttype=GETPOST("paymenttype", "int"); $accountancy_code=GETPOST("accountancy_code", "int"); +$subledger_account=GETPOST("subledger_account", "int"); $projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); // Security check @@ -112,7 +113,10 @@ if (empty($reshook)) $object->type_payment=GETPOST("paymenttype", 'int') > 0 ? GETPOST("paymenttype", "int") : 0; $object->num_payment=GETPOST("num_payment", 'alpha'); $object->fk_user_author=$user->id; + $object->accountancy_code=GETPOST("accountancy_code") > 0 ? GETPOST("accountancy_code", "int") : ""; + $object->subledger_account=GETPOST("subledger_account") > 0 ? GETPOST("subledger_account", "int") : ""; + $object->sens=GETPOST('sens'); $object->fk_project= GETPOST('fk_project', 'int'); @@ -325,6 +329,28 @@ if ($action == 'create') print ''; } + // Subledger account + if (! empty($conf->accounting->enabled)) + { + print ''.$langs->trans("SubledgerAccount").''; + print ''; + if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) + { + print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, ''); + } + else + { + print ''; + } + print ''; + } + else // For external software + { + print ''.$langs->trans("SubledgerAccount").''; + print ''; + print ''; + } + // Project if (! empty($conf->projet->enabled)) { @@ -447,6 +473,13 @@ if ($id) } print ''; + // Subledger account + print ''; + print $langs->trans("SubledgerAccount"); + print ''; + print $object->subledger_account; + print ''; + if (! empty($conf->banque->enabled)) { if ($object->fk_account > 0) diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 2d2fc43e1ef..1bac8ec18e6 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -94,3 +94,4 @@ ALTER TABLE llx_actioncomm ADD COLUMN calling_duration integer; ALTER TABLE llx_don ADD COLUMN fk_soc integer NULL; +ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_payment_various.sql b/htdocs/install/mysql/tables/llx_payment_various.sql index 880fb4b5698..320faa58034 100644 --- a/htdocs/install/mysql/tables/llx_payment_various.sql +++ b/htdocs/install/mysql/tables/llx_payment_various.sql @@ -1,5 +1,5 @@ -- =================================================================== --- Copyright (C) 2017 Alexandre Spangaro +-- Copyright (C) 2017-2019 Alexandre Spangaro -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ create table llx_payment_various amount double(24,8) DEFAULT 0 NOT NULL, fk_typepayment integer NOT NULL, accountancy_code varchar(32), + subledger_account varchar(32), fk_projet integer DEFAULT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id note text,