Skip to content

Commit

Permalink
FIX: Accountancy Bank journal Fix some problem with other module
Browse files Browse the repository at this point in the history
  • Loading branch information
aspangaro committed Mar 22, 2016
1 parent dc78cc7 commit e5d56b1
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions htdocs/accountancy/journal/bankjournal.php
Expand Up @@ -52,8 +52,9 @@
$langs->load("companies");
$langs->load("other");
$langs->load("compta");
$langs->load("bank");
$langs->load("banks");
$langs->load('bills');
$langs->load("donations");
$langs->load("accountancy");

$id_bank_account = GETPOST('id_account', 'int');
Expand Down Expand Up @@ -130,11 +131,12 @@

$num = $db->num_rows($result);
// Variables
$cptfour = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$accountancy_account_salary = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"));
$accountancy_account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : $langs->trans("CodeNotDef"));
$accountancy_account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef"));
$account_supplier = (! empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) ? $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef"));
$account_customer = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"));
$account_employee = (! empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT : $langs->trans("CodeNotDef"));
$account_pay_vat = (! empty($conf->global->ACCOUNTING_VAT_PAY_ACCOUNT) ? $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT : $langs->trans("CodeNotDef"));
$account_pay_donation = (! empty($conf->global->DONATION_ACCOUNTINGACCOUNT) ? $conf->global->DONATION_ACCOUNTINGACCOUNT : $langs->trans("CodeNotDef"));
$account_transfer = (! empty($conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH) ? $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH : $langs->trans("CodeNotDef"));

$tabpay = array ();
$tabbq = array ();
Expand All @@ -154,11 +156,9 @@
// Controls
$compta_bank = $obj->account_number;
if ($obj->label == '(SupplierInvoicePayment)')
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $cptfour);
$compta_soc = (! empty($obj->code_compta_fournisseur) ? $obj->code_compta_fournisseur : $account_supplier);
if ($obj->label == '(CustomerInvoicePayment)')
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $cptcli);
if ($obj->typeop == '(BankTransfert)')
$compta_soc = $conf->global->ACCOUNTING_ACCOUNT_TRANSFER_CASH;
$compta_soc = (! empty($obj->code_compta) ? $obj->code_compta : $account_customer);

// Variable bookkeeping
$tabpay[$obj->rowid]["date"] = $obj->do;
Expand Down Expand Up @@ -226,25 +226,23 @@
$paymentdonstatic->id = $links[$key]['url_id'];
$paymentdonstatic->fk_donation = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentDonation");
$tabtp[$obj->rowid][$accountancy_account_pay_donation] += $obj->amount;
$tabtp[$obj->rowid][$account_pay_donation] += $obj->amount;
} else if ($links[$key]['type'] == 'payment_vat') {
$paymentvatstatic->id = $links[$key]['url_id'];
$paymentvatstatic->ref = $links[$key]['url_id'];
$paymentvatstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("PaymentVat");
$tabtp[$obj->rowid][$accountancy_account_pay_vat] += $obj->amount;
$tabtp[$obj->rowid][$account_pay_vat] += $obj->amount;
} else if ($links[$key]['type'] == 'payment_salary') {
$paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id'];
$paymentsalstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentsalstatic->getNomUrl(2);
$tabtp[$obj->rowid][$accountancy_account_salary] += $obj->amount;
$tabtp[$obj->rowid][$account_employee ] += $obj->amount;
} else if ($links[$key]['type'] == 'banktransfert') {
$tabpay[$obj->rowid]["lib"] .= ' ' . $paymentvatstatic->getNomUrl(2);
$tabtp[$obj->rowid][$cpttva] += $obj->amount;
$tabpay[$obj->rowid]["lib"] .= ' ' . $langs->trans("BankTransfer");
$tabtp[$obj->rowid][$account_transfer] += $obj->amount;
}
/*else {
$tabtp [$obj->rowid] [$accountancy_account_salary] += $obj->amount;
}*/
}
}

Expand Down Expand Up @@ -572,20 +570,31 @@ function writebookkeeping() {
foreach ( $tabpay as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');

if ($val["lib"] == '(SupplierInvoicePayment)') {
$reflabel = $langs->trans('SupplierInvoicePayment');
$reflabel = $val["ref"];
if ($reflabel == '(SupplierInvoicePayment)') {
$reflabel = $langs->trans('Supplier');
}
if ($val["lib"] == '(CustomerInvoicePayment)') {
$reflabel = $langs->trans('CustomerInvoicePayment');
if ($reflabel == '(CustomerInvoicePayment)') {
$reflabel = $langs->trans('Customer');
}
if ($reflabel == '(SocialContributionPayment)') {
$reflabel = $langs->trans('SocialContribution');
}
if ($reflabel == '(DonationPayment)') {
$reflabel = $langs->trans('Donation');
}

// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td>" . $reflabel . "</td>";
print "<td>" . $ref . "</td>";
print "<td>" . length_accountg($k) . "</td>";
print "<td>" . $langs->trans('Bank') . "</td>";
if ($val['soclib'] == '') {
print "<td>" . $bank_code_journal->label . " - " . $val["ref"] . "</td>";
} else {
print "<td>" . $bank_code_journal->label . " - " . $val['soclib'] . "</td>";
}
print "<td>" . $val["type_payment"] . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
Expand All @@ -598,9 +607,9 @@ function writebookkeeping() {
if ($k != 'type') {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td>" . $val["soclib"] . "</td>";
print "<td>" . $ref . "</td>";
print "<td>" . length_accounta($k) . "</td>";
print "<td>" . $langs->trans('ThirdParty') . " (" . $val['soclib'] . ")</td>";
print "<td>" . $reflabel . ' ' . $val['soclib'] . "</td>";
print "<td>" . $val["type_payment"] . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
Expand All @@ -611,9 +620,9 @@ function writebookkeeping() {
foreach ( $tabbq[$key] as $k => $mt ) {
print "<tr " . $bc[$var] . ">";
print "<td>" . $date . "</td>";
print "<td>" . $reflabel . "</td>";
print "<td>" . $ref . "</td>";
print "<td>" . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . "</td>";
print "<td>" . $langs->trans('ThirdParty') . "</td>";
print "<td>" . $reflabel . "</td>";
print "<td>&nbsp;</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
Expand Down

0 comments on commit e5d56b1

Please sign in to comment.