Prevent entering payment for recurring invoice through the API

This commit is contained in:
Hillel Coren 2016-08-28 20:52:25 +03:00
parent 4ce11fd9f6
commit fd5fa8f557
2 changed files with 17 additions and 8 deletions

View File

@ -161,6 +161,7 @@ class InvoiceApiController extends BaseAPIController
$invoice = $this->invoiceService->save($data);
$payment = false;
if ($invoice->isInvoice()) {
if (isset($data['auto_bill']) && boolval($data['auto_bill'])) {
$payment = $this->paymentService->autoBillInvoice($invoice);
} else if (isset($data['paid']) && $data['paid']) {
@ -170,6 +171,7 @@ class InvoiceApiController extends BaseAPIController
'amount' => $data['paid']
]);
}
}
if (isset($data['email_invoice']) && $data['email_invoice']) {
if ($payment) {

View File

@ -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
*/