1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Support taxing the fee

This commit is contained in:
Hillel Coren 2017-03-16 19:18:14 +02:00
parent daec25fe79
commit 0c3db5a8e4
3 changed files with 16 additions and 3 deletions

View File

@ -1190,10 +1190,12 @@ class AccountController extends BaseController
$account->auto_bill_on_due_date = boolval(Input::get('auto_bill_on_due_date'));
$account->gateway_fee_location = Input::get('gateway_fee_location') ?: null;
/*
if ($account->gateway_fee_location) {
$taxField = $account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? 'custom_invoice_taxes1' : 'custom_invoice_taxes1';
$account->$taxField = false;
}
*/
$account->save();

View File

@ -26,7 +26,18 @@ trait ChargesFees
}
if ($settings->fee_percent) {
$fee += $this->amount * $settings->fee_percent / 100;
// prevent charging taxes twice on the surcharge
$amount = $this->getRequestedAmount();
$taxField = $account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? 'custom_invoice_taxes1' : 'custom_invoice_taxes1';
if ($account->$taxField) {
$taxAmount = 0;
foreach ($this->getTaxes() as $key => $tax) {
$taxAmount += $tax['amount'] - $tax['paid'];
}
$amount -= $taxAmount;
}
$fee += $amount * $settings->fee_percent / 100;
}
if ($account->gateway_fee_location == FEE_LOCATION_ITEM && $includeTax) {

View File

@ -238,7 +238,7 @@
->label(trans('texts.field_label'))
->placeholder($account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? trans('texts.surcharge') : ' ')
->addGroupClass('pad-checkbox')
->append($account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? false :
->append($account->gateway_fee_location == FEE_LOCATION_CHARGE1 && false ? false :
Former::checkbox('custom_invoice_taxes1')
->value(1)
->raw() . trans('texts.charge_taxes')) !!}
@ -247,7 +247,7 @@
->label(trans('texts.field_label'))
->placeholder($account->gateway_fee_location == FEE_LOCATION_CHARGE2 ? trans('texts.surcharge') : ' ')
->addGroupClass('pad-checkbox')
->append($account->gateway_fee_location == FEE_LOCATION_CHARGE2 ? false :
->append($account->gateway_fee_location == FEE_LOCATION_CHARGE2 && false ? false :
Former::checkbox('custom_invoice_taxes2')
->value(1)
->raw() . trans('texts.charge_taxes'))