mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Set flags for recurring invoices and quote terms
This commit is contained in:
parent
d32184a3d7
commit
14b5770a0a
@ -30,7 +30,8 @@ class CloneQuoteToInvoiceFactory
|
||||
unset($quote_array['invitations']);
|
||||
|
||||
//preserve terms if they exist on Quotes
|
||||
if(array_key_exists('terms', $quote_array) && strlen($quote_array['terms']) < 2)
|
||||
//if(array_key_exists('terms', $quote_array) && strlen($quote_array['terms']) < 2)
|
||||
if(!$quote->company->use_quote_terms_on_conversion)
|
||||
unset($quote_array['terms']);
|
||||
|
||||
// unset($quote_array['public_notes']);
|
||||
@ -38,7 +39,6 @@ class CloneQuoteToInvoiceFactory
|
||||
unset($quote_array['design_id']);
|
||||
unset($quote_array['user']);
|
||||
|
||||
|
||||
foreach ($quote_array as $key => $value) {
|
||||
$invoice->{$key} = $value;
|
||||
}
|
||||
|
@ -67,11 +67,23 @@ class RecurringInvoicesCron
|
||||
|
||||
nlog("Trying to send {$recurring_invoice->number}");
|
||||
|
||||
/* Special check if we should generate another invoice is the previous one is yet to be paid */
|
||||
if($recurring_invoice->company->stop_on_unpaid_recurring && $recurring_invoice->invoices()->whereIn('status_id', [2,3])->where('is_deleted', 0)->where('balance', '>', 0)->exists()) {
|
||||
|
||||
nlog("Existing invoice exists, skipping");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
|
||||
|
||||
}
|
||||
catch(\Exception $e){
|
||||
|
||||
nlog("Unable to sending recurring invoice {$recurring_invoice->id} ". $e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@ -103,6 +115,13 @@ class RecurringInvoicesCron
|
||||
|
||||
nlog("Trying to send {$recurring_invoice->number}");
|
||||
|
||||
if($recurring_invoice->company->stop_on_unpaid_recurring) {
|
||||
|
||||
if($recurring_invoice->invoices()->whereIn('status_id', [2,3])->where('is_deleted', 0)->where('balance', '>', 0)->exists())
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try{
|
||||
SendRecurring::dispatchNow($recurring_invoice, $recurring_invoice->company->db);
|
||||
}
|
||||
|
@ -100,6 +100,8 @@ class Company extends BaseModel
|
||||
'client_registration_fields',
|
||||
'convert_rate_to_client',
|
||||
'markdown_email_enabled',
|
||||
'stop_on_unpaid_recurring',
|
||||
'use_quote_terms_on_conversion',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
@ -168,6 +168,7 @@ class CompanyTransformer extends EntityTransformer
|
||||
'client_registration_fields' => (array) $company->client_registration_fields,
|
||||
'convert_rate_to_client' => (bool) $company->convert_rate_to_client,
|
||||
'markdown_email_enabled' => (bool) $company->markdown_email_enabled,
|
||||
'stop_on_unpaid_recurring' => (bool) $company->stop_on_unpaid_recurring,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,11 @@ class AddAutoBillTriesToInvoicesTable extends Migration
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->smallInteger('auto_bill_tries')->default(0);
|
||||
});
|
||||
|
||||
Schema::table('companies', function (Blueprint $table) {
|
||||
$table->boolean('stop_on_unpaid_recurring')->default(0);
|
||||
$table->boolean('use_quote_terms_on_conversion')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -25,8 +30,6 @@ class AddAutoBillTriesToInvoicesTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('invoices', function (Blueprint $table) {
|
||||
$table->dropColumn('auto_bill_tries');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user