mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 07:54:36 -04:00
working on credit payments
This commit is contained in:
parent
901f7c4117
commit
27f678bd8c
@ -524,7 +524,7 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->company->use_credit_payment = 'optin' && $this->service()->getCreditBalance() > 0) {
|
if($this->company->use_credits_payment == 'option' && $this->service()->getCreditBalance() > 0) {
|
||||||
$payment_urls[] = [
|
$payment_urls[] = [
|
||||||
'label' => ctrans('texts.apply_credit'),
|
'label' => ctrans('texts.apply_credit'),
|
||||||
'company_gateway_id' => CompanyGateway::GATEWAY_CREDIT,
|
'company_gateway_id' => CompanyGateway::GATEWAY_CREDIT,
|
||||||
|
@ -47,6 +47,7 @@ class ApplyPayment
|
|||||||
//$available_credit_balance = $this->credit->balance;
|
//$available_credit_balance = $this->credit->balance;
|
||||||
$applicable_amount = min($this->amount, $this->credit->balance);
|
$applicable_amount = min($this->amount, $this->credit->balance);
|
||||||
$invoice_balance = $this->invoice->balance;
|
$invoice_balance = $this->invoice->balance;
|
||||||
|
$credit_balance = $this->credit->balance;
|
||||||
|
|
||||||
/* Check invoice partial for amount to be cleared first */
|
/* Check invoice partial for amount to be cleared first */
|
||||||
if($this->invoice->partial > 0){
|
if($this->invoice->partial > 0){
|
||||||
@ -56,7 +57,7 @@ class ApplyPayment
|
|||||||
$this->invoice->partial -= $partial_payment;
|
$this->invoice->partial -= $partial_payment;
|
||||||
$invoice_balance -= $partial_payment;
|
$invoice_balance -= $partial_payment;
|
||||||
$this->amount -= $partial_payment;
|
$this->amount -= $partial_payment;
|
||||||
// $this->credit->balance -= $partial_payment;
|
$credit_balance -= $partial_payment;
|
||||||
$applicable_amount -= $partial_payment;
|
$applicable_amount -= $partial_payment;
|
||||||
$this->amount_applied += $partial_payment;
|
$this->amount_applied += $partial_payment;
|
||||||
|
|
||||||
@ -65,11 +66,10 @@ class ApplyPayment
|
|||||||
/* If there is remaining amount use it on the balance */
|
/* If there is remaining amount use it on the balance */
|
||||||
if($this->amount > 0 && $applicable_amount > 0 && $invoice_balance > 0){
|
if($this->amount > 0 && $applicable_amount > 0 && $invoice_balance > 0){
|
||||||
|
|
||||||
$balance_payment = min($invoice_balance, $this->amount);
|
$balance_payment = min($invoice_balance, min($this->amount, $credit_balance));
|
||||||
|
|
||||||
$invoice_balance -= $balance_payment;
|
$invoice_balance -= $balance_payment;
|
||||||
$this->amount -= $balance_payment;
|
$this->amount -= $balance_payment;
|
||||||
// $this->credit->balance -= $balance_payment;
|
|
||||||
$this->amount_applied += $balance_payment;
|
$this->amount_applied += $balance_payment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ class AutoBillInvoice extends AbstractService
|
|||||||
|
|
||||||
//if the credits cover the payments, we stop here, build the payment with credits and exit early
|
//if the credits cover the payments, we stop here, build the payment with credits and exit early
|
||||||
|
|
||||||
if($this->invoice->company->use_credits_payment == 'always' || $this->invoice->company->use_credits_payment == 'optin')
|
if($this->invoice->company->use_credits_payment == 'always' || $this->invoice->company->use_credits_payment == 'option')
|
||||||
$this->applyCreditPayment();
|
$this->applyCreditPayment();
|
||||||
|
|
||||||
info("partial = {$this->invoice->partial}");
|
info("partial = {$this->invoice->partial}");
|
||||||
|
@ -24,7 +24,7 @@ class ProjectIdsToEntities extends Migration
|
|||||||
Schema::table('companies', function (Blueprint $table) {
|
Schema::table('companies', function (Blueprint $table) {
|
||||||
$table->boolean('mark_expenses_invoiceable')->default(0);
|
$table->boolean('mark_expenses_invoiceable')->default(0);
|
||||||
$table->boolean('mark_expenses_paid')->default(0);
|
$table->boolean('mark_expenses_paid')->default(0);
|
||||||
$table->enum('use_credits_payment', ['always', 'off', 'optin'])->nullable();
|
$table->enum('use_credits_payment', ['always', 'off', 'option'])->default('off');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user