diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php
index 3a1944b3cf4..28982da4e86 100644
--- a/htdocs/accountancy/index.php
+++ b/htdocs/accountancy/index.php
@@ -262,11 +262,14 @@ if (isModEnabled('accounting')) {
print $boxlist;
print '';
-} else {
+} elseif (isModEnabled('compta')) {
print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
print ''.$langs->trans("Module10Desc")."\n";
print "
";
+} else {
+ // This case can happen mode no accounting module is on but module "intracommreport" is on
+ print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
}
// End of page
diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php
index ee4dad8a514..d45f290ad3f 100644
--- a/htdocs/compta/accounting-files.php
+++ b/htdocs/compta/accounting-files.php
@@ -178,7 +178,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
if (!empty($sql)) {
$sql .= " UNION ALL";
}
- $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens";
+ $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,";
+ $sql .= " t.localtax1, t.localtax2, t.revenuestamp,";
+ $sql .= " t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_CREDIT." as sens";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql .= " WHERE datef between ".$wheretail;
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
@@ -190,7 +192,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
if (!empty($sql)) {
$sql .= " UNION ALL";
}
- $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens";
+ $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,";
+ $sql .= " t.localtax1, t.localtax2, 0 as revenuestamp,";
+ $sql .= " t.multicurrency_code as currency, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum, ".PAY_DEBIT." as sens";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql .= " WHERE datef between ".$wheretail;
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
@@ -202,7 +206,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
if (!empty($sql)) {
$sql .= " UNION ALL";
}
- $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
+ $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat,";
+ $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
+ $sql .= " t.multicurrency_code as currency, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql .= " WHERE date_fin between ".$wheretail;
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
@@ -213,7 +219,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
if (!empty($sql)) {
$sql .= " UNION ALL";
}
- $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens";
+ $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat,";
+ $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
+ $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_CREDIT." as sens";
$sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country";
$sql .= " WHERE datedon between ".$wheretail;
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
@@ -225,7 +233,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
if (!empty($sql)) {
$sql .= " UNION ALL";
}
- $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
+ $sql .= " SELECT t.rowid as id, t.entity, t.label as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat,";
+ $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
+ $sql .= " '".$db->escape($conf->currency)."' as currency, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql .= " WHERE datep between ".$wheretail;
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
@@ -237,7 +247,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
if (!empty($sql)) {
$sql .= " UNION ALL";
}
- $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
+ $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat,";
+ $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
+ $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.date_ech as date, t.periode as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t";
$sql .= " WHERE t.date_ech between ".$wheretail;
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
@@ -249,7 +261,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
if (!empty($sql)) {
$sql .= " UNION ALL";
}
- $sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens";
+ $sql .= " SELECT t.rowid as id, t.entity, t.ref, 1 as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_vat,";
+ $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
+ $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'VariousPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, sens";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t";
$sql .= " WHERE datep between ".$wheretail;
$sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
@@ -260,7 +274,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
if (!empty($sql)) {
$sql .= " UNION ALL";
}
- $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat, '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
+ $sql .= " SELECT t.rowid as id, l.entity, l.label as ref, 1 as paid, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ht, (t.amount_capital+t.amount_insurance+t.amount_interest) as total_ttc, 0 as total_vat,";
+ $sql .= " 0 as localtax1, 0 as localtax2, 0 as revenuestamp,";
+ $sql .= " '".$db->escape($conf->currency)."' as currency, 0 as fk_soc, t.datep as date, t.datep as date_due, 'LoanPayment' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum, ".PAY_DEBIT." as sens";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_loan as t LEFT JOIN ".MAIN_DB_PREFIX."loan as l ON l.rowid = t.fk_loan";
$sql .= " WHERE datep between ".$wheretail;
$sql .= " AND l.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')';
@@ -368,6 +384,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
$nofile['amount_ht'] = $objd->total_ht;
$nofile['amount_ttc'] = $objd->total_ttc;
$nofile['amount_vat'] = $objd->total_vat;
+ $nofile['amount_localtax1'] = $objd->localtax1;
+ $nofile['amount_localtax2'] = $objd->localtax2;
+ $nofile['amount_revenuestamp'] = $objd->revenuestamp;
$nofile['ref'] = ($objd->ref ? $objd->ref : $objd->id);
$nofile['fk'] = $objd->fk_soc;
$nofile['item'] = $objd->item;
@@ -391,6 +410,9 @@ if (($action == 'searchfiles' || $action == 'dl')) {
$file['amount_ht'] = $objd->total_ht;
$file['amount_ttc'] = $objd->total_ttc;
$file['amount_vat'] = $objd->total_vat;
+ $file['amount_localtax1'] = $objd->localtax1;
+ $file['amount_localtax2'] = $objd->localtax2;
+ $file['amount_revenuestamp'] = $objd->revenuestamp;
$file['ref'] = ($objd->ref ? $objd->ref : $objd->id);
$file['fk'] = $objd->fk_soc;
$file['item'] = $objd->item;
@@ -469,6 +491,9 @@ if ($result && $action == "dl" && !$error) {
$log .= ','.$langs->transnoentitiesnoconv("TotalHT");
$log .= ','.$langs->transnoentitiesnoconv("TotalTTC");
$log .= ','.$langs->transnoentitiesnoconv("TotalVAT");
+ $log .= ','.$langs->transcountrynoentities("TotalLT1", $mysoc->country_code);
+ $log .= ','.$langs->transcountrynoentities("TotalLT2", $mysoc->country_code);
+ $log .= ','.$langs->transnoentitiesnoconv("Revenuestamp");
$log .= ','.$langs->transnoentitiesnoconv("Paid");
$log .= ','.$langs->transnoentitiesnoconv("Document");
$log .= ','.$langs->transnoentitiesnoconv("ItemID");
@@ -511,6 +536,9 @@ if ($result && $action == "dl" && !$error) {
$log .= ','.$file['amount_ht'];
$log .= ','.$file['amount_ttc'];
$log .= ','.$file['amount_vat'];
+ $log .= ','.$file['amount_localtax1'];
+ $log .= ','.$file['amount_localtax2'];
+ $log .= ','.$file['amount_revenuestamp'];
$log .= ','.$file['paid'];
$log .= ',"'.$file["name"].'"';
$log .= ','.$file['fk'];
@@ -698,9 +726,10 @@ if (!empty($date_start) && !empty($date_stop)) {
print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall ');
print '