mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on gateway fees
This commit is contained in:
parent
54275853fd
commit
0ddd4479b7
@ -394,8 +394,8 @@ if (! defined('APP_NAME')) {
|
|||||||
define('GATEWAY_TYPE_CUSTOM', 6);
|
define('GATEWAY_TYPE_CUSTOM', 6);
|
||||||
define('GATEWAY_TYPE_TOKEN', 'token');
|
define('GATEWAY_TYPE_TOKEN', 'token');
|
||||||
|
|
||||||
define('FEE_LOCATION_CHARGE1', 'invoice_charge1');
|
define('FEE_LOCATION_CHARGE1', 'custom_value1');
|
||||||
define('FEE_LOCATION_CHARGE2', 'invoice_charge2');
|
define('FEE_LOCATION_CHARGE2', 'custom_value2');
|
||||||
define('FEE_LOCATION_ITEM', 'invoice_item');
|
define('FEE_LOCATION_ITEM', 'invoice_item');
|
||||||
|
|
||||||
define('REMINDER1', 'reminder1');
|
define('REMINDER1', 'reminder1');
|
||||||
|
@ -1189,6 +1189,12 @@ class AccountController extends BaseController
|
|||||||
$account->token_billing_type_id = Input::get('token_billing_type_id');
|
$account->token_billing_type_id = Input::get('token_billing_type_id');
|
||||||
$account->auto_bill_on_due_date = boolval(Input::get('auto_bill_on_due_date'));
|
$account->auto_bill_on_due_date = boolval(Input::get('auto_bill_on_due_date'));
|
||||||
$account->gateway_fee_location = Input::get('gateway_fee_location') ?: null;
|
$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();
|
$account->save();
|
||||||
|
|
||||||
event(new UserSettingsChanged());
|
event(new UserSettingsChanged());
|
||||||
|
@ -287,8 +287,6 @@ class InvoicePresenter extends EntityPresenter
|
|||||||
if (floatval($settings->fee_amount) < 0 || floatval($settings->fee_percent) < 0) {
|
if (floatval($settings->fee_amount) < 0 || floatval($settings->fee_percent) < 0) {
|
||||||
$label = trans('texts.discount');
|
$label = trans('texts.discount');
|
||||||
} else {
|
} else {
|
||||||
//$field = $account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? 'custom_invoice_label1' : 'custom_invoice_label2';
|
|
||||||
//$label = $account->$field;
|
|
||||||
$label = trans('texts.fee');
|
$label = trans('texts.fee');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1025,22 +1025,16 @@ class InvoiceRepository extends BaseRepository
|
|||||||
if ($location == FEE_LOCATION_ITEM) {
|
if ($location == FEE_LOCATION_ITEM) {
|
||||||
// todo
|
// todo
|
||||||
} else {
|
} else {
|
||||||
if ($location == FEE_LOCATION_CHARGE1) {
|
|
||||||
$field = 'custom_value1';
|
|
||||||
} elseif ($location == FEE_LOCATION_CHARGE2) {
|
|
||||||
$field = 'custom_value2';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($invoice->$field > 0) {
|
if ($invoice->$field > 0) {
|
||||||
$data = $invoice->toArray();
|
$data = $invoice->toArray();
|
||||||
$data[$field] = 0;
|
$data[$location] = 0;
|
||||||
$invoice = $this->save($data, $invoice);
|
$invoice = $this->save($data, $invoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$fee = $invoice->calcGatewayFee($gatewayTypeId);
|
$fee = $invoice->calcGatewayFee($gatewayTypeId);
|
||||||
$data = $invoice->toArray();
|
$data = $invoice->toArray();
|
||||||
$data[$field] = $fee;
|
$data[$location] = $fee;
|
||||||
$this->save($data, $invoice);
|
$this->save($data, $invoice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,8 @@
|
|||||||
->label(trans('texts.field_label'))
|
->label(trans('texts.field_label'))
|
||||||
->placeholder($account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? trans('texts.surcharge') : ' ')
|
->placeholder($account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? trans('texts.surcharge') : ' ')
|
||||||
->addGroupClass('pad-checkbox')
|
->addGroupClass('pad-checkbox')
|
||||||
->append(Former::checkbox('custom_invoice_taxes1')
|
->append($account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? false :
|
||||||
|
Former::checkbox('custom_invoice_taxes1')
|
||||||
->value(1)
|
->value(1)
|
||||||
->raw() . trans('texts.charge_taxes')) !!}
|
->raw() . trans('texts.charge_taxes')) !!}
|
||||||
|
|
||||||
@ -246,7 +247,8 @@
|
|||||||
->label(trans('texts.field_label'))
|
->label(trans('texts.field_label'))
|
||||||
->placeholder($account->gateway_fee_location == FEE_LOCATION_CHARGE2 ? trans('texts.surcharge') : ' ')
|
->placeholder($account->gateway_fee_location == FEE_LOCATION_CHARGE2 ? trans('texts.surcharge') : ' ')
|
||||||
->addGroupClass('pad-checkbox')
|
->addGroupClass('pad-checkbox')
|
||||||
->append(Former::checkbox('custom_invoice_taxes2')
|
->append($account->gateway_fee_location == FEE_LOCATION_CHARGE2 ? false :
|
||||||
|
Former::checkbox('custom_invoice_taxes2')
|
||||||
->value(1)
|
->value(1)
|
||||||
->raw() . trans('texts.charge_taxes'))
|
->raw() . trans('texts.charge_taxes'))
|
||||||
->help(trans('texts.custom_invoice_charges_helps')) !!}
|
->help(trans('texts.custom_invoice_charges_helps')) !!}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user