diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 566a40b56c..33d337a58f 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -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); diff --git a/app/Http/Controllers/PaymentTermController.php b/app/Http/Controllers/PaymentTermController.php index 65037b0f08..ee215b1b64 100644 --- a/app/Http/Controllers/PaymentTermController.php +++ b/app/Http/Controllers/PaymentTermController.php @@ -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); } /** diff --git a/app/Http/routes.php b/app/Http/routes.php index 9f13388e53..04d17603ee 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -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'); diff --git a/app/Ninja/Datatables/PaymentTermDatatable.php b/app/Ninja/Datatables/PaymentTermDatatable.php new file mode 100644 index 0000000000..d250f2f094 --- /dev/null +++ b/app/Ninja/Datatables/PaymentTermDatatable.php @@ -0,0 +1,37 @@ +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"); + }, + ], + ]; + } +} diff --git a/app/Ninja/Repositories/PaymentTermRepository.php b/app/Ninja/Repositories/PaymentTermRepository.php index 1632d14d4b..5562f68524 100644 --- a/app/Ninja/Repositories/PaymentTermRepository.php +++ b/app/Ninja/Repositories/PaymentTermRepository.php @@ -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'); } diff --git a/app/Services/PaymentTermService.php b/app/Services/PaymentTermService.php index 77dfc7c868..ae8a413b8e 100644 --- a/app/Services/PaymentTermService.php +++ b/app/Services/PaymentTermService.php @@ -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) diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 37a5b6d4c6..c94a14ab03 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -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 invoice due date.', + 'payment_terms_help' => 'Sets the default invoice due date', '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; diff --git a/resources/views/accounts/details.blade.php b/resources/views/accounts/details.blade.php index ca551840d2..8c9c719d29 100644 --- a/resources/views/accounts/details.blade.php +++ b/resources/views/accounts/details.blade.php @@ -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'))) !!} diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index 0c304d09a6..2e13ec72f2 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -171,10 +171,10 @@ {{ trans('texts.company_fields') }}