mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on supporting custom payment terms
This commit is contained in:
parent
e6eb84f49e
commit
122937f7d2
@ -542,7 +542,6 @@ class AccountController extends BaseController
|
|||||||
$data = [
|
$data = [
|
||||||
'account' => Auth::user()->account,
|
'account' => Auth::user()->account,
|
||||||
'title' => trans('texts.payment_terms'),
|
'title' => trans('texts.payment_terms'),
|
||||||
'taxRates' => PaymentTerm::scope()->get(['id', 'name', 'num_days']),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return View::make('accounts.payment_terms', $data);
|
return View::make('accounts.payment_terms', $data);
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use App\Models\PaymentTerm;
|
use App\Models\PaymentTerm;
|
||||||
use App\Services\PaymentTermService;
|
use App\Services\PaymentTermService;
|
||||||
|
use Auth;
|
||||||
use Input;
|
use Input;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Session;
|
use Session;
|
||||||
@ -43,7 +44,9 @@ class PaymentTermController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function getDatatable()
|
public function getDatatable()
|
||||||
{
|
{
|
||||||
return $this->paymentTermService->getDatatable();
|
$accountId = Auth::user()->account_id;
|
||||||
|
|
||||||
|
return $this->paymentTermService->getDatatable($accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,6 +266,14 @@ Route::group([
|
|||||||
Route::get('api/gateways', 'AccountGatewayController@getDatatable');
|
Route::get('api/gateways', 'AccountGatewayController@getDatatable');
|
||||||
Route::post('account_gateways/bulk', 'AccountGatewayController@bulk');
|
Route::post('account_gateways/bulk', 'AccountGatewayController@bulk');
|
||||||
|
|
||||||
|
Route::get('payment_terms', 'PaymentTermController@index');
|
||||||
|
Route::get('api/payment_terms', 'PaymentTermController@getDatatable');
|
||||||
|
Route::get('payment_terms/create', 'PaymentTermController@create');
|
||||||
|
Route::post('payment_terms', 'PaymentTermController@store');
|
||||||
|
Route::put('payment_terms/{payment_terms}', 'PaymentTermController@update');
|
||||||
|
Route::get('payment_terms/{payment_terms}/edit', 'PaymentTermController@edit');
|
||||||
|
Route::post('payment_terms/bulk', 'PaymentTermController@bulk');
|
||||||
|
|
||||||
Route::get('bank_accounts/import_ofx', 'BankAccountController@showImportOFX');
|
Route::get('bank_accounts/import_ofx', 'BankAccountController@showImportOFX');
|
||||||
Route::post('bank_accounts/import_ofx', 'BankAccountController@doImportOFX');
|
Route::post('bank_accounts/import_ofx', 'BankAccountController@doImportOFX');
|
||||||
Route::resource('bank_accounts', 'BankAccountController');
|
Route::resource('bank_accounts', 'BankAccountController');
|
||||||
|
37
app/Ninja/Datatables/PaymentTermDatatable.php
Normal file
37
app/Ninja/Datatables/PaymentTermDatatable.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\Datatables;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use URL;
|
||||||
|
use Utils;
|
||||||
|
|
||||||
|
class PaymentTermDatatable extends EntityDatatable
|
||||||
|
{
|
||||||
|
public $entityType = ENTITY_PAYMENT_TERM;
|
||||||
|
public $sortCol = 1;
|
||||||
|
|
||||||
|
public function columns()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'num_days',
|
||||||
|
function ($model) {
|
||||||
|
return link_to("payment_terms/{$model->public_id}/edit", trans('texts.payment_terms_net') . ' ' . ($model->num_days == -1 ? 0 : $model->num_days))->toHtml();
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
trans('texts.edit_payment_term'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("payment_terms/{$model->public_id}/edit");
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ class PaymentTermRepository extends BaseRepository
|
|||||||
public function find($accountId = 0)
|
public function find($accountId = 0)
|
||||||
{
|
{
|
||||||
return DB::table('payment_terms')
|
return DB::table('payment_terms')
|
||||||
//->where('payment_terms.account_id', '=', $accountId)
|
->where('payment_terms.account_id', '=', $accountId)
|
||||||
->where('payment_terms.deleted_at', '=', null)
|
->where('payment_terms.deleted_at', '=', null)
|
||||||
->select('payment_terms.public_id', 'payment_terms.name', 'payment_terms.num_days', 'payment_terms.deleted_at');
|
->select('payment_terms.public_id', 'payment_terms.name', 'payment_terms.num_days', 'payment_terms.deleted_at');
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
use App\Ninja\Repositories\PaymentTermRepository;
|
use App\Ninja\Repositories\PaymentTermRepository;
|
||||||
|
use App\Ninja\Datatables\PaymentTermDatatable;
|
||||||
use URL;
|
use URL;
|
||||||
|
|
||||||
class PaymentTermService extends BaseService
|
class PaymentTermService extends BaseService
|
||||||
@ -37,9 +38,11 @@ class PaymentTermService extends BaseService
|
|||||||
*/
|
*/
|
||||||
public function getDatatable($accountId = 0)
|
public function getDatatable($accountId = 0)
|
||||||
{
|
{
|
||||||
$query = $this->paymentTermRepo->find();
|
$datatable = new PaymentTermDatatable(false);
|
||||||
|
|
||||||
return $this->datatableService->createDatatable(ENTITY_PAYMENT_TERM, $query, false);
|
$query = $this->paymentTermRepo->find($accountId);
|
||||||
|
|
||||||
|
return $this->datatableService->createDatatable($datatable, $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function columns($entityType, $hideClient)
|
public function columns($entityType, $hideClient)
|
||||||
|
@ -614,7 +614,7 @@ $LANG = array(
|
|||||||
'or' => 'or',
|
'or' => 'or',
|
||||||
'email_error' => 'There was a problem sending the email',
|
'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' => 'Note: emails are sent at the start of the hour.',
|
||||||
'payment_terms_help' => 'Sets the default <b>invoice due date</b>.',
|
'payment_terms_help' => 'Sets the default <b>invoice due date</b>',
|
||||||
'unlink_account' => 'Unlink Account',
|
'unlink_account' => 'Unlink Account',
|
||||||
'unlink' => 'Unlink',
|
'unlink' => 'Unlink',
|
||||||
'show_address' => 'Show Address',
|
'show_address' => 'Show Address',
|
||||||
@ -912,7 +912,7 @@ $LANG = array(
|
|||||||
'expense_error_multiple_clients' => 'The expenses can\'t belong to different clients',
|
'expense_error_multiple_clients' => 'The expenses can\'t belong to different clients',
|
||||||
'expense_error_invoiced' => 'Expense has already been invoiced',
|
'expense_error_invoiced' => 'Expense has already been invoiced',
|
||||||
'convert_currency' => 'Convert currency',
|
'convert_currency' => 'Convert currency',
|
||||||
'num_days' => 'Number of days',
|
'num_days' => 'Number of Days',
|
||||||
'create_payment_term' => 'Create Payment Term',
|
'create_payment_term' => 'Create Payment Term',
|
||||||
'edit_payment_terms' => 'Edit Payment Term',
|
'edit_payment_terms' => 'Edit Payment Term',
|
||||||
'edit_payment_term' => 'Edit Payment Term',
|
'edit_payment_term' => 'Edit Payment Term',
|
||||||
@ -2384,7 +2384,10 @@ $LANG = array(
|
|||||||
'your_statement' => 'Your Statement',
|
'your_statement' => 'Your Statement',
|
||||||
'statement_issued_to' => 'Statement issued to',
|
'statement_issued_to' => 'Statement issued to',
|
||||||
'statement_to' => 'Statement to',
|
'statement_to' => 'Statement to',
|
||||||
|
'customize_options' => 'Customize options',
|
||||||
|
'created_payment_term' => 'Successfully created payment term',
|
||||||
|
'updated_payment_term' => 'Successfully updated payment term',
|
||||||
|
'archived_payment_term' => 'Successfully archived payment term',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
@ -97,7 +97,7 @@
|
|||||||
{!! Former::select('payment_terms')
|
{!! Former::select('payment_terms')
|
||||||
->addOption('','')
|
->addOption('','')
|
||||||
->fromQuery(Cache::get('paymentTerms'), 'name', 'num_days')
|
->fromQuery(Cache::get('paymentTerms'), 'name', 'num_days')
|
||||||
->help(trans('texts.payment_terms_help')) !!}
|
->help(trans('texts.payment_terms_help') . ' | ' . link_to('/settings/payment_terms', trans('texts.customize_options'))) !!}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -171,10 +171,10 @@
|
|||||||
<a href="#company_fields" aria-controls="company_fields" role="tab" data-toggle="tab">{{ trans('texts.company_fields') }}</a>
|
<a href="#company_fields" aria-controls="company_fields" role="tab" data-toggle="tab">{{ trans('texts.company_fields') }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
<a href="#invoice_fields" aria-controls="invoice_fields" role="tab" data-toggle="tab">{{ trans('texts.invoice_fields') }}</a>
|
<a href="#product_fields" aria-controls="product_fields" role="tab" data-toggle="tab">{{ trans('texts.product_fields') }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
<a href="#product_fields" aria-controls="product_fields" role="tab" data-toggle="tab">{{ trans('texts.product_fields') }}</a>
|
<a href="#invoice_fields" aria-controls="invoice_fields" role="tab" data-toggle="tab">{{ trans('texts.invoice_fields') }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation">
|
<li role="presentation">
|
||||||
<a href="#invoice_charges" aria-controls="invoice_charges" role="tab" data-toggle="tab">{{ trans('texts.invoice_charges') }}</a>
|
<a href="#invoice_charges" aria-controls="invoice_charges" role="tab" data-toggle="tab">{{ trans('texts.invoice_charges') }}</a>
|
||||||
@ -209,17 +209,6 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="invoice_fields">
|
|
||||||
<div class="panel-body">
|
|
||||||
|
|
||||||
{!! Former::text('custom_invoice_text_label1')
|
|
||||||
->label(trans('texts.field_label')) !!}
|
|
||||||
{!! Former::text('custom_invoice_text_label2')
|
|
||||||
->label(trans('texts.field_label'))
|
|
||||||
->help(trans('texts.custom_invoice_fields_helps')) !!}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div role="tabpanel" class="tab-pane" id="product_fields">
|
<div role="tabpanel" class="tab-pane" id="product_fields">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
@ -231,6 +220,17 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="invoice_fields">
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
{!! Former::text('custom_invoice_text_label1')
|
||||||
|
->label(trans('texts.field_label')) !!}
|
||||||
|
{!! Former::text('custom_invoice_text_label2')
|
||||||
|
->label(trans('texts.field_label'))
|
||||||
|
->help(trans('texts.custom_invoice_fields_helps')) !!}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="invoice_charges">
|
<div role="tabpanel" class="tab-pane" id="invoice_charges">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
{!! Former::open($url)->method($method)
|
{!! Former::open($url)->method($method)
|
||||||
->rules([
|
->rules([
|
||||||
'name' => 'required',
|
|
||||||
'num_days' => 'required'
|
'num_days' => 'required'
|
||||||
])
|
])
|
||||||
->addClass('warn-on-exit') !!}
|
->addClass('warn-on-exit') !!}
|
||||||
@ -23,8 +22,10 @@
|
|||||||
{{ Former::populate($paymentTerm) }}
|
{{ Former::populate($paymentTerm) }}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{!! Former::text('name')->label('texts.name') !!}
|
{!! Former::text('num_days')
|
||||||
{!! Former::text('num_days')->label('texts.num_days') !!}
|
->type('number')
|
||||||
|
->min(1)
|
||||||
|
->label('texts.num_days') !!}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,15 +14,14 @@
|
|||||||
|
|
||||||
{!! Datatable::table()
|
{!! Datatable::table()
|
||||||
->addColumn(
|
->addColumn(
|
||||||
trans('texts.name'),
|
|
||||||
trans('texts.num_days'),
|
trans('texts.num_days'),
|
||||||
trans('texts.action'))
|
trans('texts.action'))
|
||||||
->setUrl(url('api/payment_terms/'))
|
->setUrl(url('api/payment_terms/'))
|
||||||
->setOptions('sPaginationType', 'bootstrap')
|
->setOptions('sPaginationType', 'bootstrap')
|
||||||
->setOptions('bFilter', false)
|
->setOptions('bFilter', false)
|
||||||
->setOptions('bAutoWidth', false)
|
->setOptions('bAutoWidth', false)
|
||||||
->setOptions('aoColumns', [[ "sWidth"=> "40%" ], [ "sWidth"=> "40%" ], ["sWidth"=> "20%"]])
|
->setOptions('aoColumns', [[ "sWidth"=> "50%" ], [ "sWidth"=> "50%" ]])
|
||||||
->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[2]]])
|
->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[1]]])
|
||||||
->render('datatable') !!}
|
->render('datatable') !!}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user