diff --git a/app/Models/Traits/ChargesFees.php b/app/Models/Traits/ChargesFees.php index ddd1f8f156fa..7f1e220b4bb4 100644 --- a/app/Models/Traits/ChargesFees.php +++ b/app/Models/Traits/ChargesFees.php @@ -28,8 +28,8 @@ trait ChargesFees if ($settings->fee_percent) { // prevent charging taxes twice on the surcharge $amount = $this->amount; - $taxField = $account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? 'custom_invoice_taxes1' : 'custom_invoice_taxes1'; - if ($account->$taxField) { + $taxField = $account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? 'custom_taxes1' : 'custom_taxes1'; + if ($this->$taxField) { $taxAmount = 0; foreach ($this->getTaxes() as $key => $tax) { $taxAmount += $tax['amount']; diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 853ec2b5d814..eda630df9d81 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -336,6 +336,8 @@ class InvoiceRepository extends BaseRepository } $invoice = $account->createInvoice($entityType, $data['client_id']); $invoice->invoice_date = date_create()->format('Y-m-d'); + $invoice->custom_taxes1 = $account->custom_invoice_taxes1 ?: false; + $invoice->custom_taxes2 = $account->custom_invoice_taxes2 ?: false; if (isset($data['has_tasks']) && filter_var($data['has_tasks'], FILTER_VALIDATE_BOOLEAN)) { $invoice->has_tasks = true; } @@ -512,15 +514,9 @@ class InvoiceRepository extends BaseRepository if (isset($data['custom_value1'])) { $invoice->custom_value1 = round($data['custom_value1'], 2); - if ($isNew) { - $invoice->custom_taxes1 = $account->custom_invoice_taxes1 ?: false; - } } if (isset($data['custom_value2'])) { $invoice->custom_value2 = round($data['custom_value2'], 2); - if ($isNew) { - $invoice->custom_taxes2 = $account->custom_invoice_taxes2 ?: false; - } } if (isset($data['custom_text_value1'])) {