*
* 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
@@ -24,9 +24,9 @@
*/
/**
- * \file htdocs/accountancy/journal/sellsjournal.php
- * \ingroup Advanced accountancy
- * \brief Page with sells journal
+ * \file htdocs/accountancy/journal/sellsjournal.php
+ * \ingroup Advanced accountancy
+ * \brief Page with sells journal
*/
require '../../main.inc.php';
@@ -118,6 +118,7 @@ if ($result) {
$tabfac = array ();
$tabht = array ();
$tabtva = array ();
+ $def_tva = array ();
$tabttc = array ();
$tabcompany = array ();
@@ -140,10 +141,14 @@ if ($result) {
$cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
+
+ //Define array for display vat tx
+ $def_tva[$obj->rowid]=price($obj->tva_tx);
+
// Situation invoices handling
$line = new FactureLigne($db);
- $line->fetch($obj->rowid);
- $prev_progress = $line->get_prev_progress();
+ $line->fetch($obj->fdid);
+ $prev_progress = $line->get_prev_progress($obj->fdid);
if ($obj->type == Facture::TYPE_SITUATION) {
// Avoid divide by 0
if ($obj->situation_percent == 0) {
@@ -193,14 +198,17 @@ if ($action == 'writebookkeeping') {
$error = 0;
foreach ( $tabfac as $key => $val ) {
- $companystatic->id = $tabcompany[$key]['id'];
- $companystatic->name = $tabcompany[$key]['name'];
- $companystatic->client = $tabcompany[$key]['code_client'];
-$invoicestatic->id = $key;
+ $companystatic = new Societe($db);
+ $invoicestatic = new Facture($db);
+
+ $companystatic->id = $tabcompany[$key]['id'];
+ $companystatic->name = $tabcompany[$key]['name'];
+ $companystatic->client = $tabcompany[$key]['code_client'];
+
+ $invoicestatic->id = $key;
$invoicestatic->ref = $val["ref"];
-
-
+
foreach ( $tabttc[$key] as $k => $mt ) {
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
@@ -211,8 +219,8 @@ $invoicestatic->id = $key;
$bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
- //$bookkeeping->label_compte = $tabcompany[$key]['name'];
- $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers");
+ // $bookkeeping->label_compte = $tabcompany[$key]['name'];
+ $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers");
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
@@ -242,7 +250,7 @@ $invoicestatic->id = $key;
$bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
- $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode($accountingaccount->label);
+ $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode($accountingaccount->label);
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
@@ -272,7 +280,7 @@ $invoicestatic->id = $key;
$bookkeeping->fk_docdet = $val["fk_facturedet"];
$bookkeeping->code_tiers = '';
$bookkeeping->numero_compte = $k;
- $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT");
+ $bookkeeping->label_compte = utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key];
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
@@ -296,6 +304,7 @@ $invoicestatic->id = $key;
// Export
if ($action == 'export_csv') {
+
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
@@ -304,8 +313,7 @@ if ($action == 'export_csv') {
$companystatic = new Client($db);
// Model Cegid Expert Export
- if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2)
- {
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) {
$sep = ";";
foreach ( $tabfac as $key => $val ) {
@@ -313,9 +321,9 @@ if ($action == 'export_csv') {
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
-$invoicestatic->id = $key;
- $invoicestatic->ref = $val["ref"];
-
+ $invoicestatic->id = $key;
+ $invoicestatic->ref = $val["ref"];
+
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
foreach ( $tabttc[$key] as $k => $mt ) {
@@ -325,8 +333,8 @@ $invoicestatic->id = $key;
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep;
- //print utf8_decode($companystatic->name) . $sep;
+ print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep;
+ // print utf8_decode($companystatic->name) . $sep;
print $val["ref"];
print "\n";
}
@@ -341,8 +349,8 @@ $invoicestatic->id = $key;
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print utf8_decode(dol_trunc($companystatic->name,16)). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount_static->label)) . $sep;
- //print dol_trunc($accountingaccount_static->label, 32) . $sep;
+ print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode(utf8_decode($accountingaccount_static->label)) . $sep;
+ // print dol_trunc($accountingaccount_static->label, 32) . $sep;
print $val["ref"];
print "\n";
}
@@ -357,22 +365,22 @@ $invoicestatic->id = $key;
print $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . $sep;
- //print $langs->trans("VAT") . $sep;
+ print utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep;
+ // print $langs->trans("VAT") . $sep;
print $val["ref"];
print "\n";
}
}
}
- } else {
+ } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) {
// Model Classic Export
foreach ( $tabfac as $key => $val ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
-
+
$invoicestatic->id = $key;
- $invoicestatic->ref = $val["ref"];
+ $invoicestatic->ref = $val["ref"];
$date = dol_print_date($db->jdate($val["date"]), 'day');
@@ -380,8 +388,8 @@ $invoicestatic->id = $key;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
- print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
- //print '"' . utf8_decode($companystatic->name) . '"' . $sep;
+ print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
+ // print '"' . utf8_decode($companystatic->name) . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
@@ -396,8 +404,8 @@ $invoicestatic->id = $key;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
- print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - '. utf8_decode ( dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
- //print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
+ print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
+ // print '"' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
@@ -410,8 +418,8 @@ $invoicestatic->id = $key;
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
- print '"' . utf8_decode(dol_trunc($companystatic->name,16)).' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . '"' . $sep;
- //print '"' . $langs->trans("VAT") . '"' . $sep;
+ print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep;
+ // print '"' . $langs->trans("VAT") . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
print "\n";
@@ -440,7 +448,11 @@ $invoicestatic->id = $key;
'action' => ''
));
- print '';
+ if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 || $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) {
+ print '';
+ } else {
+ print '';
+ }
print '';
@@ -496,9 +508,9 @@ $invoicestatic->id = $key;
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
print "| " . length_accounta($k);
- //print " | " . $langs->trans("ThirdParty");
- //print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
- print " | " . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"). " | ";
+ // print "" . $langs->trans("ThirdParty");
+ // print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
+ print " | " . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . " | ";
print "" . ($mt >= 0 ? price($mt) : '') . " | ";
print "" . ($mt < 0 ? price(- $mt) : '') . " | ";
}
@@ -514,8 +526,8 @@ $invoicestatic->id = $key;
print "" . $date . " | ";
print "" . $invoicestatic->getNomUrl(1) . " | ";
print "" . length_accountg($k) . " | ";
- //print "" . $accountingaccount->label . " | ";
- print "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref . ' - ' . utf8_decode ( utf8_decode ( $accountingaccount->label)) . " | ";
+ // print "" . $accountingaccount->label . " | ";
+ print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . utf8_decode(utf8_decode($accountingaccount->label)) . " | ";
print "" . ($mt < 0 ? price(- $mt) : '') . " | ";
print "" . ($mt >= 0 ? price($mt) : '') . " | ";
print "";
@@ -529,8 +541,8 @@ $invoicestatic->id = $key;
print "" . $date . " | ";
print "" . $invoicestatic->getNomUrl(1) . " | ";
print "" . length_accountg($k) . " | ";
- print "" . $companystatic->getNomUrl(0, 'customer', 16). ' - ' . $invoicestatic->ref .' - '. $langs->trans("VAT") . " | ";
- //print "" . $langs->trans("VAT") . " | ";
+ print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. " | ";
+ // print "" . $langs->trans("VAT") . " | ";
print "" . ($mt < 0 ? price(- $mt) : '') . " | ";
print "" . ($mt >= 0 ? price($mt) : '') . " | ";
print "";
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index 46375e49ff9..20640733cd4 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -164,6 +164,7 @@ Modelcsv_COALA=Export towards Sage Coala
Modelcsv_bob50=Export towards Sage BOB 50
Modelcsv_ciel=Export towards Sage Ciel Compta or Compta Evolution
Modelcsv_quadratus=Export towards Quadratus QuadraCompta
+Modelcsv_ebp=Export towards EBP
## Tools - Init accounting account on product / service
InitAccountancy=Init accountancy
@@ -181,4 +182,5 @@ Calculated=Calculated
Formula=Formula
## Error
-ErrorNoAccountingCategoryForThisCountry=No accounting category are available for this country
\ No newline at end of file
+ErrorNoAccountingCategoryForThisCountry=No accounting category are available for this country
+ExportNotSupported=The export format setuped is not supported into this page
\ No newline at end of file