FIX: The minimum amount filter does not work in the VAT report per customer

This commit is contained in:
Ferran Marcet 2019-03-22 09:28:50 +01:00
parent a39336c80d
commit f37c1b9287

View File

@ -372,19 +372,17 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$subtot_coll_total_ht = 0; $subtot_coll_total_ht = 0;
$subtot_coll_vat = 0; $subtot_coll_vat = 0;
if (is_array($x_both[$thirdparty_id]['coll']['detail'])) if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['coll']['totalht'] > $min)) {
{
if (is_array($x_both[$thirdparty_id]['coll']['detail'])) {
// VAT Rate // VAT Rate
print "<tr>"; print "<tr>";
print '<td class="tax_rate">'; print '<td class="tax_rate">';
if (is_numeric($thirdparty_id)) if (is_numeric($thirdparty_id)) {
{
$company_static->fetch($thirdparty_id); $company_static->fetch($thirdparty_id);
print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1); print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1);
} } else {
else
{
$tmpid = preg_replace('/userid_/', '', $thirdparty_id); $tmpid = preg_replace('/userid_/', '', $thirdparty_id);
$user_static->fetch($tmpid); $user_static->fetch($tmpid);
print $langs->trans("User") . ': ' . $user_static->getNomUrl(1); print $langs->trans("User") . ': ' . $user_static->getNomUrl(1);
@ -415,16 +413,18 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>'; print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
// Payment date // Payment date
if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>'; if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') {
else print '<td></td>'; print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
} else {
print '<td></td>';
}
// Rate // Rate
print '<td align="right">' . $fields['drate'] . '</td>'; print '<td align="right">' . $fields['drate'] . '</td>';
// Description // Description
print '<td align="left">'; print '<td align="left">';
if ($fields['pid']) if ($fields['pid']) {
{
$product_static->id = $fields['pid']; $product_static->id = $fields['pid'];
$product_static->ref = $fields['pref']; $product_static->ref = $fields['pref'];
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
@ -432,9 +432,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
if (dol_string_nohtmltag($fields['descr'])) { if (dol_string_nohtmltag($fields['descr'])) {
print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24); print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
} }
} } else {
else
{
if ($type) { if ($type) {
$text = img_object($langs->trans('Service'), 'service'); $text = img_object($langs->trans('Service'), 'service');
} else { } else {
@ -457,12 +455,10 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '</td>'; print '</td>';
// Total HT // Total HT
if ($modetax != 1) if ($modetax != 1) {
{
print '<td class="nowrap" align="right">'; print '<td class="nowrap" align="right">';
print price($fields['totalht']); print price($fields['totalht']);
if (price2num($fields['ftotal_ttc'])) if (price2num($fields['ftotal_ttc'])) {
{
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
//print ' ('.round($ratiolineinvoice*100,2).'%)'; //print ' ('.round($ratiolineinvoice*100,2).'%)';
@ -472,18 +468,15 @@ if (! is_array($x_coll) || ! is_array($x_paye))
// Payment // Payment
$ratiopaymentinvoice = 1; $ratiopaymentinvoice = 1;
if ($modetax != 1) if ($modetax != 1) {
{
print '<td class="nowrap" align="right">'; print '<td class="nowrap" align="right">';
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
if ($fields['payment_amount'] && $fields['ftotal_ttc']) if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
{
$payment_static->id = $fields['payment_id']; $payment_static->id = $fields['payment_id'];
print $payment_static->getNomUrl(2); print $payment_static->getNomUrl(2);
} }
if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice')
|| ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) {
{
print $langs->trans("NA"); print $langs->trans("NA");
} else { } else {
if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) {
@ -515,6 +508,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$subtot_coll_vat += $temp_vat; $subtot_coll_vat += $temp_vat;
$x_coll_sum += $temp_vat; $x_coll_sum += $temp_vat;
} }
} }
// Total customers for this vat rate // Total customers for this vat rate
print '<tr class="liste_total">'; print '<tr class="liste_total">';
@ -528,6 +522,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<td class="nowrap" align="right">' . price(price2num($subtot_coll_vat, 'MT')) . '</td>'; print '<td class="nowrap" align="right">' . price(price2num($subtot_coll_vat, 'MT')) . '</td>';
print '</tr>'; print '</tr>';
} }
}
if (count($x_coll) == 0) // Show a total ine if nothing shown if (count($x_coll) == 0) // Show a total ine if nothing shown
{ {
@ -567,17 +562,15 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$subtot_paye_total_ht = 0; $subtot_paye_total_ht = 0;
$subtot_paye_vat = 0; $subtot_paye_vat = 0;
if (is_array($x_both[$thirdparty_id]['paye']['detail'])) if ($min == 0 || ($min > 0 && $x_both[$thirdparty_id]['paye']['totalht'] > $min)) {
{
if (is_array($x_both[$thirdparty_id]['paye']['detail'])) {
print "<tr>"; print "<tr>";
print '<td class="tax_rate">'; print '<td class="tax_rate">';
if (is_numeric($thirdparty_id)) if (is_numeric($thirdparty_id)) {
{
$company_static->fetch($thirdparty_id); $company_static->fetch($thirdparty_id);
print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1); print $langs->trans("ThirdParty") . ': ' . $company_static->getNomUrl(1);
} } else {
else
{
$tmpid = preg_replace('/userid_/', '', $thirdparty_id); $tmpid = preg_replace('/userid_/', '', $thirdparty_id);
$user_static->fetch($tmpid); $user_static->fetch($tmpid);
print $langs->trans("User") . ': ' . $user_static->getNomUrl(1); print $langs->trans("User") . ': ' . $user_static->getNomUrl(1);
@ -608,16 +601,18 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>'; print '<td align="left">' . dol_print_date($fields['datef'], 'day') . '</td>';
// Payment date // Payment date
if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>'; if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') {
else print '<td></td>'; print '<td align="left">' . dol_print_date($fields['datep'], 'day') . '</td>';
} else {
print '<td></td>';
}
// Company name // Company name
print '<td align="left">' . $fields['company_link'] . '</td>'; print '<td align="left">' . $fields['company_link'] . '</td>';
// Description // Description
print '<td align="left">'; print '<td align="left">';
if ($fields['pid']) if ($fields['pid']) {
{
$product_static->id = $fields['pid']; $product_static->id = $fields['pid'];
$product_static->ref = $fields['pref']; $product_static->ref = $fields['pref'];
$product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered $product_static->type = $fields['dtype']; // We force with the type of line to have type how line is registered
@ -625,9 +620,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
if (dol_string_nohtmltag($fields['descr'])) { if (dol_string_nohtmltag($fields['descr'])) {
print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24); print ' - ' . dol_trunc(dol_string_nohtmltag($fields['descr']), 24);
} }
} } else {
else
{
if ($type) { if ($type) {
$text = img_object($langs->trans('Service'), 'service'); $text = img_object($langs->trans('Service'), 'service');
} else { } else {
@ -650,12 +643,10 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '</td>'; print '</td>';
// Total HT // Total HT
if ($modetax != 1) if ($modetax != 1) {
{
print '<td class="nowrap" align="right">'; print '<td class="nowrap" align="right">';
print price($fields['totalht']); print price($fields['totalht']);
if (price2num($fields['ftotal_ttc'])) if (price2num($fields['ftotal_ttc'])) {
{
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
$ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']); $ratiolineinvoice = ($fields['dtotal_ttc'] / $fields['ftotal_ttc']);
//print ' ('.round($ratiolineinvoice*100,2).'%)'; //print ' ('.round($ratiolineinvoice*100,2).'%)';
@ -665,22 +656,17 @@ if (! is_array($x_coll) || ! is_array($x_paye))
// Payment // Payment
$ratiopaymentinvoice = 1; $ratiopaymentinvoice = 1;
if ($modetax != 1) if ($modetax != 1) {
{
print '<td class="nowrap" align="right">'; print '<td class="nowrap" align="right">';
if ($fields['payment_amount'] && $fields['ftotal_ttc']) if ($fields['payment_amount'] && $fields['ftotal_ttc']) {
{
$paymentfourn_static->id = $fields['payment_id']; $paymentfourn_static->id = $fields['payment_id'];
print $paymentfourn_static->getNomUrl(2); print $paymentfourn_static->getNomUrl(2);
} }
if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')
|| ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) {
{
print $langs->trans("NA"); print $langs->trans("NA");
} } else {
else
{
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) {
$ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']); $ratiopaymentinvoice = ($fields['payment_amount'] / $fields['ftotal_ttc']);
} }
@ -723,6 +709,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
print '<td class="nowrap" align="right">' . price(price2num($subtot_paye_vat, 'MT')) . '</td>'; print '<td class="nowrap" align="right">' . price(price2num($subtot_paye_vat, 'MT')) . '</td>';
print '</tr>'; print '</tr>';
} }
}
if (count($x_paye) == 0) { // Show a total line if nothing shown if (count($x_paye) == 0) { // Show a total line if nothing shown
print '<tr class="liste_total">'; print '<tr class="liste_total">';