mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Added default Valid Until setting (#2874)
Added field to settings and calculation of due date
This commit is contained in:
parent
1dada2035c
commit
8b4976cacf
@ -164,6 +164,7 @@ class Account extends Eloquent
|
||||
'custom_value2',
|
||||
'custom_messages',
|
||||
'custom_fields_options',
|
||||
'valid_until_days',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -399,6 +399,8 @@ class InvoiceRepository extends BaseRepository
|
||||
if ($entityType == ENTITY_INVOICE && empty($data['partial_due_date'])) {
|
||||
$client = Client::scope()->whereId($data['client_id'])->first();
|
||||
$invoice->due_date = $account->defaultDueDate($client);
|
||||
} elseif($entityType == ENTITY_QUOTE && empty($data['due_date']) && !empty($account->valid_until_days)) {
|
||||
$invoice->due_date = \Carbon::parse($data['invoice_date'])->addDays($account->valid_until_days);
|
||||
}
|
||||
} else {
|
||||
$invoice = Invoice::scope($publicId)->firstOrFail();
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddDefaultValidUntilSetting extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->integer('valid_until_days')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->dropColumn('valid_until_days');
|
||||
});
|
||||
}
|
||||
}
|
@ -3159,7 +3159,8 @@ $LANG = array(
|
||||
'design' => 'Design',
|
||||
'password_is_too_short' => 'Password is too short',
|
||||
'failed_to_find_record' => 'Failed to find record',
|
||||
|
||||
'valid_until_days' => 'Valid Until',
|
||||
'valid_until_days_help' => 'Automatically sets the <b>Valid Until</b> value on quotes to this many days in the future. Leave blank to disable.',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
{{ Former::populate($account) }}
|
||||
{{ Former::populateField('task_rate', floatval($account->task_rate) ? Utils::roundSignificant($account->task_rate) : '') }}
|
||||
{{ Former::populateField('valid_until_days', intval($account->valid_until_days) ? $account->valid_until_days : '') }}
|
||||
|
||||
@include('accounts.nav', ['selected' => ACCOUNT_COMPANY_DETAILS])
|
||||
|
||||
@ -107,6 +108,10 @@
|
||||
->help('task_rate_help')!!}
|
||||
@endif
|
||||
|
||||
{!! Former::text('valid_until_days')
|
||||
->label(trans('texts.valid_until_days'))
|
||||
->help(trans('texts.valid_until_days_help')) !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user