1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Working on gateway fees

This commit is contained in:
Hillel Coren 2017-03-17 13:57:56 +02:00
parent 293c4f2743
commit 5f23c89121
2 changed files with 22 additions and 0 deletions

View File

@ -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();
}
}
}
/**

View File

@ -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();
}
}
}