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,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']) {

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