Debug module accountancy expert

This commit is contained in:
Laurent Destailleur
2016-10-06 19:59:33 +02:00
parent 0cfb0ff7b7
commit 28e4c17730
8 changed files with 135 additions and 51 deletions

View File

@@ -183,11 +183,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_desc = '';
}
/*
* View
*/
llxHeader('', $langs->trans("InitAccountancy"));
llxHeader('', $langs->trans("ProductsBinding"));
print '<script type="text/javascript">
$(function () {
@@ -244,7 +245,7 @@ if ($result) {
$num_lines = $db->num_rows($result);
$i = 0;
print load_fiche_titre($langs->trans("ModulesSystemTools"), '', 'title_accountancy');
print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy');
print '<br>';
print $langs->trans("InitAccountancyDesc") . '<br>';

View File

@@ -252,18 +252,18 @@ if ($result) {
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formventilation->select_account($account_parent, 'account_parent', 1);
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Validate") . '"/></div>';
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '"/></div>';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Country"), $_SERVER["PHP_SELF"], "co.label", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Country"), $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("VATIntra"), $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre('', '', '', '', '', 'align="center"');
print "</tr>\n";
@@ -275,8 +275,8 @@ if ($result) {
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="6" name="search_amount" value="' . $search_amount . '"></td>';
print '<td class="liste_titre" align="right"><input type="text" class="flat" size="3" name="search_vat" value="' . $search_vat . '">%</td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" size="10" name="search_account" value="' . $search_account . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_country" value="' . $search_country . '"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_tavintra" value="' . $search_tavintra . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_country" size="5" value="' . $search_country . '"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_tavintra" size="5" value="' . $search_tavintra . '"></td>';
print '<td class="liste_titre" align="center">';
$searchpitco=$form->showFilterAndCheckAddButtons(1);
print $searchpitco;
@@ -315,8 +315,8 @@ if ($result) {
print '<td>' . $codecompta . '<a href="./card.php?id=' . $objp->fdid . '">';
print img_edit();
print '</a></td>';
print '<td align="right">' . $objp->country .'</td>';
print '<td align="center">' . $objp->tva_intra . '</td>';
print '<td>' . $objp->country .'</td>';
print '<td>' . $objp->tva_intra . '</td>';
print '<td align="right"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="' . $objp->fdid . '"/></td>';
print "</tr>";

View File

@@ -76,9 +76,9 @@ if ($user->societe_id > 0 && empty($id_bank_account))
/*
* View
* Actions
*/
$error = 0;
$year_current = strftime("%Y", dol_now());
@@ -101,9 +101,9 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$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, soc.code_compta,";
$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,";
$sql .= " soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.type as typeop";
$sql .= " soc.code_compta, soc.code_compta_fournisseur, soc.rowid as socid, soc.nom as name, bu1.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'";
@@ -301,11 +301,6 @@ var_dump($tabbq);
var_dump($tabtp);
*/
/*
* Actions
*/
// Write bookkeeping
if (! $error && $action == 'writebookkeeping') {
$now = dol_now();
@@ -466,13 +461,26 @@ if (! $error && $action == 'writebookkeeping') {
}
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoRecordSaved"), null, 'warnings');
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
}
else
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
$action = '';
}
/*
* View
*/
$form = new Form($db);
// Export
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
@@ -632,8 +640,8 @@ if ($action == 'export_csv') {
}
}
}
else {
$form = new Form($db);
if (empty($action) || $action == 'view') {
$invoicestatic = new Facture($db);
$invoicesupplierstatic = new FactureFournisseur($db);
@@ -680,6 +688,7 @@ else {
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
print "<td></td>";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
@@ -749,9 +758,17 @@ else {
foreach ( $tabbq[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td><!-- Bank --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if ($accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
if ($val['soclib'] == '') {
print "<td>" . $bank_code_journal->label . " - " . $val["ref"] . "</td>";
} else {
@@ -768,9 +785,17 @@ else {
foreach ( $tabtp[$key] as $k => $mt ) {
if ($k != 'type') {
print "<tr " . $bc[$var] . ">";
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>";
print "<td>" . length_accounta($k) . "</td>";
print "<td>";
$accountoshow = length_accounta($k);
if ($accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $reflabel . ' ' . $val['soclib'] . "</td>";
print "<td>" . $val["type_payment"] . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
@@ -781,9 +806,12 @@ else {
} else {
foreach ( $tabbq[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">";
print "<td><!-- Wait --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>";
print "<td>" . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . "</td>";
print "<td>";
print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) .
print "</td>";
print "<td>" . $reflabel . "</td>";
print "<td>&nbsp;</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";

View File

@@ -86,8 +86,8 @@ $idpays = $p[0];
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,f.ref_supplier,";
$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur, s.fournisseur,";
$sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
$sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql .= " p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
@@ -184,6 +184,10 @@ if ($action == 'writebookkeeping') {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client'];
foreach ( $tabttc[$key] as $k => $mt ) {
@@ -298,7 +302,7 @@ if ($action == 'writebookkeeping') {
}
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoRecordSaved"), null, 'warnings');
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
}
else
{
@@ -520,10 +524,17 @@ if (empty($action) || $action == 'view') {
if ($mt) {
print "<tr " . $bc[$var] . " >";
print "<td></td>";
print "<td><!-- Product --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if ($accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label . "</td>";
@@ -537,10 +548,17 @@ if (empty($action) || $action == 'view') {
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
print "<tr " . $bc[$var] . " >";
print "<td></td>";
print "<td><!-- VAT --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if ($accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VatAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
@@ -551,12 +569,19 @@ if (empty($action) || $action == 'view') {
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
print "<td></td>";
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>" . length_accounta($k) . "</td>";
print "<td>";
$accountoshow = length_accounta($k);
if ($accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "</td>";
// print "</td><td>" . $langs->trans("ThirdParty");
// print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')';

View File

@@ -89,7 +89,7 @@ $idpays = $p[0];
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef as df, f.ref_client,";
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,";
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
$sql .= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
$sql .= " fd.situation_percent,ct.accountancy_code_sell as account_tva";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
@@ -204,6 +204,10 @@ if ($action == 'writebookkeeping') {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->code_compta = $tabcompany[$key]['code_compta'];
$companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur'];
$companystatic->code_client = $tabcompany[$key]['code_client'];
$companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur'];
$companystatic->client = $tabcompany[$key]['code_client'];
$invoicestatic->id = $key;
@@ -316,7 +320,7 @@ if ($action == 'writebookkeeping') {
}
elseif (count($tabpay) == $error)
{
setEventMessages($langs->trans("NoRecordSaved"), null, 'warnings');
setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
}
else
{
@@ -537,9 +541,17 @@ if (empty($action) || $action == 'view') {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
print "<td>" . length_accounta($k);
$companystatic->client = $tabcompany[$key]['code_client'];
print "<td>";
$accountoshow = length_accounta($k);
if ($accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
// print "</td><td>" . $langs->trans("ThirdParty");
// print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
print '</td>';
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "</td>";
print "</td><td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
@@ -556,7 +568,14 @@ if (empty($action) || $action == 'view') {
print "<td><!-- Product --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if ($accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
// print "<td>" . $accountingaccount->label . "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
@@ -572,7 +591,14 @@ if (empty($action) || $action == 'view') {
print "<td><!-- VAT --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if ($accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "</td>";
// print "<td>" . $langs->trans("VAT") . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";

View File

@@ -213,7 +213,7 @@ if ($result) {
print '<br><div class="inline-block divButAction">' . $langs->trans("ChangeAccount") . '<br>';
print $formventilation->select_account(GETPOST('account_parent'), 'account_parent', 1);
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Validate") . '" /></div>';
print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("ChangeBinding") . '" /></div>';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Invoice"), $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);

View File

@@ -114,6 +114,8 @@ function length_accountg($account)
{
global $conf;
if ($account < 0 || empty($account)) return 'NotDefined';
$g = $conf->global->ACCOUNTING_LENGTH_GACCOUNT;
if (! empty($g)) {
@@ -145,8 +147,10 @@ function length_accountg($account)
*/
function length_accounta($accounta)
{
global $conf;
global $conf, $langs;
if ($accounta < 0 || empty($accounta)) return 'NotDefined';
$a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT;
if (! empty($a)) {

View File

@@ -102,27 +102,24 @@ Sens=Sens
Codejournal=Journal
NumPiece=Piece number
AccountingCategory=Accounting category
NotMatch=Not Set
DeleteMvt=Delete general ledger lines
DelYear=Year to delete
DelJournal=Journal to delete
ConfirmDeleteMvt=This will delete all lines of the general ledger for year and/or from a specifics journal
ConfirmDeleteMvtPartial=This will delete the selected line(s) of the general ledger
DelBookKeeping=Delete the records of the general ledger
DescSellsJournal=Sales journal
DescPurchasesJournal=Purchases journal
FinanceJournal=Finance journal
DescFinanceJournal=Finance journal including all the types of payments by bank account
DescJournalOnlyBindedVisible=This is a view of records that are binded to accountancy account and can be recorded into the General Ledger.
DescJournalOnlyBindedVisible=This is a view of records that are binded to products/services accountancy account and can be recorded into the General Ledger.
VATAccountNotDefined=Account for VAT not defined
ThirdpartyAccountNotDefined=Account for thirdparty not defined
ProductAccountNotDefined=Account for product not defined
BankAccountNotDefined=Account for bank not defined
CustomerInvoicePayment=Payment of invoice customer
ThirdPartyAccount=Thirdparty account
NewAccountingMvt=New transaction
NumMvts=Numero of transaction
ListeMvts=List of movements
@@ -144,7 +141,7 @@ DescVentilCustomer=Consult here the list of customer invoice lines binded (or no
DescVentilMore=In most cases, if you use predefined products or services and you set the account number on the product/service card, the application will be able to make all the binding between your invoice lines and the accounting account of your chart of accounts, just in one click with the button <strong>"%s"</strong>. If account was not set on product/service cards or if you still has some lines not binded to any account, you will have to make a manual binding from the menu "<strong>%s</strong>".
DescVentilDoneCustomer=Consult here the list of the lines of invoices customers and their product accounting account
DescVentilTodoCustomer=Bind invoice lines not already binded with a product accounting account
ChangeAccount=Change the accounting account for lines selected by the account:
ChangeAccount=Change the product/service accounting account for selected lines with the following accounting account:
Vide=-
DescVentilSupplier=Consult here the list of supplier invoice lines binded or not yet binded to a product accounting account
DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account
@@ -157,6 +154,9 @@ MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %
FicheVentilation=Binding card
GeneralLedgerIsWritten=Operations are written in the general ledger
GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be recorded.
NoNewRecordSaved=No new record saved
ListOfProductsWithoutAccountingAccount=List of products not binded to any accounting account
ChangeBinding=Change the binding
## Admin
ApplyMassCategories=Apply mass categories