mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Working on gateway fees
This commit is contained in:
parent
293c4f2743
commit
5f23c89121
@ -575,6 +575,13 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return;
|
||||
}
|
||||
|
||||
$balanceAdjustment = floatval($balanceAdjustment);
|
||||
$partial = floatval($partial);
|
||||
|
||||
if (! $balanceAdjustment && $this->partial == $partial) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->balance = $this->balance + $balanceAdjustment;
|
||||
|
||||
if ($this->partial > 0) {
|
||||
@ -582,6 +589,13 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
}
|
||||
|
||||
$this->save();
|
||||
|
||||
// mark fees as paid
|
||||
if ($balanceAdjustment != 0 && $this->account->gateway_fee_location == FEE_LOCATION_ITEM) {
|
||||
if ($invoiceItem = $this->getGatewayFeeItem()) {
|
||||
$invoiceItem->markFeePaid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,4 +89,12 @@ class InvoiceItem extends EntityModel
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
public function markFeePaid()
|
||||
{
|
||||
if ($this->invoice_item_type_id == INVOICE_ITEM_TYPE_PENDING_GATEWAY_FEE) {
|
||||
$this->invoice_item_type_id = INVOICE_ITEM_TYPE_PAID_GATEWAY_FEE;
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user