From 13cf3b1d7fb1cd64c73d48b26ff5a960fb292138 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 1 Feb 2019 15:50:12 +0100 Subject: [PATCH] Add subledger in various payment --- .../bank/class/paymentvarious.class.php | 48 +++++++------ htdocs/compta/bank/various_payment/card.php | 70 ++++++++++++++----- .../install/mysql/migration/9.0.0-10.0.0.sql | 1 + .../mysql/tables/llx_payment_various.sql | 3 +- 4 files changed, 82 insertions(+), 40 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index e126937e95c..d9e1fab8496 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 d9fa5c3c9a1..bb4ec5aacb0 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 @@ -45,12 +45,13 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $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"); -$accountancy_code=GETPOST("accountancy_code","int"); +$accountid=GETPOST("accountid",'int') > 0 ? GETPOST("accountid",'int') : 0; +$label=GETPOST("label",'alpha'); +$sens=GETPOST("sens",'int'); +$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 @@ -113,6 +114,7 @@ if (empty($reshook)) $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 +327,21 @@ if ($action == 'create') print ''; } + // Subledger account + if (! empty($conf->accounting->enabled)) + { + print ''.$langs->trans("SubledgerAccount").''; + print ''; + print $formaccounting->select_subledger_account($subledger_account, 'subledger_account', 1, null, 1, 1, ''); + print ''; + } + else // For external software + { + print ''.$langs->trans("SubledgerAccount").''; + print ''; + print ''; + } + // Project if (! empty($conf->projet->enabled)) { @@ -433,19 +450,34 @@ if ($id) print ''.$langs->trans("Amount").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).''; // Accountancy code - print ''; - print $langs->trans("AccountAccounting"); - print ''; - if (! empty($conf->accounting->enabled)) - { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('',$object->accountancy_code, 1); + print ''; + print $langs->trans("AccountAccounting"); + print ''; + if (! empty($conf->accounting->enabled)) + { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$object->accountancy_code, 1); - print $accountingaccount->getNomUrl(0,1,1,'',1); - } else { - print $object->accountancy_code; - } - print ''; + print $accountingaccount->getNomUrl(0,1,1,'',1); + } else { + print $object->accountancy_code; + } + print ''; + + // Subledger account + print ''; + print $langs->trans("SubledgerAccount"); + print ''; + if (! empty($conf->accounting->enabled)) + { + $subledgeraccount = new AccountingAccount($db); + $subledgeraccount->fetch('',$object->subledger_account, 1); + + print $subledgeraccount->getNomUrl(0,1,1,'',1); + } else { + print $object->subledger_account; + } + print ''; if (! empty($conf->banque->enabled)) { 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,