Skip to content

Commit

Permalink
Fix tva_tx on deposit invoice (Dolibarr#28305)
Browse files Browse the repository at this point in the history
* Fix tva_tx on deposit invoice

* Update card.php

* Update card.php

Modifs according to Eldy's suggestions : 

introduce a hidden option
INVOICE_VAT_TO_USE_ON_CREDIT_NOTE_WHEN_GENERATED_FROM_REMAIN_TO_PAY, with possible values:

   - not defined, we keep vat to 0 (current code):
    - if value is string 'default', we do what you suggest, we use the default vat for company (in most cases it will be the higher vat rate in dictionary).
    - if value is a float, we use this float value.

* Update card.php
  • Loading branch information
vmaury authored Feb 23, 2024
1 parent 1b4fb86 commit ac1e8ac
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion htdocs/compta/facture/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,22 @@
$totaldeposits = $facture_source->getSumDepositsUsed();
$remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);

$object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 1, 0, 0, 0, 0, 0, '', '', 'TTC');
if (!empty($conf->global->INVOICE_VAT_TO_USE_ON_CREDIT_NOTE_WHEN_GENERATED_FROM_REMAIN_TO_PAY) && $conf->global->INVOICE_VAT_TO_USE_ON_CREDIT_NOTE_WHEN_GENERATED_FROM_REMAIN_TO_PAY == 'default') {
if ((empty($object->thirdparty) || !is_object($object->thirdparty) || get_class($object->thirdparty) != 'Societe')) {
$object->fetch_thirdparty();
}
if (!empty($object->thirdparty) && is_object($object->thirdparty) && get_class($object->thirdparty) == 'Societe') {
$tva_tx = get_default_tva($mysoc, $object->thirdparty);
} else {
$tva_tx = 0;
}
} elseif ((float) $conf->global->INVOICE_VAT_TO_USE_ON_CREDIT_NOTE_WHEN_GENERATED_FROM_REMAIN_TO_PAY > 0) {
$tva_tx = (float) $conf->global->INVOICE_VAT_TO_USE_ON_CREDIT_NOTE_WHEN_GENERATED_FROM_REMAIN_TO_PAY;
} else {
$tva_tx = 0;
}

$object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 1, $tva_tx, 0, 0, 0, 0, '', '', 'TTC');
}
}

Expand Down

0 comments on commit ac1e8ac

Please sign in to comment.