Implement workflow options

This commit is contained in:
Hillel Coren 2018-03-13 22:05:57 +02:00
parent e7c61e9c0b
commit fb30fcd4ed
9 changed files with 60 additions and 8 deletions

View File

@ -115,7 +115,7 @@ class SendRecurringInvoices extends Command
try {
$invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice);
if ($invoice && ! $invoice->isPaid()) {
if ($invoice && ! $invoice->isPaid() && $account->auto_email_invoice) {
$this->info('Not billed - Sending Invoice');
$this->mailer->sendInvoice($invoice);
} elseif ($invoice) {

View File

@ -976,6 +976,8 @@ class AccountController extends BaseController
$account->invoice_footer = Input::get('invoice_footer');
$account->quote_terms = Input::get('quote_terms');
$account->auto_convert_quote = Input::get('auto_convert_quote');
$account->auto_archive_invoice = Input::get('auto_archive_invoice');
$account->auto_email_invoice = Input::get('auto_email_invoice');
$account->recurring_invoice_number_prefix = Input::get('recurring_invoice_number_prefix');
$account->client_number_prefix = trim(Input::get('client_number_prefix'));

View File

@ -90,6 +90,11 @@ class InvoiceListener
->first();
$activity->json_backup = $invoice->hidePrivateFields()->toJSON();
$activity->save();
if ($invoice->balance == 0 && $payment->account->auto_archive_invoice) {
$invoiceRepo = app('App\Ninja\Repositories\InvoiceRepository');
$invoiceRepo->archive($invoice);
}
}
/**

View File

@ -134,6 +134,8 @@ class Account extends Eloquent
'header_font_id',
'body_font_id',
'auto_convert_quote',
'auto_archive_invoice',
'auto_email_invoice',
'all_pages_footer',
'all_pages_header',
'show_currency_code',

View File

@ -237,6 +237,8 @@ class AccountTransformer extends EntityTransformer
'header_font_id' => (int) $account->header_font_id,
'body_font_id' => (int) $account->body_font_id,
'auto_convert_quote' => (bool) $account->auto_convert_quote,
'auto_archive_invoice' => (bool) $account->auto_archive_invoice,
'auto_email_invoice' => (bool) $account->auto_email_invoice,
'all_pages_footer' => (bool) $account->all_pages_footer,
'all_pages_header' => (bool) $account->all_pages_header,
'show_currency_code' => (bool) $account->show_currency_code,

View File

@ -15,11 +15,15 @@ class AddSlackNotifications extends Migration
{
Schema::table('users', function ($table) {
$table->string('slack_webhook_url')->nullable();
$table->string('accepted_terms_version')->nullable();
$table->timestamp('accepted_terms_timestamp')->nullable();
$table->string('accepted_terms_ip')->nullable();
});
Schema::table('accounts', function ($table) {
$table->boolean('auto_archive_invoice')->default(false)->nullable();
$table->boolean('auto_email_invoice')->default(true)->nullable();
});
}
/**
@ -31,10 +35,14 @@ class AddSlackNotifications extends Migration
{
Schema::table('users', function ($table) {
$table->dropColumn('slack_webhook_url');
$table->dropColumn('accepted_terms_version');
$table->dropColumn('accepted_terms_timestamp');
$table->dropColumn('accepted_terms_ip');
});
Schema::table('accounts', function ($table) {
$table->dropColumn('auto_archive_invoice');
$table->dropColumn('auto_email_invoice');
});
}
}

View File

@ -366,6 +366,7 @@ $LANG = array(
'confirm_email_invoice' => 'Are you sure you want to email this invoice?',
'confirm_email_quote' => 'Are you sure you want to email this quote?',
'confirm_recurring_email_invoice' => 'Are you sure you want this invoice emailed?',
'confirm_recurring_email_invoice_not_sent' => 'Are you sure you want to start the recurrence?',
'cancel_account' => 'Delete Account',
'cancel_account_message' => 'Warning: This will permanently delete your account, there is no undo.',
'go_back' => 'Go Back',
@ -614,6 +615,7 @@ $LANG = array(
'or' => 'or',
'email_error' => 'There was a problem sending the email',
'confirm_recurring_timing' => 'Note: emails are sent at the start of the hour.',
'confirm_recurring_timing_not_sent' => 'Note: invoices are created at the start of the hour.',
'payment_terms_help' => 'Sets the default <b>invoice due date</b>',
'unlink_account' => 'Unlink Account',
'unlink' => 'Unlink',
@ -978,7 +980,7 @@ $LANG = array(
'bank_account_error' => 'Failed to retreive account details, please check your credentials.',
'status_approved' => 'Approved',
'quote_settings' => 'Quote Settings',
'auto_convert_quote' => 'Auto convert quote',
'auto_convert_quote' => 'Auto Convert Quote',
'auto_convert_quote_help' => 'Automatically convert a quote to an invoice when approved by a client.',
'validate' => 'Validate',
'info' => 'Info',
@ -1327,6 +1329,7 @@ $LANG = array(
'debit_cards' => 'Debit Cards',
'warn_start_date_changed' => 'The next invoice will be sent on the new start date.',
'warn_start_date_changed_not_sent' => 'The next invoice will be created on the new start date.',
'original_start_date' => 'Original start date',
'new_start_date' => 'New start date',
'security' => 'Security',
@ -2773,6 +2776,11 @@ $LANG = array(
'accept' => 'Accept',
'accepted_terms' => 'Successfully accepted the latest terms of service',
'invalid_url' => 'Invalid URL',
'workflow_settings' => 'Workflow Settings',
'auto_email_invoice' => 'Auto Email Invoice',
'auto_email_invoice_help' => 'Automatically email recurring invoices when they are created.',
'auto_archive_invoice' => 'Auto Archive Invoice',
'auto_archive_invoice_help' => 'Automatically archive invoices once they are paid.',
);

View File

@ -23,6 +23,8 @@
{!! Former::open()->rules(['iframe_url' => 'url'])->addClass('warn-on-exit') !!}
{{ Former::populate($account) }}
{{ Former::populateField('auto_convert_quote', intval($account->auto_convert_quote)) }}
{{ Former::populateField('auto_archive_invoice', intval($account->auto_archive_invoice)) }}
{{ Former::populateField('auto_email_invoice', intval($account->auto_email_invoice)) }}
{{ Former::populateField('custom_invoice_taxes1', intval($account->custom_invoice_taxes1)) }}
{{ Former::populateField('custom_invoice_taxes2', intval($account->custom_invoice_taxes2)) }}
{{ Former::populateField('share_counter', intval($account->share_counter)) }}
@ -316,9 +318,19 @@
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.quote_settings') !!}</h3>
<h3 class="panel-title">{!! trans('texts.workflow_settings') !!}</h3>
</div>
<div class="panel-body form-padding-right">
{!! Former::checkbox('auto_email_invoice')
->text(trans('texts.enable'))
->blockHelp(trans('texts.auto_email_invoice_help'))
->value(1) !!}
{!! Former::checkbox('auto_archive_invoice')
->text(trans('texts.enable'))
->blockHelp(trans('texts.auto_archive_invoice_help'))
->value(1) !!}
{!! Former::checkbox('auto_convert_quote')
->text(trans('texts.enable'))
->blockHelp(trans('texts.auto_convert_quote_help'))

View File

@ -1340,13 +1340,22 @@
return false;
}
@if ($account->auto_email_invoice)
var title = "{!! trans("texts.confirm_recurring_email_invoice") !!}";
@else
var title = "{!! trans("texts.confirm_recurring_email_invoice_not_sent") !!}";
@endif
var text = '\n' + getSendToEmails();
var startDate = moment($('#start_date').datepicker('getDate'));
// warn invoice will be emailed when saving new recurring invoice
if (model.invoice().start_date() == "{{ Utils::fromSqlDate(date('Y-m-d')) }}") {
@if ($account->auto_email_invoice)
text += '\n\n' + "{!! trans("texts.confirm_recurring_timing") !!}";
@else
text += '\n\n' + "{!! trans("texts.confirm_recurring_timing_not_sent") !!}";
@endif
// check if the start date is in the future
} else if (startDate.isAfter(moment(), 'day')) {
var message = "{!! trans("texts.email_will_be_sent_on") !!}";
@ -1370,7 +1379,11 @@
if (model.invoice().start_date() != model.invoice().start_date_orig()) {
var text = "{!! trans("texts.original_start_date") !!}: " + model.invoice().start_date_orig() + '\n'
+ "{!! trans("texts.new_start_date") !!}: " + model.invoice().start_date();
@if ($account->auto_email_invoice)
var title = "{!! trans("texts.warn_start_date_changed") !!}";
@else
var title = "{!! trans("texts.warn_start_date_changed_not_sent") !!}";
@endif
sweetConfirm(function() {
submitAction('');
}, text, title);