Merge pull request #6916 from aspangaro/6.0-vat2

FIX : Vat payment - Sql error / Add information in tooltip / Correct book entry in general ledger
This commit is contained in:
Laurent Destailleur 2017-05-31 19:30:07 +02:00 committed by GitHub
commit 98ddb38c00
2 changed files with 53 additions and 26 deletions

View File

@ -286,7 +286,8 @@ if ($result) {
$paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id']; $paymentvatstatic->ref = $links[$key]['url_id'];
$paymentvatstatic->label = $links[$key]['label']; $paymentvatstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentVat"); $tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id;
$tabtp[$obj->rowid][$account_pay_vat] += $obj->amount; $tabtp[$obj->rowid][$account_pay_vat] += $obj->amount;
} else if ($links[$key]['type'] == 'payment_salary') { } else if ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->id = $links[$key]['url_id'];
@ -417,9 +418,12 @@ if (! $error && $action == 'writebookkeeping') {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport $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') { } else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation $bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation
} }
$result = $bookkeeping->create($user); $result = $bookkeeping->create($user);
@ -491,14 +495,18 @@ if (! $error && $action == 'writebookkeeping') {
$objmid = $db->fetch_object($resultmid); $objmid = $db->fetch_object($resultmid);
$bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')';
} }
$bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->code_tiers = $tabcompany[$key]['code_compta'];
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
} else if ($tabtype[$key] == 'payment_donation') { } else if ($tabtype[$key] == 'payment_vat') {
$bookkeeping->code_tiers = ''; $bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k; $bookkeeping->numero_compte = $k;
$bookkeeping->doc_ref = $langs->trans("Donation") . ' (' . $val["paymentdonationid"] . ')'; // Rowid of donation $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat
} else if ($tabtype[$key] == 'banktransfert') { } else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->code_tiers = ''; $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->numero_compte = $k;
} else { } else {
// FIXME Should be a temporary account ??? // FIXME Should be a temporary account ???
@ -732,6 +740,7 @@ if (empty($action) || $action == 'view') {
$invoicestatic = new Facture($db); $invoicestatic = new Facture($db);
$invoicesupplierstatic = new FactureFournisseur($db); $invoicesupplierstatic = new FactureFournisseur($db);
$expensereportstatic = new ExpenseReport($db); $expensereportstatic = new ExpenseReport($db);
$vatstatic = new Tva($db);
$donationstatic = new Don($db); $donationstatic = new Don($db);
llxHeader('', $langs->trans("FinanceJournal")); llxHeader('', $langs->trans("FinanceJournal"));
@ -859,6 +868,20 @@ if (empty($action) || $action == 'view') {
} }
else dol_print_error($db); else dol_print_error($db);
} }
elseif ($tabtype[$key] == 'payment_vat')
{
$sqlmid = 'SELECT v.rowid as id';
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "tva as v";
$sqlmid .= " WHERE v.rowid=" . $val["paymentvatid"];
dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG);
$resultmid = $db->query($sqlmid);
if ($resultmid) {
$objmid = $db->fetch_object($resultmid);
$vatstatic->fetch($objmid->id);
$ref=$langs->trans("PaymentVat").' '.$vatstatic->getNomUrl(1);
}
else dol_print_error($db);
}
elseif ($tabtype[$key] == 'payment_donation') elseif ($tabtype[$key] == 'payment_donation')
{ {
$sqlmid = 'SELECT payd.fk_donation as id'; $sqlmid = 'SELECT payd.fk_donation as id';

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
$langs->load("compta"); $langs->load("compta");
$langs->load("bills"); $langs->load("bills");
@ -94,10 +95,10 @@ llxHeader('', $langs->trans("VATPayments"));
$form = new Form($db); $form = new Form($db);
$formother=new FormOther($db); $formother=new FormOther($db);
$tva_static = new Tva($db); $tva_static = new Tva($db);
$accountstatic = new Account($db); $bankstatic = new Account($db);
$sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,"; $sql = "SELECT t.rowid, t.amount, t.label, t.datev as dv, t.datep as dp, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,";
$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
@ -227,19 +228,22 @@ if ($result)
{ {
print '<td>'; print '<td>';
if ($obj->fk_bank > 0) if ($obj->fk_bank > 0)
{ {
//$accountstatic->fetch($obj->fk_bank); $bankstatic->id=$obj->bid;
$accountstatic->id=$obj->bid; $bankstatic->ref=$obj->bref;
$accountstatic->ref=$obj->bref; $bankstatic->number=$obj->bnumber;
$accountstatic->number=$obj->bnumber; $bankstatic->account_number=$obj->account_number;
$accountstatic->accountancy_number=$obj->account_number;
$accountstatic->accountancy_journal=$obj->accountancy_journal; $accountingjournal = new AccountingJournal($db);
$accountstatic->label=$obj->blabel; $accountingjournal->fetch($obj->fk_accountancy_journal);
print $accountstatic->getNomUrl(1); $bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1);
}
else print '&nbsp;'; $bankstatic->label=$obj->blabel;
print '</td>'; print $bankstatic->getNomUrl(1);
} }
else print '&nbsp;';
print '</td>';
}
// Amount // Amount
$total = $total + $obj->amount; $total = $total + $obj->amount;
print "<td align=\"right\">".price($obj->amount)."</td>"; print "<td align=\"right\">".price($obj->amount)."</td>";