2
0
forked from Wavyzz/dolibarr

Merge branch '12.0_new_payments_on_salaries' of github.com:atm-gauthier/dolibarr into NEW/add_real_payments_on_salaries

This commit is contained in:
Gauthier PC portable 024
2021-02-09 11:27:21 +01:00
8 changed files with 51 additions and 48 deletions

View File

@@ -1,6 +1,5 @@
-- ============================================================================
-- Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
@@ -18,11 +17,10 @@
-- ============================================================================
ALTER TABLE llx_salary ADD INDEX idx_salary_ref (num_payment);
ALTER TABLE llx_salary ADD INDEX idx_salary_user (fk_user, entity);
ALTER TABLE llx_salary ADD INDEX idx_salary_datep (datep);
ALTER TABLE llx_salary ADD INDEX idx_salary_datesp (datesp);
ALTER TABLE llx_salary ADD INDEX idx_salary_dateep (dateep);
ALTER TABLE llx_salary ADD CONSTRAINT fk_salary_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_ref (num_payment);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_user (fk_user, entity);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datep (datep);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_datesp (datesp);
ALTER TABLE llx_payment_salary ADD INDEX idx_payment_salary_dateep (dateep);
ALTER TABLE llx_payment_salary ADD CONSTRAINT fk_payment_salary_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);

View File

@@ -1,6 +1,5 @@
-- ===================================================================
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
-- Copyright (C) 2011-2018 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
@@ -20,16 +19,24 @@
create table llx_payment_salary
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
fk_salary integer,
datec datetime, -- date de creation
tms timestamp,
datep datetime, -- payment date
amount double(24,8) DEFAULT 0,
fk_typepaiement integer NOT NULL,
num_paiement varchar(50),
ref varchar(30) NULL, -- payment reference number (currently NULL because there is no numbering manager yet)
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
datec datetime, -- Create date
fk_user integer DEFAULT NULL,
datep date, -- payment date
datev date, -- value date (this field should not be here, only into bank tables)
salary double(24,8), -- salary of user when payment was done
amount double(24,8) NOT NULL DEFAULT 0,
fk_projet integer DEFAULT NULL,
fk_typepayment integer NOT NULL,
num_payment varchar(50), -- num cheque or other
label varchar(255),
datesp date, -- date start period
dateep date, -- date end period
entity integer DEFAULT 1 NOT NULL, -- multi company id
note text,
fk_bank integer NOT NULL,
fk_user_creat integer, -- creation user
fk_user_modif integer -- last modification user
fk_bank integer,
fk_user_author integer, -- user creating
fk_user_modif integer, -- user making last change
fk_salary integer
)ENGINE=innodb;

View File

@@ -1,6 +1,5 @@
-- ===================================================================
-- Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
@@ -18,4 +17,4 @@
-- ===================================================================
ALTER TABLE llx_salary_extrafields ADD INDEX idx_salary_extrafields (fk_object);
ALTER TABLE llx_payment_salary_extrafields ADD INDEX idx_payment_salary_extrafields (fk_object);

View File

@@ -1,6 +1,5 @@
-- ===================================================================
-- Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
-- Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.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
@@ -17,7 +16,7 @@
--
-- ===================================================================
create table llx_salary_extrafields
create table llx_payment_salary_extrafields
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,

View File

@@ -788,13 +788,13 @@ if ($id)
/*
* Payments
*/
$sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,";
$sql = "SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
$sql .= " c.code as type_code,c.libelle as paiement_type,";
$sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal';
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id";
$sql .= ", ".MAIN_DB_PREFIX."salary as salaire";
$sql .= " WHERE p.fk_salary = ".$id;
$sql .= " AND p.fk_salary = salaire.rowid";

View File

