mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-06 02: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);
|
$invoice = $this->invoiceService->save($data);
|
||||||
$payment = false;
|
$payment = false;
|
||||||
|
|
||||||
if (isset($data['auto_bill']) && boolval($data['auto_bill'])) {
|
if ($invoice->isInvoice()) {
|
||||||
$payment = $this->paymentService->autoBillInvoice($invoice);
|
if (isset($data['auto_bill']) && boolval($data['auto_bill'])) {
|
||||||
} else if (isset($data['paid']) && $data['paid']) {
|
$payment = $this->paymentService->autoBillInvoice($invoice);
|
||||||
$payment = $this->paymentRepo->save([
|
} else if (isset($data['paid']) && $data['paid']) {
|
||||||
'invoice_id' => $invoice->id,
|
$payment = $this->paymentRepo->save([
|
||||||
'client_id' => $client->id,
|
'invoice_id' => $invoice->id,
|
||||||
'amount' => $data['paid']
|
'client_id' => $client->id,
|
||||||
]);
|
'amount' => $data['paid']
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['email_invoice']) && $data['email_invoice']) {
|
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 $this->isType(INVOICE_TYPE_QUOTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isInvoice() {
|
||||||
|
return $this->isType(INVOICE_TYPE_STANDARD) && ! $this->is_recurring;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $notify
|
* @param bool $notify
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user