1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Support negative payments

This commit is contained in:
Hillel Coren 2017-03-26 21:31:13 +03:00
parent 7f038809fd
commit 0b978dcdf6
5 changed files with 6 additions and 6 deletions

View File

@ -90,7 +90,7 @@ class PaymentController extends BaseController
{
$invoices = Invoice::scope()
->invoices()
->where('invoices.balance', '>', 0)
->where('invoices.balance', '!=', 0)
->with('client', 'invoice_status')
->orderBy('invoice_number')->get();

View File

@ -26,7 +26,7 @@ class CreatePaymentAPIRequest extends PaymentRequest
if (! $this->invoice_id || ! $this->amount) {
return [
'invoice_id' => 'required|numeric|min:1',
'amount' => 'required|numeric|min:0.01',
'amount' => 'required|numeric|not_in:0',
];
}

View File

@ -36,7 +36,7 @@ class CreatePaymentRequest extends PaymentRequest
$rules = [
'client' => 'required', // TODO: change to client_id once views are updated
'invoice' => 'required', // TODO: change to invoice_id once views are updated
'amount' => "required|numeric|min:0.01",
'amount' => 'required|numeric|not_in:0',
'payment_date' => 'required',
];

View File

@ -541,7 +541,7 @@ class Invoice extends EntityModel implements BalanceAffecting
public function updatePaidStatus($save = true)
{
$statusId = false;
if ($this->amount > 0 && $this->balance == 0) {
if ($this->amount != 0 && $this->balance == 0) {
$statusId = INVOICE_STATUS_PAID;
} elseif ($this->balance > 0 && $this->balance < $this->amount) {
$statusId = INVOICE_STATUS_PARTIAL;
@ -626,7 +626,7 @@ class Invoice extends EntityModel implements BalanceAffecting
public function canBePaid()
{
return floatval($this->balance) > 0 && ! $this->is_deleted && $this->isInvoice();
return floatval($this->balance) != 0 && ! $this->is_deleted && $this->isInvoice();
}
public static function calcStatusLabel($status, $class, $entityType, $quoteInvoiceId)

View File

@ -225,7 +225,7 @@ class InvoicePresenter extends EntityPresenter
$actions[] = ['url' => url("quotes/{$invoice->quote_id}/edit"), 'label' => trans('texts.view_quote')];
}
if (!$invoice->deleted_at && ! $invoice->is_recurring && $invoice->balance > 0) {
if (!$invoice->deleted_at && ! $invoice->is_recurring && $invoice->balance != 0) {
$actions[] = ['url' => 'javascript:submitBulkAction("markPaid")', 'label' => trans('texts.mark_paid')];
$actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')];
}