mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
Check invoice is set to is_public in the API
This commit is contained in:
parent
0275ab92ab
commit
3d507fad68
@ -158,13 +158,23 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
|
|
||||||
$data = self::prepareData($data, $client);
|
$data = self::prepareData($data, $client);
|
||||||
$data['client_id'] = $client->id;
|
$data['client_id'] = $client->id;
|
||||||
|
|
||||||
|
// in these cases the invoice needs to be set as public
|
||||||
|
$isAutoBill = isset($data['auto_bill']) && filter_var($data['auto_bill'], FILTER_VALIDATE_BOOLEAN);
|
||||||
|
$isEmailInvoice = isset($data['email_invoice']) && filter_var($data['email_invoice'], FILTER_VALIDATE_BOOLEAN);
|
||||||
|
$isPaid = isset($data['paid']) && floatval($data['paid']);
|
||||||
|
|
||||||
|
if ($isAutoBill || $isPaid || $isEmailInvoice) {
|
||||||
|
$data['is_public'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
$invoice = $this->invoiceService->save($data);
|
$invoice = $this->invoiceService->save($data);
|
||||||
$payment = false;
|
$payment = false;
|
||||||
|
|
||||||
if ($invoice->isInvoice()) {
|
if ($invoice->isInvoice()) {
|
||||||
if (isset($data['auto_bill']) && boolval($data['auto_bill'])) {
|
if ($isAutoBill) {
|
||||||
$payment = $this->paymentService->autoBillInvoice($invoice);
|
$payment = $this->paymentService->autoBillInvoice($invoice);
|
||||||
} else if (isset($data['paid']) && $data['paid']) {
|
} else if ($isPaid) {
|
||||||
$payment = $this->paymentRepo->save([
|
$payment = $this->paymentRepo->save([
|
||||||
'invoice_id' => $invoice->id,
|
'invoice_id' => $invoice->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
@ -173,7 +183,7 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($data['email_invoice']) && $data['email_invoice']) {
|
if ($isEmailInvoice) {
|
||||||
if ($payment) {
|
if ($payment) {
|
||||||
$this->mailer->sendPaymentConfirmation($payment);
|
$this->mailer->sendPaymentConfirmation($payment);
|
||||||
} elseif ( ! $invoice->is_recurring) {
|
} elseif ( ! $invoice->is_recurring) {
|
||||||
|
Loading…
Reference in New Issue
Block a user