Fix f... option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS (do not use this!)

This commit is contained in:
Laurent Destailleur 2022-10-12 12:14:04 +02:00
parent 77898ab456
commit 020d3dcbe5
13 changed files with 138 additions and 39 deletions

View File

@ -201,6 +201,9 @@ if ($object->nature == 2 || $object->nature == 3) {
} else {
$description .= $langs->trans("DepositsAreIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
}
$listofchoices = array('notyet' => $langs->trans("NotYetInGeneralLedger"), 'already' => $langs->trans("AlreadyInGeneralLedger"));

View File

@ -97,10 +97,19 @@ class FactureStats extends Stats
if ($this->userid > 0) {
$this->where .= ' AND f.fk_user_author = '.((int) $this->userid);
}
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$this->where .= " AND f.type IN (0,1,2,5)";
} else {
$this->where .= " AND f.type IN (0,1,2,3,5)";
if ($mode == 'customer') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$this->where .= " AND f.type IN (0,1,2,5)";
} else {
$this->where .= " AND f.type IN (0,1,2,3,5)";
}
}
if ($mode == 'supplier') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$this->where .= " AND f.type IN (0,1,2,5)";
} else {
$this->where .= " AND f.type IN (0,1,2,3,5)";
}
}
if ($typentid) {

View File

@ -253,7 +253,7 @@ if ($object->id > 0) {
$resteapayeraffiche = $resteapayer;
if ($type == 'bank-transfer') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { // Not recommended
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {
@ -266,7 +266,7 @@ if ($object->id > 0) {
$absolute_discount = price2num($absolute_discount, 'MT');
$absolute_creditnote = price2num($absolute_creditnote, 'MT');
} else {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Not recommended
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
} else {

View File

@ -193,6 +193,9 @@ if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='<br>'.$lan
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description.='<br>'.$langs->trans("DepositsAreNotIncluded");
}
if (! empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description.='<br>'.$langs->trans("SupplierDepositsAreNotIncluded");
}
*/
if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
$description .= $langs->trans("ThisIsAnEstimatedValue");

View File

@ -188,6 +188,9 @@ if ($modecompta == "CREANCES-DETTES") {
} else {
$description .= $langs->trans("DepositsAreIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
} elseif ($modecompta == "RECETTES-DEPENSES") {
@ -636,7 +639,7 @@ if ($modecompta == 'BOOKKEEPING') {
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.fk_statut IN (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2)";
} else {
$sql .= " AND f.type IN (0,1,2,3)";
@ -1340,7 +1343,7 @@ if ($modecompta == 'BOOKKEEPING') {
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_statut IN (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2)";
} else {
$sql .= " AND f.type IN (0,1,2,3)";

View File

@ -164,6 +164,9 @@ if ($modecompta == 'CREANCES-DETTES') {
} else {
$description .= "<br>".$langs->trans("DepositsAreIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
} elseif ($modecompta == "RECETTES-DEPENSES") {
@ -329,7 +332,7 @@ if (isModEnabled('facture') && ($modecompta == 'CREANCES-DETTES' || $modecompta
$sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_statut IN (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2)";
} else {
$sql .= " AND f.type IN (0,1,2,3)";
@ -437,7 +440,7 @@ if (isModEnabled('tax') && ($modecompta == 'CREANCES-DETTES' || $modecompta == "
$sql = "SELECT sum(f.total_tva) as amount, date_format(f.datef,'%Y-%m') as dm";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_statut IN (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2)";
} else {
$sql .= " AND f.type IN (0,1,2,3)";

View File

@ -204,6 +204,9 @@ if ($modecompta == "CREANCES-DETTES") {
} else {
$description .= $langs->trans("DepositsAreIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
} elseif ($modecompta == "RECETTES-DEPENSES") {
@ -230,8 +233,6 @@ if ($modecompta == "CREANCES-DETTES") {
$exportlink = '';
$description = $langs->trans("RulesResultBookkeepingPersonalized");
$description .= ' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/categories_list.php?search_country_id='.$mysoc->country_id.'&mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("AccountingCategory")).')';
//if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
//else $description.= $langs->trans("DepositsAreIncluded");
$builddate = dol_now();
}

View File

@ -224,7 +224,9 @@ if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
// Customers invoices
$elementcust = $langs->trans("CustomersInvoices");
$productcust = $langs->trans("ProductOrService");
@ -255,6 +257,9 @@ if ($modecompta == "CREANCES-DETTES") {
} else {
$description .= $langs->trans("DepositsAreIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
$builddate = dol_now();
} elseif ($modecompta == "RECETTES-DEPENSES") {
@ -405,7 +410,7 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql2 .= " WHERE ff.datef >= '".$db->idate($date_start)."'";
$sql2 .= " AND ff.datef <= '".$db->idate($date_end)."'";
$sql .= " AND ff.fk_statut in (1,2)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND ff.type IN (0,1,2,5)";
} else {
$sql .= " AND ff.type IN (0,1,2,3,5)";

View File

@ -246,7 +246,6 @@ if ($modecompta == "CREANCES-DETTES") {
} else {
$description .= $langs->trans("DepositsAreIncluded");
}
$builddate = dol_now();
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("TurnoverCollected").', '.$langs->trans("ByProductsAndServices");

View File

@ -153,6 +153,9 @@ if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
$description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue");
}

View File

@ -211,6 +211,9 @@ if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
$description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue");
}

View File

@ -163,6 +163,9 @@ if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= '<br>'.$langs->trans("DepositsAreNotIncluded");
}
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$description .= $langs->trans("SupplierDepositsAreNotIncluded");
}
if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) {
$description .= '<br>'.$langs->trans("ThisIsAnEstimatedValue");
}

View File

@ -174,10 +174,18 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity IN (".getEntity($invoicetable).")";
$sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
if ($direction == 'buy') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
}
$sql .= " AND f.rowid = d.".$fk_facture;
$sql .= " AND s.rowid = f.fk_soc";
@ -222,10 +230,18 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity IN (".getEntity($invoicetable).")";
$sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
if ($direction == 'buy') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
}
$sql .= " AND f.rowid = d.".$fk_facture;
$sql .= " AND s.rowid = f.fk_soc";
@ -359,10 +375,18 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity IN (".getEntity($invoicetable).")";
$sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
if ($direction == 'buy') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
}
$sql .= " AND f.rowid = d.".$fk_facture;
$sql .= " AND s.rowid = f.fk_soc";
@ -407,10 +431,18 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity IN (".getEntity($invoicetable).")";
$sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
if ($direction == 'buy') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
}
$sql .= " AND f.rowid = d.".$fk_facture;
$sql .= " AND s.rowid = f.fk_soc";
@ -730,10 +762,18 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity IN (".getEntity($invoicetable).")";
$sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
if ($direction == 'buy') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
}
if ($y && $m) {
$sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
@ -776,10 +816,18 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity IN (".getEntity($invoicetable).")";
$sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
if ($direction == 'buy') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
}
if ($y && $m) {
$sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
@ -915,10 +963,18 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity IN (".getEntity($invoicetable).")";
$sql .= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
if ($direction == 'buy') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
}
if ($y && $m) {
$sql .= " AND f.datef >= '".$db->idate(dol_get_first_day($y, $m, false))."'";
@ -961,10 +1017,18 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity IN (".getEntity($invoicetable).")";
$sql .= " AND f.fk_statut in (1,2)"; // Paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
if ($direction == 'buy') {
if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
}
if ($y && $m) {
$sql .= " AND pa.datep >= '".$db->idate(dol_get_first_day($y, $m, false))."'";