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:
parent
7f038809fd
commit
0b978dcdf6
@ -90,7 +90,7 @@ class PaymentController extends BaseController
|
|||||||
{
|
{
|
||||||
$invoices = Invoice::scope()
|
$invoices = Invoice::scope()
|
||||||
->invoices()
|
->invoices()
|
||||||
->where('invoices.balance', '>', 0)
|
->where('invoices.balance', '!=', 0)
|
||||||
->with('client', 'invoice_status')
|
->with('client', 'invoice_status')
|
||||||
->orderBy('invoice_number')->get();
|
->orderBy('invoice_number')->get();
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class CreatePaymentAPIRequest extends PaymentRequest
|
|||||||
if (! $this->invoice_id || ! $this->amount) {
|
if (! $this->invoice_id || ! $this->amount) {
|
||||||
return [
|
return [
|
||||||
'invoice_id' => 'required|numeric|min:1',
|
'invoice_id' => 'required|numeric|min:1',
|
||||||
'amount' => 'required|numeric|min:0.01',
|
'amount' => 'required|numeric|not_in:0',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class CreatePaymentRequest extends PaymentRequest
|
|||||||
$rules = [
|
$rules = [
|
||||||
'client' => 'required', // TODO: change to client_id once views are updated
|
'client' => 'required', // TODO: change to client_id once views are updated
|
||||||
'invoice' => 'required', // TODO: change to invoice_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',
|
'payment_date' => 'required',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
public function updatePaidStatus($save = true)
|
public function updatePaidStatus($save = true)
|
||||||
{
|
{
|
||||||
$statusId = false;
|
$statusId = false;
|
||||||
if ($this->amount > 0 && $this->balance == 0) {
|
if ($this->amount != 0 && $this->balance == 0) {
|
||||||
$statusId = INVOICE_STATUS_PAID;
|
$statusId = INVOICE_STATUS_PAID;
|
||||||
} elseif ($this->balance > 0 && $this->balance < $this->amount) {
|
} elseif ($this->balance > 0 && $this->balance < $this->amount) {
|
||||||
$statusId = INVOICE_STATUS_PARTIAL;
|
$statusId = INVOICE_STATUS_PARTIAL;
|
||||||
@ -626,7 +626,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
|
|
||||||
public function canBePaid()
|
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)
|
public static function calcStatusLabel($status, $class, $entityType, $quoteInvoiceId)
|
||||||
|
@ -225,7 +225,7 @@ class InvoicePresenter extends EntityPresenter
|
|||||||
$actions[] = ['url' => url("quotes/{$invoice->quote_id}/edit"), 'label' => trans('texts.view_quote')];
|
$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:submitBulkAction("markPaid")', 'label' => trans('texts.mark_paid')];
|
||||||
$actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')];
|
$actions[] = ['url' => 'javascript:onPaymentClick()', 'label' => trans('texts.enter_payment')];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user