mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-06 03:14:36 -04:00
Prevent entering payment for recurring invoice through the API
This commit is contained in:
parent
4ce11fd9f6
commit
fd5fa8f557
@ -161,14 +161,16 @@ class InvoiceApiController extends BaseAPIController
|
||||
$invoice = $this->invoiceService->save($data);
|
||||
$payment = false;
|
||||
|
||||
if (isset($data['auto_bill']) && boolval($data['auto_bill'])) {
|
||||
$payment = $this->paymentService->autoBillInvoice($invoice);
|
||||
} else if (isset($data['paid']) && $data['paid']) {
|
||||
$payment = $this->paymentRepo->save([
|
||||
'invoice_id' => $invoice->id,
|
||||
'client_id' => $client->id,
|
||||
'amount' => $data['paid']
|
||||
]);
|
||||
if ($invoice->isInvoice()) {
|
||||
if (isset($data['auto_bill']) && boolval($data['auto_bill'])) {
|
||||
$payment = $this->paymentService->autoBillInvoice($invoice);
|
||||
} else if (isset($data['paid']) && $data['paid']) {
|
||||
$payment = $this->paymentRepo->save([
|
||||
'invoice_id' => $invoice->id,
|
||||
'client_id' => $client->id,
|
||||
'amount' => $data['paid']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['email_invoice']) && $data['email_invoice']) {
|
||||
|
@ -388,6 +388,13 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return $this->isType(INVOICE_TYPE_QUOTE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isInvoice() {
|
||||
return $this->isType(INVOICE_TYPE_STANDARD) && ! $this->is_recurring;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $notify
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user