Merge pull request #6948 from aspangaro/6.0-salary
Fix : Book entry of salary payment in general ledger
This commit is contained in:
commit
7b0e0858ca
@ -63,7 +63,7 @@ $langs->load('bills');
|
||||
$langs->load('donations');
|
||||
$langs->load("accountancy");
|
||||
$langs->load("trips");
|
||||
$langs->load("hrm");
|
||||
$langs->load("salaries");
|
||||
|
||||
// Multi journal
|
||||
$id_journal = GETPOST('id_journal', 'int');
|
||||
@ -112,7 +112,7 @@ $idpays = $p[0];
|
||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
|
||||
$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
|
||||
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop,";
|
||||
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as name, u.firstname as firstname, bu2.type as typeop";
|
||||
$sql .= " u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, bu2.type as typeop";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "bank as b";
|
||||
$sql .= " JOIN " . MAIN_DB_PREFIX . "bank_account as ba on b.fk_account=ba.rowid";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
|
||||
@ -187,6 +187,7 @@ if ($result) {
|
||||
|
||||
$tabuser[$obj->rowid] = array (
|
||||
'id' => $obj->userid,
|
||||
'name' => $obj->firstname.' '.$obj->lastname,
|
||||
'lastname' => $obj->lastname,
|
||||
'firstname' => $obj->firstname,
|
||||
'accountancy_code' => $compta_user,
|
||||
@ -209,11 +210,11 @@ if ($result) {
|
||||
// Now loop on each link of record in bank.
|
||||
foreach ( $links as $key => $val ) {
|
||||
|
||||
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation'))) // So we excluded 'company' here
|
||||
{
|
||||
// We save tabtype for a future use, to remember what kind of payment it is
|
||||
$tabtype[$obj->rowid] = $links[$key]['type'];
|
||||
}
|
||||
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary'))) // So we excluded 'company' here
|
||||
{
|
||||
// We save tabtype for a future use, to remember what kind of payment it is
|
||||
$tabtype[$obj->rowid] = $links[$key]['type'];
|
||||
}
|
||||
|
||||
if ($links[$key]['type'] == 'payment') {
|
||||
$paymentstatic->id = $links[$key]['url_id'];
|
||||
@ -280,7 +281,7 @@ if ($result) {
|
||||
$paymentsalstatic->ref = $links[$key]['url_id'];
|
||||
$paymentsalstatic->label = $links[$key]['label'];
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
|
||||
// $tabtp[$obj->rowid][$account_employee] += $obj->amount;
|
||||
$tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
|
||||
} else if ($links[$key]['type'] == 'payment_expensereport') {
|
||||
$paymentexpensereportstatic->id = $links[$key]['url_id'];
|
||||
$paymentexpensereportstatic->fk_expensereport = $links[$key]['url_id'];
|
||||
@ -404,14 +405,18 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport
|
||||
}
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
|
||||
}
|
||||
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->label_compte = $tabuser[$key]['name'];
|
||||
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment
|
||||
}
|
||||
|
||||
$result = $bookkeeping->create($user);
|
||||
if ($result < 0) {
|
||||
if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists
|
||||
@ -481,19 +486,24 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
|
||||
}
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
|
||||
} else if ($tabtype[$key] == 'banktransfert') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->code_tiers = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = $tabuser[$key]['name'];
|
||||
$bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Rowid of salary payment
|
||||
} else if ($tabtype[$key] == 'banktransfert') {
|
||||
$bookkeeping->code_tiers = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
} else {
|
||||
// FIXME Should be a temporary account ???
|
||||
$bookkeeping->doc_ref = $k;
|
||||
@ -728,6 +738,7 @@ if (empty($action) || $action == 'view') {
|
||||
$expensereportstatic = new ExpenseReport($db);
|
||||
$vatstatic = new Tva($db);
|
||||
$donationstatic = new Don($db);
|
||||
$salarystatic = new PaymentSalary($db);
|
||||
|
||||
llxHeader('', $langs->trans("FinanceJournal"));
|
||||
|
||||
@ -882,6 +893,20 @@ if (empty($action) || $action == 'view') {
|
||||
}
|
||||
else dol_print_error($db);
|
||||
}
|
||||
elseif ($tabtype[$key] == 'payment_salary')
|
||||
{
|
||||
$sqlmid = 'SELECT s.rowid as id';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_salary as s";
|
||||
$sqlmid .= " WHERE s.rowid=" . $val["paymentsalid"];
|
||||
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
if ($resultmid) {
|
||||
$objmid = $db->fetch_object($resultmid);
|
||||
$salarystatic->fetch($objmid->id);
|
||||
$ref=$langs->trans("SalaryPayment").' '.$salarystatic->getNomUrl(1);
|
||||
}
|
||||
else dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
/*$invoicestatic->id = $key;
|
||||
|
||||
@ -66,6 +66,7 @@ RemoveFromRubriqueConfirm=Are you sure you want to remove link between the entry
|
||||
ListBankTransactions=List of bank entries
|
||||
IdTransaction=Transaction ID
|
||||
BankTransactions=Bank entries
|
||||
BankTransaction=Bank entry
|
||||
ListTransactions=List entries
|
||||
ListTransactionsByCategory=List entries/category
|
||||
TransactionsToConciliate=Entries to reconcile
|
||||
|
||||
Loading…
Reference in New Issue
Block a user