Add subledger in various payment

This commit is contained in:
Alexandre SPANGARO 2019-02-01 15:50:12 +01:00
parent 3e6aef472d
commit 13cf3b1d7f
4 changed files with 82 additions and 40 deletions

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
/* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
* 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)."'";

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
/* Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
* 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 '</td></tr>';
}
// Subledger account
if (! empty($conf->accounting->enabled))
{
print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
print '<td>';
print $formaccounting->select_subledger_account($subledger_account, 'subledger_account', 1, null, 1, 1, '');
print '</td></tr>';
}
else // For external software
{
print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="subledger_account" value="'.$subledger_account.'">';
print '</td></tr>';
}
// Project
if (! empty($conf->projet->enabled))
{
@ -433,19 +450,34 @@ if ($id)
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
// Accountancy code
print '<tr><td class="nowrap">';
print $langs->trans("AccountAccounting");
print '</td><td>';
if (! empty($conf->accounting->enabled))
{
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('',$object->accountancy_code, 1);
print '<tr><td class="nowrap">';
print $langs->trans("AccountAccounting");
print '</td><td>';
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 '</td></tr>';
print $accountingaccount->getNomUrl(0,1,1,'',1);
} else {
print $object->accountancy_code;
}
print '</td></tr>';
// Subledger account
print '<tr><td class="nowrap">';
print $langs->trans("SubledgerAccount");
print '</td><td>';
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 '</td></tr>';
if (! empty($conf->banque->enabled))
{

View File

@ -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);

View File

@ -1,5 +1,5 @@
-- ===================================================================
-- Copyright (C) 2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
-- Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
--
-- 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,