@@ -69,7 +69,7 @@ class PaymentSalary extends CommonObject
/**
* @var int ID
*/
public $fk_typepaiement;
public $fk_typepayment;
/**
* @var string
@@ -90,7 +90,7 @@ class PaymentSalary extends CommonObject
/**
* @var int ID
*/
public $fk_user_creat;
public $fk_user_author;
/**
* @var int ID
@@ -135,12 +135,12 @@ class PaymentSalary extends CommonObject
// Clean parameters
if (isset($this->fk_salary)) $this->fk_salary = (int) $this->fk_salary;
if (isset($this->amount)) $this->amount = trim($this->amount);
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note)) $this->note = trim($this->note);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_author)) $this->fk_user_author = (int) $this->fk_user_author;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
$totalamount = 0;
@@ -161,7 +161,7 @@ class PaymentSalary extends CommonObject
if ($totalamount != 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_salary, datec, datep, amount,";
$sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)";
$sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)";
$sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',";
$sql .= " '".$this->db->idate($this->datepaye)."',";
$sql .= " ".$totalamount.",";
@@ -240,15 +240,15 @@ class PaymentSalary extends CommonObject
$sql .= " t.tms,";
$sql .= " t.datep,";
$sql .= " t.amount,";
$sql .= " t.fk_typepaiement,";
$sql .= " t.num_paiement as num_payment,";
$sql .= " t.fk_typepayment,";
$sql .= " t.num_payment as num_payment,";
$sql .= " t.note,";
$sql .= " t.fk_bank,";
$sql .= " t.fk_user_creat,";
$sql .= " t.fk_user_author,";
$sql .= " t.fk_user_modif,";
$sql .= " pt.code as type_code, pt.libelle as type_label,";
$sql .= ' b.fk_account';
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
$sql .= " WHERE t.rowid = ".$id;
// TODO link on entity of tax;
@@ -269,12 +269,12 @@ class PaymentSalary extends CommonObject
$this->tms = $this->db->jdate($obj->tms);
$this->datep = $this->db->jdate($obj->datep);
$this->amount = $obj->amount;
$this->fk_typepaiement = $obj->fk_typepaiement;
$this->fk_typepayment = $obj->fk_typepayment;
$this->num_paiement = $obj->num_payment;
$this->num_payment = $obj->num_payment;
$this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_creat = $obj->fk_user_creat;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
$this->type_code = $obj->type_code;
@@ -310,12 +310,12 @@ class PaymentSalary extends CommonObject
if (isset($this->fk_salary)) $this->fk_salary = (int) $this->fk_salary;
if (isset($this->amount)) $this->amount = trim($this->amount);
if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement;
if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note)) $this->note = trim($this->note);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_author)) $this->fk_user_author = (int) $this->fk_user_author;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
@@ -331,11 +331,11 @@ class PaymentSalary extends CommonObject
$sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
$sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
$sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
$sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").",";
$sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").",";
$sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").",";
$sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
$sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
$sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").",";
$sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").",";
$sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").",";
$sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null")."";
@@ -486,12 +486,12 @@ class PaymentSalary extends CommonObject
$this->tms = '';
$this->datep = '';
$this->amount = '';
$this->fk_typepaiement = '';
$this->fk_typepayment = '';
$this->num_payment = '';
$this->note_private = '';
$this->note_public = '';
$this->fk_bank = '';
$this->fk_user_creat = '';
$this->fk_user_author = '';
$this->fk_user_modif = '';
}

View File

@@ -143,7 +143,7 @@ print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($o
print '<tr><td>'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
// Numero
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_paiement.'</td></tr>';
print '<tr><td>'.$langs->trans('Numero').'</td><td colspan="3">'.$object->num_payment.'</td></tr>';
// Montant
print '<tr><td>'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';

View File

@@ -121,7 +121,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as ps";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON (s.rowid = ps.fk_salary)";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON (u.rowid = s.fk_user)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ps.fk_typepaiement = pct.id";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ps.fk_typepayment = pct.id";
$sql .= " WHERE s.entity IN (".getEntity('user').")";
/* if ($year > 0)
{
@@ -148,7 +148,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "ps.amount", "", $param, 'class="right"', $sortfield, $sortorder);
print "</tr>\n";
while ($i < $num)