';
+ // Button to write into Ledger
+ if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
+ print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
+ print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '
';
+ if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
+ print '';
+ }
+ else {
+ print '';
+ }
print '
';
print '
@@ -612,7 +640,7 @@ if (empty($action) || $action == 'view') {
}
else print $accountoshow;
print "";
- print "
";
print "";
@@ -635,7 +663,7 @@ if (empty($action) || $action == 'view') {
}
else print $accountoshow;
print "";
- print "
";
diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php
index 0d2e7ac19cc..4eb4dc72171 100644
--- a/htdocs/accountancy/journal/sellsjournal.php
+++ b/htdocs/accountancy/journal/sellsjournal.php
@@ -89,27 +89,26 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
-$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
-$idpays = $p[0];
+$idpays = $mysoc->country_id;
$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 .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,";
$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 .= " 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 .= " ct.accountancy_code_sell as account_tva";
$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
$sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture";
$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
-$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 . "c_tva as ct ON ((fd.vat_src_code <> '' AND fd.vat_src_code = ct.code) OR (fd.vat_src_code = '' AND fd.tva_tx = ct.taux)) AND ct.fk_pays = '" . $idpays . "'";
$sql .= " WHERE fd.fk_code_ventilation > 0";
$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy
$sql .= " AND f.fk_statut > 0"; // TODO Facture annulée ?
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
} else {
- $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
+ $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
}
$sql .= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end)
@@ -127,29 +126,34 @@ if ($result) {
$tabcompany = array ();
$num = $db->num_rows($result);
- $i = 0;
+ // Variables
$cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef");
+ $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
+ $i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object($result);
- // les variables
+ // Controls
$compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
$compta_prod = $obj->compte;
if (empty($compta_prod)) {
if ($obj->product_type == 0)
$compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
- else
- $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
+ else
+ $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef");
}
- $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);
+ $vatdata = getTaxesFromId($obj->tva_tx.($obj->vat_src_code?' ('.$obj->vat_src_code.')':''), $mysoc, $mysoc, 0);
+ $compta_tva = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
- //Define array for display vat tx
- $def_tva[$obj->rowid]=price($obj->tva_tx);
+ // Define array to display all VAT rates that use this accounting account $compta_tva
+ if ((! price2num($obj->tva_tx)) || ! empty($obj->vat_src_code))
+ {
+ $def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
+ }
// Situation invoices handling
$line = new FactureLigne($db);
@@ -231,10 +235,11 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
- $bookkeeping->code_tiers = $tabcompany[$key]['code_client'];
- $bookkeeping->numero_compte = $tabcompany[$key]['code_compta'];
- // $bookkeeping->label_compte = $tabcompany[$key]['name'];
- $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers");
+ $bookkeeping->thirdparty_code = $companystatic->code_client;
+ $bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
+ $bookkeeping->subledger_label = ''; // TODO To complete
+ $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
+ $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account");
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt >= 0) ? $mt : 0;
@@ -277,7 +282,9 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add;
- $bookkeeping->code_tiers = '';
+ $bookkeeping->thirdparty_code = $companystatic->code_client;
+ $bookkeeping->subledger_account = '';
+ $bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
$bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label;
$bookkeeping->montant = $mt;
@@ -321,9 +328,11 @@ if ($action == 'writebookkeeping') {
$bookkeeping->doc_type = 'customer_invoice';
$bookkeeping->fk_doc = $key;
$bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add
- $bookkeeping->code_tiers = '';
+ $bookkeeping->thirdparty_code = $companystatic->code_client;
+ $bookkeeping->subledger_account = '';
+ $bookkeeping->subledger_label = '';
$bookkeeping->numero_compte = $k;
- $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key];
+ $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]);
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
$bookkeeping->debit = ($mt < 0) ? $mt : 0;
@@ -358,6 +367,12 @@ if ($action == 'writebookkeeping') {
else
{
$db->rollback();
+
+ if ($error >= 10)
+ {
+ setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
+ break; // Break in the foreach
+ }
}
}
@@ -373,7 +388,7 @@ if ($action == 'writebookkeeping') {
{
setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
}
-
+
$action='';
}
@@ -416,7 +431,7 @@ $form = new Form($db);
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'C' : 'D') . $sep;
print ($mt <= 0 ? price(- $mt) : $mt) . $sep;
- print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep;
+ print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . $sep;
print $val["ref"];
print "\n";
}
@@ -469,7 +484,7 @@ $form = new Form($db);
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
- print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
+ print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . '"' . $sep;
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
print "\n";
@@ -535,8 +550,19 @@ if (empty($action) || $action == 'view') {
} else {
print '
';
- print '
';
+
+ // Button to write into Ledger
+ if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
+ print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
+ print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '
'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'');
+ }
+ print '
';
+ if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
+ print '';
+ }
+ else {
+ print '';
+ }
print '
';
print '
@@ -602,7 +628,7 @@ if (empty($action) || $action == 'view') {
// print "
" . $langs->trans("ThirdParty");
// print ' (' . $companystatic->getNomUrl(0, 'customer', 16) . ')';
print ' | ';
- print "
" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . " | ";
+ print "
" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("subledger_account") . " | ";
print "
" . ($mt >= 0 ? price($mt) : '') . " | ";
print "
" . ($mt < 0 ? price(- $mt) : '') . " | ";
print "";
@@ -649,7 +675,7 @@ if (empty($action) || $action == 'view') {
}
else print $accountoshow;
print "";
- print "
" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. " | ";
+ print "
" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.join(', ',$def_tva[$key][$k]). " | ";
// print "
" . $langs->trans("VAT") . " | ";
print "
" . ($mt < 0 ? price(- $mt) : '') . " | ";
print "
" . ($mt >= 0 ? price($mt) : '') . " | ";
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index c83a3aa39be..f920b04bf62 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -1502,9 +1502,12 @@ if ($id)
}
$class='tddict';
+ if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200';
if ($fieldlist[$field] == 'tracking') $class.=' tdoverflowauto';
if ($fieldlist[$field] == 'code') $class.=' width100';
if ($fieldlist[$field] == 'position') $class.=' right';
+ if ($fieldlist[$field] == 'localtax1_type') $class.=' nowrap';
+ if ($fieldlist[$field] == 'localtax2_type') $class.=' nowrap';
// Show value for field
if ($showfield) print '
'.$valuetoshow.' | ';
}
@@ -1694,7 +1697,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
} // For state page, we do not show the country input (we link to region, not country)
print '
';
$fieldname='country';
- print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
+ print $form->select_country((! empty($obj->country_code)?$obj->country_code:(! empty($obj->country)?$obj->country:'')), $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone');
print ' | ';
}
elseif ($fieldlist[$field] == 'country_id')
@@ -1820,7 +1823,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
{
$fieldname = $fieldlist[$field];
$accountancy_account = (! empty($obj->$fieldname) ? $obj->$fieldname : 0);
- print $formaccounting->select_account($accountancy_account, $fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
+ print $formaccounting->select_account($accountancy_account, '.'.$fieldlist[$field], 1, '', 1, 1, 'maxwidth200 maxwidthonsmartphone');
}
else
{
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index b8906bd1038..a51ef902eb6 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -175,7 +175,7 @@ if (empty($reshook))
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
-
+
if ($action == 'update_extras') {
$object->fetch($id);
@@ -262,21 +262,23 @@ if ($id > 0)
print '';
}
- // Assujeti a TVA ou pas
+ // VAT is used
print '
';
- print '| '.$langs->trans('VATIsUsed').' | ';
+ print ' | '.$langs->trans('VATIsUsed').' | ';
+ print '';
print yn($object->tva_assuj);
print ' | ';
print '
';
// Local Taxes
- if ($mysoc->useLocalTax(1))
+ // TODO Move this on same record than VATIsUsed
+ if ($mysoc->localtax1_assuj=="1")
{
print '
| '.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).' | ';
print yn($object->localtax1_assuj);
print ' |
';
}
- if ($mysoc->useLocalTax(2))
+ if ($mysoc->localtax1_assuj=="1")
{
print '
| '.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).' | ';
print yn($object->localtax2_assuj);
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index 06918ff2846..1f55698d13f 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -524,7 +524,7 @@ if ($action == 'create')
{
print ' |
| '.$langs->trans("AccountancyJournal").' | ';
print '';
- print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
+ print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
print ' |
';
}
@@ -982,7 +982,7 @@ else
{
print '
| '.$langs->trans("AccountancyJournal").' | ';
print '';
- print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, '', 0, 0);
+ print $formaccounting->select_journal($object->fk_accountancy_journal, 'fk_accountancy_journal', 4, 1, 0, 0);
print ' |
';
}
diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php
index 2d444c1aefe..8a348dba57a 100644
--- a/htdocs/core/class/html.formaccounting.class.php
+++ b/htdocs/core/class/html.formaccounting.class.php
@@ -54,15 +54,14 @@ class FormAccounting extends Form
* @param string $htmlname Name of field in html form
* @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
- * @param array $event Event options
* @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
* @param int $select_out Set value returned by select. 0=rowid (default), 1=code
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
- *
+ * @param int $disabledajaxcombo Disable ajax combo box.
* @return string String with HTML select
*/
- function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='')
+ function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='', $disabledajaxcombo=0)
{
global $conf;
@@ -92,8 +91,6 @@ class FormAccounting extends Form
return -1;
}
- $out = ajax_combobox($htmlname, $event);
-
$selected = 0;
while ($obj = $this->db->fetch_object($resql))
{
@@ -125,7 +122,7 @@ class FormAccounting extends Form
}
}
- $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
+ $out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, ($disabledajaxcombo?0:1));
return $out;
}
@@ -204,9 +201,9 @@ class FormAccounting extends Form
{
dol_print_error($db,$db->lasterror());
}
-
- $out .= ajax_combobox($htmlname, $event);
-
+
+ $out .= ajax_combobox($htmlname, array());
+
print $out;
}
@@ -244,7 +241,7 @@ class FormAccounting extends Form
* Return list of accounts with label by chart of accounts
*
* @param string $selectid Preselected id or code of accounting accounts (depends on $select_in)
- * @param string $htmlname Name of field in html form
+ * @param string $htmlname Name of HTML field id. If name start with '.', it is name of HTML css class, so several component with same name in different forms can be used.
* @param int $showempty Add an empty field
* @param array $event Event options
* @param int $select_in 0=selectid value is a aa.rowid (default) or 1=selectid is aa.account_number
@@ -260,7 +257,7 @@ class FormAccounting extends Form
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
$out = '';
-
+
$options = array();
if ($usecache && ! empty($this->options_cache[$usecache]))
{
@@ -287,8 +284,6 @@ class FormAccounting extends Form
return -1;
}
- $out .= ajax_combobox($htmlname, $event);
-
$selected = 0;
while ($obj = $this->db->fetch_object($resql))
{
@@ -330,14 +325,13 @@ class FormAccounting extends Form
/**
* Return list of auxilary thirdparty accounts
*
- * @param string $selectid Preselected pcg_type
- * @param string $htmlname Name of field in html form
- * @param int $showempty Add an empty field
- * @param array $event Event options
- *
- * @return string String with HTML select
+ * @param string $selectid Preselected pcg_type
+ * @param string $htmlname Name of field in html form
+ * @param int $showempty Add an empty field
+ * @param string $morecss More css
+ * @return string String with HTML select
*/
- function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) {
+ function select_auxaccount($selectid, $htmlname='account_num_aux', $showempty=0, $morecss='maxwidth200') {
$aux_account = array();
@@ -382,8 +376,7 @@ class FormAccounting extends Form
$this->db->free($resql);
// Build select
- $out = ajax_combobox($htmlname, $event);
- $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', 'maxwidth300');
+ $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
return $out;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 49bcc265050..a582263185b 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -4099,29 +4099,49 @@ function get_localtax_by_third($local)
/**
- * Get vat rate and npr from id.
- * You can call getLocalTaxesFromRate after to get other fields
+ * Get vat main information from Id.
+ * You can call getLocalTaxesFromRate after to get other fields.
*
- * @param int $vatrowid Line ID into vat rate table.
- * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
+ * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
+ * @param Societe $buyer Company object
+ * @param Societe $seller Company object
+ * @param int $firstparamisid 1 if first param is id into table (use this if you can)
+ * @return array array('rowid'=> , 'code'=> ...)
+ * @see getLocalTaxesFromRate
*/
-function getTaxesFromId($vatrowid)
+function getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
{
global $db, $mysoc;
- dol_syslog("getTaxesFromId vatrowid=".$vatrowid);
+ dol_syslog("getTaxesFromId vatrowid=".$vatrate);
// Search local taxes
- $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr";
+ $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t";
- $sql.= " WHERE t.rowid ='".$vatrowid."'";
+ if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate;
+ else
+ {
+ $vatratecleaned = $vatrate;
+ $vatratecode = '';
+ if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)"
+ {
+ $vatratecleaned = $reg[1];
+ $vatratecode = $reg[2];
+ }
+
+ $sql.=", ".MAIN_DB_PREFIX."c_country as c";
+ if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ??
+ else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
+ $sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
+ if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'";
+ }
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
-
- return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr);
+ if ($obj) return array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'rate'=>$obj->rate, 'npr'=>$obj->npr, 'accountancy_code_sell'=>$obj->accountancy_code_sell, 'accountancy_code_buy'=>$obj->accountancy_code_buy);
+ else return array();
}
else dol_print_error($db);
@@ -4135,12 +4155,13 @@ function getTaxesFromId($vatrowid)
* Instead this function must be called when adding a line to get the array of localtax and type, and then
* provide it to the function calcul_price_total.
*
- * @param string $vatrate VAT Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
- * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2)
- * @param Societe $buyer Company object
- * @param Societe $seller Company object
- * @param int $firstparamisid 1 if first param is id into table (use this if you can)
- * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
+ * @param int|string $vatrate VAT ID or Rate. Value can be value or the string with code into parenthesis or rowid if $firstparamisid is 1. Example: '8.5' or '8.5 (8.5NPR)' or 123.
+ * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2)
+ * @param Societe $buyer Company object
+ * @param Societe $seller Company object
+ * @param int $firstparamisid 1 if first param is id into table (use this if you can)
+ * @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
+ * @see getTaxesFromId
*/
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
{
@@ -4148,25 +4169,25 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local);
- $vatratecleaned = $vatrate;
- $vatratecode = '';
- if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)"
- {
- $vatratecleaned = $reg[1];
- $vatratecode = $reg[2];
- }
-
// Search local taxes
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
- if ($firstparamisid) $sql.= " WHERE t.rowid ='".$vatrate."'";
+ if ($firstparamisid) $sql.= " WHERE t.rowid = ".(int) $vatrate;
else
{
+ $vatratecleaned = $vatrate;
+ $vatratecode = '';
+ if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) // If vat is "xx (yy)"
+ {
+ $vatratecleaned = $reg[1];
+ $vatratecode = $reg[2];
+ }
+
$sql.=", ".MAIN_DB_PREFIX."c_country as c";
if ($mysoc->country_code == 'ES') $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ??
else $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
$sql.= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
- if ($vatratecode) $sql.= " AND t.code ='".$vatratecode."'";
+ if ($vatratecode) $sql.= " AND t.code = '".$vatratecode."'";
}
$resql=$db->query($sql);
diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php
index 1780da06456..af0874b8c30 100644
--- a/htdocs/core/modules/modAccounting.class.php
+++ b/htdocs/core/modules/modAccounting.class.php
@@ -224,7 +224,7 @@ class modAccounting extends DolibarrModules
$this->rights[$r][4] = 'chartofaccount';
$this->rights[$r][5] = '';
$r++;
-
+
$this->rights[$r][0] = 50401;
$this->rights[$r][1] = 'Bind products and invoices with accounting accounts';
$this->rights[$r][2] = 'r';
@@ -242,9 +242,9 @@ class modAccounting extends DolibarrModules
$this->rights[$r][5] = 'dispatch_advanced';
$r++;
*/
-
+
$this->rights[$r][0] = 50411;
- $this->rights[$r][1] = 'Read operations in General Ledger';
+ $this->rights[$r][1] = 'Read operations in Ledger';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mouvements';
@@ -252,7 +252,7 @@ class modAccounting extends DolibarrModules
$r++;
$this->rights[$r][0] = 50412;
- $this->rights[$r][1] = 'Write/Edit operations in General Ledger';
+ $this->rights[$r][1] = 'Write/Edit operations in Ledger';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mouvements';
@@ -260,7 +260,7 @@ class modAccounting extends DolibarrModules
$r++;
$this->rights[$r][0] = 50420;
- $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, general ledger)';
+ $this->rights[$r][1] = 'Report and export reports (turnover, balance, journals, ledger)';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'comptarapport';
@@ -279,7 +279,7 @@ class modAccounting extends DolibarrModules
// Menus
//-------
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
-
+
// Exports
//--------
$r=0;
diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
index 46e3b698100..a66ef47fba6 100644
--- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
+++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
@@ -90,6 +90,8 @@ ALTER TABLE llx_expedition ADD COLUMN fk_projet integer DEFAULT NULL after fk_so
ALTER TABLE llx_expensereport ADD COLUMN import_key varchar(14);
ALTER TABLE llx_expensereport ADD COLUMN extraparams varchar(255);
+
+
ALTER TABLE llx_bank_account ADD COLUMN extraparams varchar(255);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_CREATE','Product or service created','Executed when a product or sevice is created','product',30);
@@ -187,6 +189,7 @@ UPDATE llx_bank_account as ba set fk_accountancy_journal = (SELECT rowid FROM ll
ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid);
--Update general ledger for FEC format & harmonization
+
ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN code_tiers varchar(32);
ALTER TABLE llx_accounting_bookkeeping CHANGE COLUMN code_tiers thirdparty_code varchar(32);
@@ -229,6 +232,7 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoic
ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_invoice_supplier_source FOREIGN KEY (fk_invoice_supplier) REFERENCES llx_facture_fourn (rowid);
ALTER TABLE llx_facture_rec ADD COLUMN vat_src_code varchar(10) DEFAULT '';
+ALTER TABLE llx_expensereport_det ADD COLUMN vat_src_code varchar(10) DEFAULT '';
DELETE FROM llx_const WHERE name = __ENCRYPT('ADHERENT_BANK_USE_AUTO')__;
diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql
index 069cd534e4f..8d01f29de68 100644
--- a/htdocs/install/mysql/tables/llx_expensereport_det.sql
+++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql
@@ -27,6 +27,7 @@ CREATE TABLE llx_expensereport_det
qty real NOT NULL,
value_unit real NOT NULL,
remise_percent real,
+ vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3), -- Vat rate
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index 5f3d4eef2da..64744eedf4a 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -49,8 +49,8 @@ AccountancyAreaDescLoan=STEP %s: Define default accounting accounts for loans. F
AccountancyAreaDescBank=STEP %s: Define accounting accounts for each bank and financial accounts. For this, go on the card of each financial account. You can start from page %s.
AccountancyAreaDescProd=STEP %s: Define accounting accounts on your products/services. For this, use the menu entry %s.
-AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in General Ledger in one click. Complete missing bindings. For this, use the menu entry %s.
-AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the General Ledger. For this, go into menu
%s, and click into button
%s.
+AccountancyAreaDescBind=STEP %s: Check the binding between existing %s lines and accounting account is done, so application will be able to journalize transactions in Ledger in one click. Complete missing bindings. For this, use the menu entry %s.
+AccountancyAreaDescWriteRecords=STEP %s: Write transactions into the Ledger. For this, go into menu
%s, and click into button
%s.
AccountancyAreaDescAnalyze=STEP %s: Add or edit existing transactions and generate reports and exports.
AccountancyAreaDescClosePeriod=STEP %s: Close period so we can't make modification in a future.
@@ -61,6 +61,8 @@ ChangeAndLoad=Change and load
Addanaccount=Add an accounting account
AccountAccounting=Accounting account
AccountAccountingShort=Account
+SubledgerAccount=Subledger Account
+subledger_account=Subledger Account
ShowAccountingAccount=Show accounting account
ShowAccountingJournal=Show accounting journal
AccountAccountingSuggest=Accounting account suggested
@@ -77,8 +79,8 @@ SuppliersVentilation=Supplier invoice binding
ExpenseReportsVentilation=Expense report binding
CreateMvts=Create new transaction
UpdateMvts=Modification of a transaction
-WriteBookKeeping=Journalize transactions in General Ledger
-Bookkeeping=General ledger
+WriteBookKeeping=Journalize transactions in Ledger
+Bookkeeping=Ledger
AccountBalance=Account balance
CAHTF=Total purchase supplier before tax
@@ -141,16 +143,16 @@ TransactionNumShort=Num. transaction
AccountingCategory=Accounting account groups
GroupByAccountAccounting=Group by accounting account
NotMatch=Not Set
-DeleteMvt=Delete general ledger lines
+DeleteMvt=Delete 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 specific journal. At least one criteria is required.
-ConfirmDeleteMvtPartial=This will delete the selected line(s) of the general ledger
-DelBookKeeping=Delete record of the general ledger
+ConfirmDeleteMvt=This will delete all lines of the Ledger for year and/or from a specific journal. At least one criteria is required.
+ConfirmDeleteMvtPartial=This will delete the selected line(s) of the Ledger
+DelBookKeeping=Delete record of the Ledger
FinanceJournal=Finance journal
ExpenseReportsJournal=Expense reports journal
DescFinanceJournal=Finance journal including all the types of payments by bank account
-DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the General Ledger.
+DescJournalOnlyBindedVisible=This is a view of record that are bound to products/services accountancy account and can be recorded into the Ledger.
VATAccountNotDefined=Account for VAT not defined
ThirdpartyAccountNotDefined=Account for third party not defined
ProductAccountNotDefined=Account for product not defined
@@ -192,7 +194,7 @@ AutomaticBindingDone=Automatic binding done
ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used
MvtNotCorrectlyBalanced=Mouvement not correctly balanced. Credit = %s. Debit = %s
FicheVentilation=Binding card
-GeneralLedgerIsWritten=Transactions are written in the general ledger
+GeneralLedgerIsWritten=Transactions are written in the Ledger
GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be dispatched. If there is no other error message, this is probably because they were already dispatched.
NoNewRecordSaved=No new record dispatched
ListOfProductsWithoutAccountingAccount=List of products not bound to any accounting account
@@ -254,6 +256,7 @@ Calculated=Calculated
Formula=Formula
## Error
+SomeMandatoryStepsOfSetupWereNotDone=Some mandatory steps of setup was not done, please complete them
ErrorNoAccountingCategoryForThisCountry=No accounting account group available for country %s (See Home - Setup - Dictionaries)
ExportNotSupported=The export format setuped is not supported into this page
BookeppingLineAlreayExists=Lines already existing into bookeeping
@@ -261,4 +264,4 @@ NoJournalDefined=No journal defined
Binded=Lines bound
ToBind=Lines to bind
-WarningReportNotReliable=Warning, this report is not based on the General Ledger, so does not contains transaction modified manualy in the General ledger. It will be replaced by a more complete report in a next version.
+WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. It will be replaced by a more complete report in a next version.
diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang
index c85a2671c21..6f8a1b5e301 100644
--- a/htdocs/langs/en_US/compta.lang
+++ b/htdocs/langs/en_US/compta.lang
@@ -190,8 +190,10 @@ AccountancyJournal=Accountancy code journal
ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for collecting VAT - VAT on sales (used if not defined on VAT dictionary setup)
ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for recovered VAT - VAT on purchases (used if not defined on VAT dictionary setup)
ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT
-ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account by default for customer third parties (used if not defined on third party card)
-ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account by default for supplier third parties (used if not defined on third party card)
+ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties
+ACCOUNTING_ACCOUNT_CUSTOMER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated customer accouting account on third party is not defined
+ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for supplier third parties
+ACCOUNTING_ACCOUNT_SUPPLIER_Desc=Dedicated accounting account defined on third party card will be used for Subledger accouting, this one for General Ledger or as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined
CloneTax=Clone a social/fiscal tax
ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment
CloneTaxForNextMonth=Clone it for next month
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index 0f49bd832d6..0f57a23d23c 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -182,6 +182,7 @@ ErrorFailedToLoadLoginFileForMode=Failed to get the login key for mode '%s'.
ErrorModuleNotFound=File of module was not found.
ErrorFieldAccountNotDefinedForBankLine=Value for Accounting account not defined for source line id %s (%s)
ErrorFieldAccountNotDefinedForInvoiceLine=Value for Accounting account not defined for invoice id %s (%s)
+ErrorFieldAccountNotDefinedForLine=Value for Accounting account not defined for the line (%s)
ErrorBankStatementNameMustFollowRegex=Error, bank statement name must follow the following syntax rule %s
ErrorPhpMailDelivery=Check that you don't use a too high number of recipients and that your email content is not similar to a Spam. Ask also your administrator to check firewall and server logs files for a more complete information.
ErrorUserNotAssignedToTask=User must be assigned to task to be able to enter time consumed.
@@ -191,6 +192,7 @@ ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package (
select_localtax(1,$object->localtax1_value, "lt1");
print '';
}
+ print '';
- print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').' | ';
+ print ' | '.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').' | ';
print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
if (! isOnlyOneLocalTax(2))
{
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index 1fcd73f0ddc..834131a86a8 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -365,7 +365,7 @@ if ($sql_select)
print ' | ';
print '';
print ' | ';
- print ''; // date
+ print ' | '; // date
print $formother->select_month($month?$month:-1,'month',1);
$formother->select_year($year?$year:-1,'year',1, 20, 1);
print ' | ';