mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Support creating/sending recurring invoices with the API
This commit is contained in:
parent
b561bfd594
commit
50a84f9ffb
@ -202,7 +202,10 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
if ($payment) {
|
if ($payment) {
|
||||||
app('App\Ninja\Mailers\ContactMailer')->sendPaymentConfirmation($payment);
|
app('App\Ninja\Mailers\ContactMailer')->sendPaymentConfirmation($payment);
|
||||||
//$this->dispatch(new SendPaymentEmail($payment));
|
//$this->dispatch(new SendPaymentEmail($payment));
|
||||||
} elseif (! $invoice->is_recurring) {
|
} else {
|
||||||
|
if ($invoice->is_recurring && $recurringInvoice = $this->invoiceRepo->createRecurringInvoice($invoice)) {
|
||||||
|
$invoice = $recurringInvoice;
|
||||||
|
}
|
||||||
app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice);
|
app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice);
|
||||||
//$this->dispatch(new SendInvoiceEmail($invoice));
|
//$this->dispatch(new SendInvoiceEmail($invoice));
|
||||||
}
|
}
|
||||||
@ -238,6 +241,10 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
'custom_value2' => 0,
|
'custom_value2' => 0,
|
||||||
'custom_taxes1' => false,
|
'custom_taxes1' => false,
|
||||||
'custom_taxes2' => false,
|
'custom_taxes2' => false,
|
||||||
|
'tax_name1' => '',
|
||||||
|
'tax_rate1' => 0,
|
||||||
|
'tax_name2' => '',
|
||||||
|
'tax_rate2' => 0,
|
||||||
'partial' => 0,
|
'partial' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -314,6 +321,10 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
{
|
{
|
||||||
$invoice = $request->entity();
|
$invoice = $request->entity();
|
||||||
|
|
||||||
|
if ($invoice->is_recurring && $recurringInvoice = $this->invoiceRepo->createRecurringInvoice($invoice)) {
|
||||||
|
$invoice = $recurringInvoice;
|
||||||
|
}
|
||||||
|
|
||||||
//$this->dispatch(new SendInvoiceEmail($invoice));
|
//$this->dispatch(new SendInvoiceEmail($invoice));
|
||||||
$result = app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice);
|
$result = app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice);
|
||||||
|
|
||||||
|
@ -17,10 +17,15 @@ class RecurringInvoiceDatatable extends EntityDatatable
|
|||||||
[
|
[
|
||||||
'frequency',
|
'frequency',
|
||||||
function ($model) {
|
function ($model) {
|
||||||
$frequency = strtolower($model->frequency);
|
if ($model->frequency) {
|
||||||
$frequency = preg_replace('/\s/', '_', $frequency);
|
$frequency = strtolower($model->frequency);
|
||||||
|
$frequency = preg_replace('/\s/', '_', $frequency);
|
||||||
|
$label = trans('texts.freq_' . $frequency);
|
||||||
|
} else {
|
||||||
|
$label = trans('texts.freq_inactive');
|
||||||
|
}
|
||||||
|
|
||||||
return link_to("recurring_invoices/{$model->public_id}/edit", trans('texts.freq_'.$frequency))->toHtml();
|
return link_to("recurring_invoices/{$model->public_id}/edit", $label)->toHtml();
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -144,7 +144,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
->join('accounts', 'accounts.id', '=', 'invoices.account_id')
|
->join('accounts', 'accounts.id', '=', 'invoices.account_id')
|
||||||
->join('clients', 'clients.id', '=', 'invoices.client_id')
|
->join('clients', 'clients.id', '=', 'invoices.client_id')
|
||||||
->join('invoice_statuses', 'invoice_statuses.id', '=', 'invoices.invoice_status_id')
|
->join('invoice_statuses', 'invoice_statuses.id', '=', 'invoices.invoice_status_id')
|
||||||
->join('frequencies', 'frequencies.id', '=', 'invoices.frequency_id')
|
->leftJoin('frequencies', 'frequencies.id', '=', 'invoices.frequency_id')
|
||||||
->join('contacts', 'contacts.client_id', '=', 'clients.id')
|
->join('contacts', 'contacts.client_id', '=', 'clients.id')
|
||||||
->where('invoices.account_id', '=', $accountId)
|
->where('invoices.account_id', '=', $accountId)
|
||||||
->where('invoices.invoice_type_id', '=', INVOICE_TYPE_STANDARD)
|
->where('invoices.invoice_type_id', '=', INVOICE_TYPE_STANDARD)
|
||||||
@ -430,7 +430,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
$invoice->last_sent_date = null;
|
$invoice->last_sent_date = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$invoice->frequency_id = array_get($data, 'frequency_id', 0);
|
$invoice->frequency_id = array_get($data, 'frequency_id', FREQUENCY_MONTHLY);
|
||||||
$invoice->start_date = Utils::toSqlDate(array_get($data, 'start_date'));
|
$invoice->start_date = Utils::toSqlDate(array_get($data, 'start_date'));
|
||||||
$invoice->end_date = Utils::toSqlDate(array_get($data, 'end_date'));
|
$invoice->end_date = Utils::toSqlDate(array_get($data, 'end_date'));
|
||||||
$invoice->client_enable_auto_bill = isset($data['client_enable_auto_bill']) && $data['client_enable_auto_bill'] ? true : false;
|
$invoice->client_enable_auto_bill = isset($data['client_enable_auto_bill']) && $data['client_enable_auto_bill'] ? true : false;
|
||||||
|
@ -1373,6 +1373,7 @@ $LANG = array(
|
|||||||
'start_of_week' => 'First Day of the Week',
|
'start_of_week' => 'First Day of the Week',
|
||||||
|
|
||||||
// Frequencies
|
// Frequencies
|
||||||
|
'freq_inactive' => 'Inactive',
|
||||||
'freq_weekly' => 'Weekly',
|
'freq_weekly' => 'Weekly',
|
||||||
'freq_two_weeks' => 'Two weeks',
|
'freq_two_weeks' => 'Two weeks',
|
||||||
'freq_four_weeks' => 'Four weeks',
|
'freq_four_weeks' => 'Four weeks',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user