1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Working on supporting custom payment terms

This commit is contained in:
Hillel Coren 2017-02-26 12:53:06 +02:00
parent 122937f7d2
commit 3daeaaa7ee
7 changed files with 17 additions and 7 deletions

View File

@ -188,7 +188,6 @@ class ClientController extends BaseController
'data' => Input::old('data'),
'account' => Auth::user()->account,
'sizes' => Cache::get('sizes'),
'paymentTerms' => Cache::get('paymentTerms'),
'currencies' => Cache::get('currencies'),
'customLabel1' => Auth::user()->account->custom_client_label1,
'customLabel2' => Auth::user()->account->custom_client_label2,

View File

@ -303,7 +303,6 @@ class InvoiceController extends BaseController
'defaultTax' => $account->default_tax_rate,
'currencies' => Cache::get('currencies'),
'sizes' => Cache::get('sizes'),
'paymentTerms' => Cache::get('paymentTerms'),
'invoiceDesigns' => InvoiceDesign::getDesigns(),
'invoiceFonts' => Cache::get('fonts'),
'frequencies' => \App\Models\Frequency::selectOptions(),

View File

@ -112,8 +112,8 @@ class PaymentTermController extends BaseController
$paymentTerm = PaymentTerm::createNew();
}
$paymentTerm->name = trim(Input::get('name'));
$paymentTerm->num_days = Utils::parseInt(Input::get('num_days'));
$paymentTerm->name = 'Net ' . $paymentTerm->num_days;
$paymentTerm->save();
$message = $publicId ? trans('texts.updated_payment_term') : trans('texts.created_payment_term');

View File

@ -2,6 +2,7 @@
namespace App\Models;
use Cache;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
@ -9,7 +10,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
*/
class PaymentTerm extends EntityModel
{
//use SoftDeletes;
use SoftDeletes;
/**
* @var bool
@ -27,4 +28,15 @@ class PaymentTerm extends EntityModel
{
return ENTITY_PAYMENT_TERM;
}
public static function getSelectOptions()
{
$terms = Cache::get('paymentTerms');
foreach (PaymentTerm::scope()->get() as $term) {
$terms->push($term);
}
return $terms->sortBy('num_days');
}
}

View File

@ -96,7 +96,7 @@
{!! Former::select('payment_terms')
->addOption('','')
->fromQuery(Cache::get('paymentTerms'), 'name', 'num_days')
->fromQuery(\App\Models\PaymentTerm::getSelectOptions(), 'name', 'num_days')
->help(trans('texts.payment_terms_help') . ' | ' . link_to('/settings/payment_terms', trans('texts.customize_options'))) !!}
</div>

View File

@ -126,7 +126,7 @@
->placeholder($account->language ? trans('texts.lang_'.$account->language->name) : '')
->fromQuery($languages, 'name', 'id') !!}
{!! Former::select('payment_terms')->addOption('','')
->fromQuery($paymentTerms, 'name', 'num_days')
->fromQuery(\App\Models\PaymentTerm::getSelectOptions(), 'name', 'num_days')
->placeholder($account->present()->paymentTerms)
->help(trans('texts.payment_terms_help')) !!}
{!! Former::select('size_id')->addOption('','')

View File

@ -729,7 +729,7 @@
->data_bind('value: language_id')
->fromQuery($languages, 'name', 'id') !!}
{!! Former::select('client[payment_terms]')->addOption('','')->data_bind('value: payment_terms')
->fromQuery($paymentTerms, 'name', 'num_days')
->fromQuery(\App\Models\PaymentTerm::getSelectOptions(), 'name', 'num_days')
->label(trans('texts.payment_terms'))
->help(trans('texts.payment_terms_help')) !!}
{!! Former::select('client[size_id]')->addOption('','')->data_bind('value: size_id')