mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-12 04:21:30 +01:00
Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -646,7 +646,7 @@ class AccountancyCategory // extends CommonObject
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
|
||||
//if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date';
|
||||
$sql .= " WHERE t.entity = ".$conf->entity;
|
||||
$sql .= " WHERE t.entity = ".((int) $conf->entity);
|
||||
if (is_array($cpt)) {
|
||||
$sql .= " AND t.numero_compte IN (".$this->db->sanitize($listofaccount, 1).")";
|
||||
} else {
|
||||
|
||||
@@ -128,8 +128,8 @@ if ($action == 'validatehistory') {
|
||||
|
||||
// Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind
|
||||
// Customer Invoice lines (must be same request than into page list.php for manual binding)
|
||||
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype, f.fk_facture_source,";
|
||||
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
|
||||
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype, f.situation_cycle_ref, f.fk_facture_source,";
|
||||
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.situation_percent, l.tva_tx as tva_tx_line, l.vat_src_code,";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,";
|
||||
@@ -312,6 +312,10 @@ print '<span class="opacitymedium">'.$langs->trans("DescVentilCustomer").'</span
|
||||
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("DescVentilMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
|
||||
print '</span><br>';
|
||||
|
||||
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
|
||||
print info_admin($langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices"));
|
||||
print "<br>";
|
||||
}
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
@@ -386,6 +390,11 @@ if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
// TODO When INVOICE_USE_SITUATION = 1, values here are wrong. There is no compensation on bad stored amounts
|
||||
//$situation_ratio = 1;
|
||||
//if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
|
||||
//}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
if ($row[0] == 'tobind') {
|
||||
@@ -519,6 +528,11 @@ if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
// TODO When INVOICE_USE_SITUATION = 1, values here are wrong. There is no compensation on bad stored amounts
|
||||
//$situation_ratio = 1;
|
||||
//if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
|
||||
//}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
if ($row[0] == 'tobind') {
|
||||
@@ -630,7 +644,6 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa
|
||||
print "</table>\n";
|
||||
print '</div>';
|
||||
|
||||
|
||||
if (isModEnabled('margin')) {
|
||||
print "<br>\n";
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
@@ -644,22 +657,41 @@ if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This pa
|
||||
print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
|
||||
}
|
||||
print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
|
||||
$sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
|
||||
if ($j > 12) {
|
||||
$j -= 12;
|
||||
}
|
||||
$sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j,
|
||||
" (".$db->ifsql("fd.total_ht < 0",
|
||||
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))",
|
||||
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").")",
|
||||
0).") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
|
||||
}
|
||||
$sql .= " SUM(".$db->ifsql("fd.total_ht < 0",
|
||||
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))",
|
||||
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").") as total";
|
||||
|
||||
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
|
||||
// With old situation invoice setup
|
||||
$sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
|
||||
if ($j > 12) {
|
||||
$j -= 12;
|
||||
}
|
||||
$sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j,
|
||||
" (".$db->ifsql("fd.total_ht < 0",
|
||||
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent !
|
||||
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").")",
|
||||
0).") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
|
||||
}
|
||||
$sql .= " SUM(".$db->ifsql("fd.total_ht < 0",
|
||||
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))", // TODO This is bugged, we must use the percent for the invoice and fd.situation_percent is cumulated percent !
|
||||
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").") as total";
|
||||
} else {
|
||||
$sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,";
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
|
||||
if ($j > 12) {
|
||||
$j -= 12;
|
||||
}
|
||||
$sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j,
|
||||
" (".$db->ifsql("fd.total_ht < 0",
|
||||
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty)))",
|
||||
" (fd.total_ht - (fd.buy_price_ht * fd.qty))").")",
|
||||
0).") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
|
||||
}
|
||||
$sql .= " SUM(".$db->ifsql("fd.total_ht < 0",
|
||||
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty)))",
|
||||
" (fd.total_ht - (fd.buy_price_ht * fd.qty))").") as total";
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
|
||||
$sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'";
|
||||
|
||||
@@ -189,8 +189,8 @@ print '<script type="text/javascript">
|
||||
/*
|
||||
* Customer Invoice lines
|
||||
*/
|
||||
$sql = "SELECT f.rowid as facid, f.ref as ref, f.type as ftype, f.datef, f.ref_client,";
|
||||
$sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc,";
|
||||
$sql = "SELECT f.rowid as facid, f.ref as ref, f.type as ftype, f.situation_cycle_ref, f.datef, f.ref_client,";
|
||||
$sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc, fd.situation_percent,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_client,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
$sql .= " spe.accountancy_code_customer as code_compta_client,";
|
||||
@@ -502,8 +502,33 @@ if ($result) {
|
||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
|
||||
print '</td>';
|
||||
|
||||
print '<td class="right nowraponall amount">'.price($objp->total_ht).'</td>';
|
||||
// Amount
|
||||
print '<td class="right nowraponall amount">';
|
||||
|
||||
// Create a compensation rate for old situation invoice feature.
|
||||
$situation_ratio = 1;
|
||||
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
|
||||
if ($objp->situation_cycle_ref) {
|
||||
// Avoid divide by 0
|
||||
if ($objp->situation_percent == 0) {
|
||||
$situation_ratio = 0;
|
||||
} else {
|
||||
$line = new FactureLigne($db);
|
||||
$line->fetch($objp->rowid);
|
||||
|
||||
// Situation invoices handling
|
||||
$prev_progress = $line->get_prev_progress($objp->facid);
|
||||
|
||||
$situation_ratio = ($objp->situation_percent - $prev_progress) / $objp->situation_percent;
|
||||
}
|
||||
}
|
||||
print price($objp->total_ht * $situation_ratio);
|
||||
} else {
|
||||
print price($objp->total_ht);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Vat rate
|
||||
print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
|
||||
|
||||
// Thirdparty
|
||||
|
||||
@@ -228,8 +228,8 @@ if (empty($chartaccountcode)) {
|
||||
}
|
||||
|
||||
// Customer Invoice lines
|
||||
$sql = "SELECT f.rowid as facid, f.ref, f.datef, f.type as ftype, f.fk_facture_source,";
|
||||
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
|
||||
$sql = "SELECT f.rowid as facid, f.ref, f.datef, f.type as ftype, f.situation_cycle_ref, f.fk_facture_source,";
|
||||
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.situation_percent, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
|
||||
$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,";
|
||||
@@ -655,8 +655,30 @@ if ($result) {
|
||||
print $form->textwithtooltip(dol_trunc($text, $trunclength), $facture_static_det->desc);
|
||||
print '</td>';
|
||||
|
||||
// Amount
|
||||
print '<td class="right nowraponall amount">';
|
||||
print price($objp->total_ht);
|
||||
|
||||
// Create a compensation rate for old situation invoice feature.
|
||||
$situation_ratio = 1;
|
||||
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
|
||||
if ($objp->situation_cycle_ref) {
|
||||
// Avoid divide by 0
|
||||
if ($objp->situation_percent == 0) {
|
||||
$situation_ratio = 0;
|
||||
} else {
|
||||
$line = new FactureLigne($db);
|
||||
$line->fetch($objp->rowid);
|
||||
|
||||
// Situation invoices handling
|
||||
$prev_progress = $line->get_prev_progress($objp->facid);
|
||||
|
||||
$situation_ratio = ($objp->situation_percent - $prev_progress) / $objp->situation_percent;
|
||||
}
|
||||
}
|
||||
print price($objp->total_ht * $situation_ratio);
|
||||
} else {
|
||||
print price($objp->total_ht);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Vat rate
|
||||
|
||||
@@ -83,12 +83,7 @@ $help_url = 'EN:Module_Double_Entry_Accounting#Setup';
|
||||
|
||||
llxHeader('', $langs->trans("AccountancyArea"), $help_url);
|
||||
|
||||
if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_SITUATION == 1) {
|
||||
print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
|
||||
|
||||
print '<span class="opacitymedium">'.$langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices")."</span>\n";
|
||||
print "<br>";
|
||||
} elseif (isModEnabled('accounting')) {
|
||||
if (isModEnabled('accounting')) {
|
||||
$step = 0;
|
||||
|
||||
$resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
|
||||
|
||||
@@ -106,7 +106,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))
|
||||
$date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
|
||||
}
|
||||
|
||||
$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,";
|
||||
$sql = "SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,";
|
||||
$sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
|
||||
$sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
|
||||
if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
|
||||
@@ -206,21 +206,23 @@ if ($result) {
|
||||
$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.')' : ''));
|
||||
}
|
||||
|
||||
if ($obj->type == Facture::TYPE_SITUATION) {
|
||||
// Avoid divide by 0
|
||||
if ($obj->situation_percent == 0) {
|
||||
$situation_ratio = 0;
|
||||
} else {
|
||||
$line = new FactureLigne($db);
|
||||
$line->fetch($obj->fdid);
|
||||
// Create a compensation rate.
|
||||
$situation_ratio = 1;
|
||||
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
|
||||
if ($obj->situation_cycle_ref) {
|
||||
// Avoid divide by 0
|
||||
if ($obj->situation_percent == 0) {
|
||||
$situation_ratio = 0;
|
||||
} else {
|
||||
$line = new FactureLigne($db);
|
||||
$line->fetch($obj->fdid);
|
||||
|
||||
// Situation invoices handling
|
||||
$prev_progress = $line->get_prev_progress($obj->rowid);
|
||||
// Situation invoices handling
|
||||
$prev_progress = $line->get_prev_progress($obj->rowid);
|
||||
|
||||
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
|
||||
$situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$situation_ratio = 1;
|
||||
}
|
||||
|
||||
// Invoice lines
|
||||
|
||||
Reference in New Issue
Block a user