From 47f38ad54e7d0856f75cdbe4815011971f707148 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 21 Oct 2015 14:11:08 +0300 Subject: [PATCH] Added support for default taxes --- app/Http/Controllers/AccountController.php | 37 ++++ .../Controllers/AccountGatewayController.php | 5 + app/Http/Controllers/InvoiceController.php | 21 +- app/Http/Controllers/ProductController.php | 75 ++++--- app/Http/Controllers/TaxRateController.php | 110 ++++++++++ app/Http/Controllers/TokenController.php | 5 + app/Http/Controllers/UserController.php | 5 + app/Http/routes.php | 5 + app/Models/Account.php | 6 + app/Models/Product.php | 5 + app/Ninja/Repositories/TaxRateRepository.php | 2 + ...015_10_21_075058_add_default_tax_rates.php | 40 ++++ database/seeds/PaymentLibrariesSeeder.php | 1 + resources/lang/en/texts.php | 12 +- resources/lang/lt/texts.php | 2 +- resources/views/accounts/product.blade.php | 7 + resources/views/accounts/products.blade.php | 10 +- resources/views/accounts/tax_rate.blade.php | 47 +++++ resources/views/accounts/tax_rates.blade.php | 79 +++++++ resources/views/invoices/edit.blade.php | 194 +++--------------- 20 files changed, 452 insertions(+), 216 deletions(-) create mode 100644 app/Http/Controllers/TaxRateController.php create mode 100644 database/migrations/2015_10_21_075058_add_default_tax_rates.php create mode 100644 resources/views/accounts/tax_rate.blade.php create mode 100644 resources/views/accounts/tax_rates.blade.php diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 9deebc13dbf1..182cb4ab6e2f 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -36,6 +36,7 @@ use App\Models\Gateway; use App\Models\Timezone; use App\Models\Industry; use App\Models\InvoiceDesign; +use App\Models\TaxRate; use App\Ninja\Repositories\AccountRepository; use App\Ninja\Mailers\UserMailer; use App\Ninja\Mailers\ContactMailer; @@ -164,6 +165,8 @@ class AccountController extends BaseController return self::showTemplates(); } elseif ($section === ACCOUNT_PRODUCTS) { return self::showProducts(); + } elseif ($section === ACCOUNT_TAX_RATES) { + return self::showTaxRates(); } else { $data = [ 'account' => Account::with('users')->findOrFail(Auth::user()->account_id), @@ -238,14 +241,32 @@ class AccountController extends BaseController private function showProducts() { + $columns = ['product', 'description', 'unit_cost']; + if (Auth::user()->account->invoice_item_taxes) { + $columns[] = 'tax_rate'; + } + $columns[] = 'action'; + $data = [ 'account' => Auth::user()->account, 'title' => trans('texts.product_library'), + 'columns' => Utils::trans($columns), ]; return View::make('accounts.products', $data); } + private function showTaxRates() + { + $data = [ + 'account' => Auth::user()->account, + 'title' => trans('texts.tax_rates'), + 'taxRates' => TaxRate::scope()->get(['id', 'name', 'rate']), + ]; + + return View::make('accounts.tax_rates', $data); + } + private function showInvoiceDesign($section) { $account = Auth::user()->account->load('country'); @@ -349,6 +370,8 @@ class AccountController extends BaseController return AccountController::saveEmailTemplates(); } elseif ($section === ACCOUNT_PRODUCTS) { return AccountController::saveProducts(); + } elseif ($section === ACCOUNT_TAX_RATES) { + return AccountController::saveTaxRates(); } } @@ -398,6 +421,20 @@ class AccountController extends BaseController return Redirect::to('settings/' . ACCOUNT_TEMPLATES_AND_REMINDERS); } + private function saveTaxRates() + { + $account = Auth::user()->account; + + $account->invoice_taxes = Input::get('invoice_taxes') ? true : false; + $account->invoice_item_taxes = Input::get('invoice_item_taxes') ? true : false; + $account->show_item_taxes = Input::get('show_item_taxes') ? true : false; + $account->default_tax_rate_id = Input::get('default_tax_rate_id'); + $account->save(); + + Session::flash('message', trans('texts.updated_settings')); + return Redirect::to('settings/' . ACCOUNT_TAX_RATES); + } + private function saveProducts() { $account = Auth::user()->account; diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php index d99f0be47fc8..e448f5bdb5be 100644 --- a/app/Http/Controllers/AccountGatewayController.php +++ b/app/Http/Controllers/AccountGatewayController.php @@ -19,6 +19,11 @@ use App\Ninja\Repositories\AccountRepository; class AccountGatewayController extends BaseController { + public function index() + { + return Redirect::to('settings/' . ACCOUNT_PAYMENTS); + } + public function getDatatable() { $query = DB::table('account_gateways') diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 6ff0d57512e4..6b6194bc50ec 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -31,7 +31,6 @@ use App\Models\Gateway; use App\Ninja\Mailers\ContactMailer as Mailer; use App\Ninja\Repositories\InvoiceRepository; use App\Ninja\Repositories\ClientRepository; -use App\Ninja\Repositories\TaxRateRepository; use App\Events\InvoiceViewed; class InvoiceController extends BaseController @@ -39,16 +38,14 @@ class InvoiceController extends BaseController protected $mailer; protected $invoiceRepo; protected $clientRepo; - protected $taxRateRepo; - public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, TaxRateRepository $taxRateRepo) + public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo) { parent::__construct(); $this->mailer = $mailer; $this->invoiceRepo = $invoiceRepo; $this->clientRepo = $clientRepo; - $this->taxRateRepo = $taxRateRepo; } public function index() @@ -393,7 +390,7 @@ class InvoiceController extends BaseController return [ 'account' => Auth::user()->account->load('country'), - 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')), + 'products' => Product::scope()->with('default_tax_rate')->orderBy('id')->get(), 'countries' => Cache::get('countries'), 'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(), @@ -523,8 +520,6 @@ class InvoiceController extends BaseController { $invoice = $input->invoice; - $this->taxRateRepo->save($input->tax_rates); - $clientData = (array) $invoice->client; $client = $this->clientRepo->save($invoice->client->public_id, $clientData); @@ -532,18 +527,6 @@ class InvoiceController extends BaseController $invoiceData['client_id'] = $client->id; $invoice = $this->invoiceRepo->save($publicId, $invoiceData, $entityType); - $account = Auth::user()->account; - if ($account->invoice_taxes != $input->invoice_taxes - || $account->invoice_item_taxes != $input->invoice_item_taxes - || $account->invoice_design_id != $input->invoice->invoice_design_id - || $account->show_item_taxes != $input->show_item_taxes) { - $account->invoice_taxes = $input->invoice_taxes; - $account->invoice_item_taxes = $input->invoice_item_taxes; - $account->invoice_design_id = $input->invoice->invoice_design_id; - $account->show_item_taxes = $input->show_item_taxes; - $account->save(); - } - $client->load('contacts'); $sendInvoiceIds = []; diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 3f8e8b499047..ba8fb6b7ae3a 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -12,51 +12,76 @@ use Session; use Redirect; use App\Models\Product; +use App\Models\TaxRate; class ProductController extends BaseController { + public function index() + { + return Redirect::to('settings/' . ACCOUNT_PRODUCTS); + } + public function getDatatable() { + $account = Auth::user()->account; + $query = DB::table('products') + ->leftJoin('tax_rates', function($join){ + $join->on('tax_rates.id', '=', 'products.default_tax_rate_id') + ->whereNull('tax_rates.deleted_at'); + }) ->where('products.account_id', '=', Auth::user()->account_id) ->where('products.deleted_at', '=', null) - ->select('products.public_id', 'products.product_key', 'products.notes', 'products.cost'); + ->select('products.public_id', 'products.product_key', 'products.notes', 'products.cost', 'tax_rates.name as tax_name', 'tax_rates.rate as tax_rate'); - return Datatable::query($query) - ->addColumn('product_key', function ($model) { return link_to('products/'.$model->public_id.'/edit', $model->product_key); }) - ->addColumn('notes', function ($model) { return nl2br(Str::limit($model->notes, 100)); }) - ->addColumn('cost', function ($model) { return Utils::formatMoney($model->cost); }) - ->addColumn('dropdown', function ($model) { - return ''; - }) - ->orderColumns(['cost', 'product_key', 'cost']) - ->make(); + $datatable = Datatable::query($query) + ->addColumn('product_key', function ($model) { return link_to('products/'.$model->public_id.'/edit', $model->product_key); }) + ->addColumn('notes', function ($model) { return nl2br(Str::limit($model->notes, 100)); }) + ->addColumn('cost', function ($model) { return Utils::formatMoney($model->cost); }); + + if ($account->invoice_item_taxes) { + $datatable->addColumn('tax_rate', function ($model) { return $model->tax_rate ? ($model->tax_name . ' ' . $model->tax_rate . '%') : ''; }); + } + + return $datatable->addColumn('dropdown', function ($model) { + return ''; + }) + ->orderColumns(['cost', 'product_key', 'cost']) + ->make(); } public function edit($publicId) { + $account = Auth::user()->account; + $data = [ - 'product' => Product::scope($publicId)->firstOrFail(), - 'method' => 'PUT', - 'url' => 'products/'.$publicId, - 'title' => trans('texts.edit_product'), - ]; + 'account' => $account, + 'taxRates' => $account->invoice_item_taxes ? TaxRate::scope()->get(['id', 'name', 'rate']) : null, + 'product' => Product::scope($publicId)->firstOrFail(), + 'method' => 'PUT', + 'url' => 'products/'.$publicId, + 'title' => trans('texts.edit_product'), + ]; return View::make('accounts.product', $data); } public function create() { + $account = Auth::user()->account; + $data = [ + 'account' => $account, + 'taxRates' => $account->invoice_item_taxes ? TaxRate::scope()->get(['id', 'name', 'rate']) : null, 'product' => null, 'method' => 'POST', 'url' => 'products', @@ -87,6 +112,8 @@ class ProductController extends BaseController $product->product_key = trim(Input::get('product_key')); $product->notes = trim(Input::get('notes')); $product->cost = trim(Input::get('cost')); + $product->default_tax_rate_id = Input::get('default_tax_rate_id'); + $product->save(); $message = $productPublicId ? trans('texts.updated_product') : trans('texts.created_product'); diff --git a/app/Http/Controllers/TaxRateController.php b/app/Http/Controllers/TaxRateController.php new file mode 100644 index 000000000000..656a7b98d84c --- /dev/null +++ b/app/Http/Controllers/TaxRateController.php @@ -0,0 +1,110 @@ +where('tax_rates.account_id', '=', Auth::user()->account_id) + ->where('tax_rates.deleted_at', '=', null) + ->select('tax_rates.public_id', 'tax_rates.name', 'tax_rates.rate'); + + return Datatable::query($query) + ->addColumn('name', function ($model) { return link_to('tax_rates/'.$model->public_id.'/edit', $model->name); }) + ->addColumn('rate', function ($model) { return $model->rate . '%'; }) + ->addColumn('dropdown', function ($model) { + return ''; + }) + ->orderColumns(['name', 'rate']) + ->make(); + } + + public function edit($publicId) + { + $data = [ + 'taxRate' => TaxRate::scope($publicId)->firstOrFail(), + 'method' => 'PUT', + 'url' => 'tax_rates/'.$publicId, + 'title' => trans('texts.edit_tax_rate'), + ]; + + return View::make('accounts.tax_rate', $data); + } + + public function create() + { + $data = [ + 'taxRate' => null, + 'method' => 'POST', + 'url' => 'tax_rates', + 'title' => trans('texts.create_tax_rate'), + ]; + + return View::make('accounts.tax_rate', $data); + } + + public function store() + { + return $this->save(); + } + + public function update($publicId) + { + return $this->save($publicId); + } + + private function save($publicId = false) + { + if ($publicId) { + $taxRate = TaxRate::scope($publicId)->firstOrFail(); + } else { + $taxRate = TaxRate::createNew(); + } + + $taxRate->name = trim(Input::get('name')); + $taxRate->rate = Utils::parseFloat(Input::get('rate')); + $taxRate->save(); + + $message = $publicId ? trans('texts.updated_tax_rate') : trans('texts.created_tax_rate'); + Session::flash('message', $message); + + return Redirect::to('settings/' . ACCOUNT_TAX_RATES); + } + + public function archive($publicId) + { + $tax_rate = TaxRate::scope($publicId)->firstOrFail(); + $tax_rate->delete(); + + Session::flash('message', trans('texts.archived_tax_rate')); + + return Redirect::to('settings/' . ACCOUNT_TAX_RATES); + } +} diff --git a/app/Http/Controllers/TokenController.php b/app/Http/Controllers/TokenController.php index 704888e642c4..9feca2c1a9ae 100644 --- a/app/Http/Controllers/TokenController.php +++ b/app/Http/Controllers/TokenController.php @@ -25,6 +25,11 @@ use App\Ninja\Repositories\AccountRepository; class TokenController extends BaseController { + public function index() + { + return Redirect::to('settings/' . ACCOUNT_API_TOKENS); + } + public function getDatatable() { $query = DB::table('account_tokens') diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 9802b50e97e4..84f30ca20bfb 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -35,6 +35,11 @@ class UserController extends BaseController $this->userMailer = $userMailer; } + public function index() + { + return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT); + } + public function getDatatable() { $query = DB::table('users') diff --git a/app/Http/routes.php b/app/Http/routes.php index 652df6360a0e..f0635392e060 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -114,6 +114,10 @@ Route::group(['middleware' => 'auth'], function() { Route::resource('products', 'ProductController'); Route::get('products/{product_id}/archive', 'ProductController@archive'); + Route::get('api/tax_rates', array('as'=>'api.tax_rates', 'uses'=>'TaxRateController@getDatatable')); + Route::resource('tax_rates', 'TaxRateController'); + Route::get('tax_rates/{tax_rates_id}/archive', 'TaxRateController@archive'); + Route::get('company/{section}/{subSection?}', 'AccountController@redirectLegacy'); Route::get('settings/data_visualizations', 'ReportController@d3'); Route::get('settings/charts_and_reports', 'ReportController@showReports'); @@ -258,6 +262,7 @@ if (!defined('CONTACT_EMAIL')) { define('ACCOUNT_PAYMENTS', 'online_payments'); define('ACCOUNT_MAP', 'import_map'); define('ACCOUNT_EXPORT', 'export'); + define('ACCOUNT_TAX_RATES', 'tax_rates'); define('ACCOUNT_PRODUCTS', 'products'); define('ACCOUNT_ADVANCED_SETTINGS', 'advanced_settings'); define('ACCOUNT_INVOICE_SETTINGS', 'invoice_settings'); diff --git a/app/Models/Account.php b/app/Models/Account.php index bbfba1289485..5bbc4bb48bc7 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -20,6 +20,7 @@ class Account extends Eloquent ACCOUNT_USER_DETAILS, ACCOUNT_LOCALIZATION, ACCOUNT_PAYMENTS, + ACCOUNT_TAX_RATES, ACCOUNT_PRODUCTS, ACCOUNT_NOTIFICATIONS, ACCOUNT_IMPORT_EXPORT, @@ -106,6 +107,11 @@ class Account extends Eloquent return $this->belongsTo('App\Models\Industry'); } + public function default_tax_rate() + { + return $this->belongsTo('App\Models\TaxRate'); + } + public function isGatewayConfigured($gatewayId = 0) { $this->load('account_gateways'); diff --git a/app/Models/Product.php b/app/Models/Product.php index a1059dfbd73c..98ad8e064939 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -11,4 +11,9 @@ class Product extends EntityModel { return Product::scope()->where('product_key', '=', $key)->first(); } + + public function default_tax_rate() + { + return $this->belongsTo('App\Models\TaxRate'); + } } diff --git a/app/Ninja/Repositories/TaxRateRepository.php b/app/Ninja/Repositories/TaxRateRepository.php index d5bd4dc24287..17a9ef35a892 100644 --- a/app/Ninja/Repositories/TaxRateRepository.php +++ b/app/Ninja/Repositories/TaxRateRepository.php @@ -5,6 +5,7 @@ use Utils; class TaxRateRepository { + /* public function save($taxRates) { $taxRateIds = []; @@ -39,4 +40,5 @@ class TaxRateRepository } } } + */ } diff --git a/database/migrations/2015_10_21_075058_add_default_tax_rates.php b/database/migrations/2015_10_21_075058_add_default_tax_rates.php new file mode 100644 index 000000000000..0f2299e68fee --- /dev/null +++ b/database/migrations/2015_10_21_075058_add_default_tax_rates.php @@ -0,0 +1,40 @@ +unsignedInteger('default_tax_rate_id')->nullable(); + $table->smallInteger('recurring_hour')->default(DEFAULT_SEND_RECURRING_HOUR); + }); + + Schema::table('products', function ($table) { + $table->unsignedInteger('default_tax_rate_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('default_tax_rate_id'); + $table->dropColumn('recurring_hour'); + }); + + Schema::table('products', function ($table) { + $table->dropColumn('default_tax_rate_id'); + }); + } +} diff --git a/database/seeds/PaymentLibrariesSeeder.php b/database/seeds/PaymentLibrariesSeeder.php index 96ce8d26305f..03cfe984affb 100644 --- a/database/seeds/PaymentLibrariesSeeder.php +++ b/database/seeds/PaymentLibrariesSeeder.php @@ -96,6 +96,7 @@ class PaymentLibrariesSeeder extends Seeder ['name' => 'Hong Kong Dollar', 'code' => 'HKD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['name' => 'Indonesian Rupiah', 'code' => 'IDR', 'symbol' => 'Rp', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ['name' => 'Mexican Peso', 'code' => 'MXN', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Egyptian Pound', 'code' => 'EGP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], ]; foreach ($currencies as $currency) { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index fc264a39a2f7..01fbbc7ee2bf 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -337,7 +337,7 @@ return array( 'fill_products_help' => 'Selecting a product will automatically fill in the description and cost', 'update_products' => 'Auto-update products', 'update_products_help' => 'Updating an invoice will automatically update the product library', - 'create_product' => 'Create Product', + 'create_product' => 'Add Product', 'edit_product' => 'Edit Product', 'archive_product' => 'Archive Product', 'updated_product' => 'Successfully updated product', @@ -831,7 +831,17 @@ return array( 'referral_code_help' => 'Earn money by sharing our app online', 'enable_with_stripe' => 'Enable | Requires Stripe', + 'tax_settings' => 'Tax Settings', + 'create_tax_rate' => 'Add Tax Rate', + 'updated_tax_rate' => 'Successfully updated tax rate', + 'created_tax_rate' => 'Successfully created tax rate', + 'edit_tax_rate' => 'Edit tax rate', + 'archive_tax_rate' => 'Archive tax rate', + 'archived_tax_rate' => 'Successfully archived the tax rate', + 'default_tax_rate_id' => 'Default Tax Rate', + 'tax_rate' => 'Tax Rate', ); + diff --git a/resources/lang/lt/texts.php b/resources/lang/lt/texts.php index c93e6d9a9196..2c20fc364399 100644 --- a/resources/lang/lt/texts.php +++ b/resources/lang/lt/texts.php @@ -337,7 +337,7 @@ return array( 'fill_products_help' => 'Selecting a product will automatically fill in the description and cost', 'update_products' => 'Auto-update products', 'update_products_help' => 'Updating an invoice will automatically update the product library', - 'create_product' => 'Create Product', + 'create_product' => 'Add Product', 'edit_product' => 'Edit Product', 'archive_product' => 'Archive Product', 'updated_product' => 'Successfully updated product', diff --git a/resources/views/accounts/product.blade.php b/resources/views/accounts/product.blade.php index 3f2b7f4b27e3..d970ea7cbbb9 100644 --- a/resources/views/accounts/product.blade.php +++ b/resources/views/accounts/product.blade.php @@ -25,6 +25,13 @@ {!! Former::textarea('notes') !!} {!! Former::text('cost') !!} + @if ($account->invoice_item_taxes) + {!! Former::select('default_tax_rate_id') + ->addOption('', '') + ->label(trans('texts.tax_rate')) + ->fromQuery($taxRates, function($model) { return $model->name . ' ' . $model->rate . '%'; }, 'id') !!} + @endif + diff --git a/resources/views/accounts/products.blade.php b/resources/views/accounts/products.blade.php index 9ebdf22a3ab5..b0c12ad53538 100644 --- a/resources/views/accounts/products.blade.php +++ b/resources/views/accounts/products.blade.php @@ -19,7 +19,7 @@ {!! Former::checkbox('fill_products')->text(trans('texts.fill_products_help')) !!} {!! Former::checkbox('update_products')->text(trans('texts.update_products_help')) !!}   - {!! Former::actions( Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) ) !!} + {!! Former::actions( Button::success(trans('texts.save'))->submit()->appendIcon(Icon::create('floppy-disk')) ) !!} {!! Former::close() !!} @@ -30,16 +30,12 @@ ->appendIcon(Icon::create('plus-sign')) !!} {!! Datatable::table() - ->addColumn( - trans('texts.product'), - trans('texts.description'), - trans('texts.unit_cost'), - trans('texts.action')) + ->addColumn($columns) ->setUrl(url('api/products/')) ->setOptions('sPaginationType', 'bootstrap') ->setOptions('bFilter', false) ->setOptions('bAutoWidth', false) - ->setOptions('aoColumns', [[ "sWidth"=> "20%" ], [ "sWidth"=> "45%" ], ["sWidth"=> "20%"], ["sWidth"=> "15%" ]]) + //->setOptions('aoColumns', [[ "sWidth"=> "15%" ], [ "sWidth"=> "35%" ]]) ->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[3]]]) ->render('datatable') !!} diff --git a/resources/views/accounts/tax_rate.blade.php b/resources/views/accounts/tax_rate.blade.php new file mode 100644 index 000000000000..5889c7aecb96 --- /dev/null +++ b/resources/views/accounts/tax_rate.blade.php @@ -0,0 +1,47 @@ +@extends('header') + +@section('content') + @parent + + @include('accounts.nav', ['selected' => ACCOUNT_TAX_RATES]) + + {!! Former::open($url)->method($method) + ->rules([ + 'name' => 'required', + 'rate' => 'required' + ]) + ->addClass('warn-on-exit') !!} + + +
+
+

{!! $title !!}

+
+
+ + @if ($taxRate) + {{ Former::populate($taxRate) }} + @endif + + {!! Former::text('name')->label('texts.name') !!} + {!! Former::text('rate')->label('texts.rate')->append('%') !!} + +
+
+ + {!! Former::actions( + Button::normal(trans('texts.cancel'))->large()->asLinkTo(URL::to('/settings/tax_rates'))->appendIcon(Icon::create('remove-circle')), + Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) + ) !!} + + {!! Former::close() !!} + + + +@stop \ No newline at end of file diff --git a/resources/views/accounts/tax_rates.blade.php b/resources/views/accounts/tax_rates.blade.php new file mode 100644 index 000000000000..831e6358ee64 --- /dev/null +++ b/resources/views/accounts/tax_rates.blade.php @@ -0,0 +1,79 @@ +@extends('header') + +@section('content') + @parent + + @include('accounts.nav', ['selected' => ACCOUNT_TAX_RATES]) + + {!! Former::open()->addClass('warn-on-exit') !!} + {{ Former::populate($account) }} + {{ Former::populateField('invoice_taxes', intval($account->invoice_taxes)) }} + {{ Former::populateField('invoice_item_taxes', intval($account->invoice_item_taxes)) }} + {{ Former::populateField('show_item_taxes', intval($account->show_item_taxes)) }} + + +
+
+

{!! trans('texts.tax_settings') !!}

+
+
+ + {!! Former::checkbox('invoice_taxes') + ->text(trans('texts.enable_invoice_tax')) + ->label(' ') !!} + + {!! Former::checkbox('invoice_item_taxes') + ->text(trans('texts.enable_line_item_tax')) + ->label(' ') !!} + + {!! Former::checkbox('show_item_taxes') + ->text(trans('texts.show_line_item_tax')) + ->label(' ') !!} + +   + + {!! Former::select('default_tax_rate_id') + ->style('max-width: 250px') + ->addOption('', '') + ->fromQuery($taxRates, function($model) { return $model->name . ': ' . $model->rate . '%'; }, 'id') !!} + + +   + {!! Former::actions( Button::success(trans('texts.save'))->submit()->appendIcon(Icon::create('floppy-disk')) ) !!} + {!! Former::close() !!} +
+
+ + {!! Button::primary(trans('texts.create_tax_rate')) + ->asLinkTo(URL::to('/tax_rates/create')) + ->withAttributes(['class' => 'pull-right']) + ->appendIcon(Icon::create('plus-sign')) !!} + + {!! Datatable::table() + ->addColumn( + trans('texts.name'), + trans('texts.rate'), + trans('texts.action')) + ->setUrl(url('api/tax_rates/')) + ->setOptions('sPaginationType', 'bootstrap') + ->setOptions('bFilter', false) + ->setOptions('bAutoWidth', false) + ->setOptions('aoColumns', [[ "sWidth"=> "40%" ], [ "sWidth"=> "40%" ], ["sWidth"=> "20%"]]) + ->setOptions('aoColumnDefs', [['bSortable'=>false, 'aTargets'=>[2]]]) + ->render('datatable') !!} + + + + +@stop \ No newline at end of file diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 906e4b8a4d3f..0e48a6ebce2d 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -147,19 +147,9 @@ {!! Former::text('custom_text_value2')->label($account->custom_invoice_text_label2)->data_bind("value: custom_text_value2, valueUpdate: 'afterkeydown'") !!} @endif - -
- - -
- -

 

-
@@ -251,7 +241,7 @@ - @@ -501,61 +491,6 @@ -
{{ trans('texts.subtotal') }}
- - - - - - - - - - - - - - - - -
{{ trans('texts.name') }}{{ trans('texts.rate') }}
- - - - -   -
-   - - {!! Former::checkbox('invoice_taxes')->text(trans('texts.enable_invoice_tax')) - ->label(trans('texts.settings'))->data_bind('checked: $root.invoice_taxes, enable: $root.tax_rates().length > 1') !!} - {!! Former::checkbox('invoice_item_taxes')->text(trans('texts.enable_line_item_tax')) - ->label(' ')->data_bind('checked: $root.invoice_item_taxes, enable: $root.tax_rates().length > 1') !!} - {!! Former::checkbox('show_item_taxes')->text(trans('texts.show_line_item_tax')) - ->label(' ')->data_bind('checked: $root.show_item_taxes, enable: $root.tax_rates().length > 1') !!} - -
- -
- - - - - - -