mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
API changes for Zapier
This commit is contained in:
parent
725522ea21
commit
4281a1c3b0
@ -21,6 +21,7 @@ use App\Http\Requests\InvoiceRequest;
|
|||||||
use App\Http\Requests\CreateInvoiceAPIRequest;
|
use App\Http\Requests\CreateInvoiceAPIRequest;
|
||||||
use App\Http\Requests\UpdateInvoiceAPIRequest;
|
use App\Http\Requests\UpdateInvoiceAPIRequest;
|
||||||
use App\Services\InvoiceService;
|
use App\Services\InvoiceService;
|
||||||
|
use App\Services\PaymentService;
|
||||||
|
|
||||||
class InvoiceApiController extends BaseAPIController
|
class InvoiceApiController extends BaseAPIController
|
||||||
{
|
{
|
||||||
@ -28,7 +29,7 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
|
|
||||||
protected $entityType = ENTITY_INVOICE;
|
protected $entityType = ENTITY_INVOICE;
|
||||||
|
|
||||||
public function __construct(InvoiceService $invoiceService, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, PaymentRepository $paymentRepo, Mailer $mailer)
|
public function __construct(InvoiceService $invoiceService, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, PaymentRepository $paymentRepo, Mailer $mailer, PaymentService $paymentService)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
$this->paymentRepo = $paymentRepo;
|
$this->paymentRepo = $paymentRepo;
|
||||||
$this->invoiceService = $invoiceService;
|
$this->invoiceService = $invoiceService;
|
||||||
$this->mailer = $mailer;
|
$this->mailer = $mailer;
|
||||||
|
$this->paymentService = $paymentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,8 +165,9 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
$invoice = $this->invoiceService->save($data);
|
$invoice = $this->invoiceService->save($data);
|
||||||
$payment = false;
|
$payment = false;
|
||||||
|
|
||||||
// Optionally create payment with invoice
|
if (isset($data['auto_bill']) && boolval($data['auto_bill'])) {
|
||||||
if (isset($data['paid']) && $data['paid']) {
|
$payment = $this->paymentService->autoBillInvoice($invoice);
|
||||||
|
} else if (isset($data['paid']) && $data['paid']) {
|
||||||
$payment = $this->paymentRepo->save([
|
$payment = $this->paymentRepo->save([
|
||||||
'invoice_id' => $invoice->id,
|
'invoice_id' => $invoice->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user