mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01: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 = [
|
||||
'account' => Auth::user()->account,
|
||||
'title' => trans('texts.payment_terms'),
|
||||
'taxRates' => PaymentTerm::scope()->get(['id', 'name', 'num_days']),
|
||||
];
|
||||
|
||||
return View::make('accounts.payment_terms', $data);
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Services\PaymentTermService;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
@ -43,7 +44,9 @@ class PaymentTermController extends BaseController
|
||||
*/
|
||||
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::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::post('bank_accounts/import_ofx', 'BankAccountController@doImportOFX');
|
||||
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)
|
||||
{
|
||||
return DB::table('payment_terms')
|
||||
//->where('payment_terms.account_id', '=', $accountId)
|
||||
->where('payment_terms.account_id', '=', $accountId)
|
||||
->where('payment_terms.deleted_at', '=', null)
|
||||
->select('payment_terms.public_id', 'payment_terms.name', 'payment_terms.num_days', 'payment_terms.deleted_at');
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Services;
|
||||
|
||||
use App\Ninja\Repositories\PaymentTermRepository;
|
||||
use App\Ninja\Datatables\PaymentTermDatatable;
|
||||
use URL;
|
||||
|
||||
class PaymentTermService extends BaseService
|
||||
@ -37,9 +38,11 @@ class PaymentTermService extends BaseService
|
||||
*/
|
||||
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)
|
||||
|
@ -614,7 +614,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.',
|
||||
'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' => 'Unlink',
|
||||
'show_address' => 'Show Address',
|
||||
@ -912,7 +912,7 @@ $LANG = array(
|
||||
'expense_error_multiple_clients' => 'The expenses can\'t belong to different clients',
|
||||
'expense_error_invoiced' => 'Expense has already been invoiced',
|
||||
'convert_currency' => 'Convert currency',
|
||||
'num_days' => 'Number of days',
|
||||
'num_days' => 'Number of Days',
|
||||
'create_payment_term' => 'Create Payment Term',
|
||||
'edit_payment_terms' => 'Edit Payment Term',
|
||||
'edit_payment_term' => 'Edit Payment Term',
|
||||
@ -2384,7 +2384,10 @@ $LANG = array(
|
||||
'your_statement' => 'Your Statement',
|
||||
'statement_issued_to' => 'Statement issued 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;
|
||||
|
@ -97,7 +97,7 @@
|
||||
{!! Former::select('payment_terms')
|
||||
->addOption('','')
|
||||
->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>
|
||||
|
@ -171,10 +171,10 @@
|
||||
<a href="#company_fields" aria-controls="company_fields" role="tab" data-toggle="tab">{{ trans('texts.company_fields') }}</a>
|
||||
</li>
|
||||
<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 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 role="presentation">
|
||||
<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 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 class="panel-body">
|
||||
|
||||
@ -231,6 +220,17 @@
|
||||
|
||||
</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 class="panel-body">
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
@extends('header')
|
||||
|
||||
@section('content')
|
||||
@section('content')
|
||||
@parent
|
||||
|
||||
@include('accounts.nav', ['selected' => ACCOUNT_PAYMENT_TERMS])
|
||||
|
||||
{!! Former::open($url)->method($method)
|
||||
->rules([
|
||||
'name' => 'required',
|
||||
'num_days' => 'required'
|
||||
])
|
||||
->addClass('warn-on-exit') !!}
|
||||
@ -23,13 +22,15 @@
|
||||
{{ Former::populate($paymentTerm) }}
|
||||
@endif
|
||||
|
||||
{!! Former::text('name')->label('texts.name') !!}
|
||||
{!! Former::text('num_days')->label('texts.num_days') !!}
|
||||
{!! Former::text('num_days')
|
||||
->type('number')
|
||||
->min(1)
|
||||
->label('texts.num_days') !!}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! Former::actions(
|
||||
{!! Former::actions(
|
||||
Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/settings/payment_terms'))->appendIcon(Icon::create('remove-circle')),
|
||||
Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk'))
|
||||
) !!}
|
||||
@ -44,4 +45,4 @@
|
||||
|
||||
</script>
|
||||
|
||||
@stop
|
||||
@stop
|
||||
|
@ -1,6 +1,6 @@
|
||||
@extends('header')
|
||||
|
||||
@section('content')
|
||||
@section('content')
|
||||
@parent
|
||||
|
||||
@include('accounts.nav', ['selected' => ACCOUNT_PAYMENT_TERMS])
|
||||
@ -12,22 +12,21 @@
|
||||
|
||||
@include('partials.bulk_form', ['entityType' => ENTITY_PAYMENT_TERM])
|
||||
|
||||
{!! Datatable::table()
|
||||
{!! Datatable::table()
|
||||
->addColumn(
|
||||
trans('texts.name'),
|
||||
trans('texts.num_days'),
|
||||
trans('texts.action'))
|
||||
->setUrl(url('api/payment_terms/'))
|
||||
->setUrl(url('api/payment_terms/'))
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
->setOptions('bFilter', false)
|
||||
->setOptions('bAutoWidth', false)
|
||||
->setOptions('aoColumns', [[ "sWidth"=> "40%" ], [ "sWidth"=> "40%" ], ["sWidth"=> "20%"]])
|
||||
->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[2]]])
|
||||
->setOptions('bFilter', false)
|
||||
->setOptions('bAutoWidth', false)
|
||||
->setOptions('aoColumns', [[ "sWidth"=> "50%" ], [ "sWidth"=> "50%" ]])
|
||||
->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[1]]])
|
||||
->render('datatable') !!}
|
||||
|
||||
<script>
|
||||
window.onDatatableReady = actionListHandler;
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
@stop
|
||||
@stop
|
||||
|
Loading…
Reference in New Issue
Block a user