From 6771a56197cf532e6356671d2d4b3f74c937d560 Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Mon, 9 Jul 2018 18:13:23 +0200 Subject: [PATCH 01/12] Added charging tax at the organiser level 1) Added new field to the organiser model called charge_tax. Added the migration for this. 2) Renamed tax fields columns in the database to be the same as the other organiser fields for consistency. 3) Added charge_tax option to the various organiser create and edit pages. 4) Have re-enabled some tests and used the @group passing label so we can start running tests for the various parts of the applicaiton. --- app/Http/Controllers/OrganiserController.php | 15 +++-- .../OrganiserCustomizeController.php | 9 ++- app/Models/Organiser.php | 27 +++++--- ...al_tax_field_rename_current_tax_fields.php | 37 +++++++++++ phpunit.xml | 4 +- .../ManageOrganiser/CreateOrganiser.blade.php | 25 ++++---- .../views/ManageOrganiser/Customize.blade.php | 56 +++++++++++++---- tests/OrganiserCustomizeTest.php | 8 ++- tests/OrganiserTest.php | 61 +++++++++++++++++-- 9 files changed, 192 insertions(+), 50 deletions(-) create mode 100644 database/migrations/2018_07_09_133243_additional_tax_field_rename_current_tax_fields.php diff --git a/app/Http/Controllers/OrganiserController.php b/app/Http/Controllers/OrganiserController.php index a9261025..fa64af95 100644 --- a/app/Http/Controllers/OrganiserController.php +++ b/app/Http/Controllers/OrganiserController.php @@ -40,6 +40,11 @@ class OrganiserController extends MyBaseController { $organiser = Organiser::createNew(false, false, true); + $chargeTax = $request->get('charge_tax'); + + if ($chargeTax == 'Yes') { + $organiser->addExtraValidationRules(); + } if (!$organiser->validate($request->all())) { return response()->json([ 'status' => 'error', @@ -53,13 +58,11 @@ class OrganiserController extends MyBaseController $organiser->facebook = $request->get('facebook'); $organiser->twitter = $request->get('twitter'); $organiser->confirmation_key = str_random(15); - $organiser->taxname = $request->get('taxname'); - $organiser->taxvalue = $request->get('taxvalue'); - $organiser->taxid = $request->get('taxid'); - $organiser->taxname = $request->get('taxname'); - $organiser->taxvalue = round($request->get('taxvalue'),2); - $organiser->taxid = $request->get('taxid'); + $organiser->tax_name = $request->get('tax_name'); + $organiser->tax_value = round($request->get('tax_value'),2); + $organiser->tax_id = $request->get('tax_id'); + $organiser->charge_tax = ($chargeTax == 'Yes') ? 1 : 0; if ($request->hasFile('organiser_logo')) { $organiser->setLogo($request->file('organiser_logo')); diff --git a/app/Http/Controllers/OrganiserCustomizeController.php b/app/Http/Controllers/OrganiserCustomizeController.php index a50b8c37..92ed3b4d 100644 --- a/app/Http/Controllers/OrganiserCustomizeController.php +++ b/app/Http/Controllers/OrganiserCustomizeController.php @@ -50,9 +50,12 @@ class OrganiserCustomizeController extends MyBaseController $organiser->enable_organiser_page = $request->get('enable_organiser_page'); $organiser->facebook = $request->get('facebook'); $organiser->twitter = $request->get('twitter'); - $organiser->taxname = $request->get('taxname'); - $organiser->taxvalue = $request->get('taxvalue'); - $organiser->taxid = $request->get('taxid'); + $organiser->tax_name = $request->get('tax_name'); + $organiser->tax_value = $request->get('tax_value'); + $organiser->tax_id = $request->get('tax_id'); + $organiser->charge_tax = ($request->get('charge_tax') == 1) ? 1 : 0; + + //var_dump($organiser->charge_tax); if ($request->get('remove_current_image') == '1') { $organiser->logo_path = ''; diff --git a/app/Models/Organiser.php b/app/Models/Organiser.php index 900d5ba1..89aa5cac 100644 --- a/app/Models/Organiser.php +++ b/app/Models/Organiser.php @@ -2,12 +2,15 @@ namespace App\Models; +use Illuminate\Auth\Authenticatable; use Illuminate\Http\UploadedFile; +use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Str; use Image; -class Organiser extends MyBaseModel +class Organiser extends MyBaseModel implements AuthenticatableContract { + use Authenticatable; /** * The validation rules for the model. * @@ -16,21 +19,24 @@ class Organiser extends MyBaseModel protected $rules = [ 'name' => ['required'], 'email' => ['required', 'email'], - 'taxname' => ['required','max:15'], - 'taxvalue' => ['required','numeric'], - 'taxid' => ['required','max:100'], 'organiser_logo' => ['mimes:jpeg,jpg,png', 'max:10000'], ]; + protected $extra_rules = [ + 'tax_name' => ['required','max:15'], + 'tax_value' => ['required','numeric'], + 'tax_id' => ['required','max:100'], + ]; + /** * The validation rules for the model. * * @var array $attributes */ protected $attributes = [ - 'taxname' => 'Tax Name', - 'taxvalue' => 'Tax Rate', - 'taxid' => 'Tax ID', + 'tax_name' => 'Tax Name', + 'tax_value' => 'Tax Rate', + 'tax_id' => 'Tax ID', ]; /** @@ -161,5 +167,12 @@ class Organiser extends MyBaseModel $this->logo_path = $relativePath; } } + + /** + * Adds extra validator rules to the organiser object depending on whether tax is required or not + */ + public function addExtraValidationRules() { + $this->rules = $this->rules + $this->extra_rules; + } } diff --git a/database/migrations/2018_07_09_133243_additional_tax_field_rename_current_tax_fields.php b/database/migrations/2018_07_09_133243_additional_tax_field_rename_current_tax_fields.php new file mode 100644 index 00000000..f4544bd0 --- /dev/null +++ b/database/migrations/2018_07_09_133243_additional_tax_field_rename_current_tax_fields.php @@ -0,0 +1,37 @@ +boolean('charge_tax')->default(0); + $table->renameColumn('taxname', 'tax_name'); + $table->renameColumn('taxvalue', 'tax_value'); + $table->renameColumn('taxid', 'tax_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('organisers', function (Blueprint $table) { + $table->dropColumn('charge_tax'); + $table->renameColumn('tax_name', 'taxname'); + $table->renameColumn('tax_value', 'taxvalue'); + $table->renameColumn('tax_id', 'taxid'); + }); + } +} diff --git a/phpunit.xml b/phpunit.xml index f1bd8182..5a2c22ea 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -19,7 +19,7 @@ - - + + diff --git a/resources/views/ManageOrganiser/CreateOrganiser.blade.php b/resources/views/ManageOrganiser/CreateOrganiser.blade.php index fe6d7f7c..a3d1e0c1 100644 --- a/resources/views/ManageOrganiser/CreateOrganiser.blade.php +++ b/resources/views/ManageOrganiser/CreateOrganiser.blade.php @@ -52,10 +52,6 @@ - - - -
{!! Form::label('about', trans("Organiser.organiser_description"), array('class'=>'control-label ')) !!} {!! Form::textarea('about', Input::old('about'), @@ -65,26 +61,33 @@ 'rows' => 4 )) !!}
+
+

Do you want to Charge Tax at your Events?

+ {!! Form::label('Yes', 'Yes', array('class'=>'control-label', 'id' => 'charge_yes')) !!} + {{ Form::radio('charge_tax', 'Yes' , false) }} + {!! Form::label('No', 'No', array('class'=>'control-label','id' => 'charge_no')) !!} + {{ Form::radio('charge_tax', 'No' , true) }} +
-
+
- {!! Form::label('taxid', 'Tax ID', array('class'=>'control-label required')) !!} - {!! Form::text('taxid', Input::old('taxid'), array('class'=>'form-control', 'placeholder'=>'Tax ID')) !!} + {!! Form::label('tax_id', 'Tax ID', array('class'=>'control-label required')) !!} + {!! Form::text('tax_id', Input::old('tax_id'), array('class'=>'form-control', 'placeholder'=>'Tax ID')) !!}
- {!! Form::label('taxname', 'Tax name', array('class'=>'control-label required')) !!} - {!! Form::text('taxname', Input::old('taxname'), array('class'=>'form-control', 'placeholder'=>'Tax name')) !!} + {!! Form::label('tax_name', 'Tax name', array('class'=>'control-label required')) !!} + {!! Form::text('tax_name', Input::old('tax_name'), array('class'=>'form-control', 'placeholder'=>'Tax name')) !!}
- {!! Form::label('taxvalue', 'Tax value', array('class'=>'control-label required')) !!} - {!! Form::text('taxvalue', Input::old('taxvalue'), array('class'=>'form-control', 'placeholder'=>'Tax Value')) !!} + {!! Form::label('tax_value', 'Tax value', array('class'=>'control-label required')) !!} + {!! Form::text('tax_value', Input::old('tax_value'), array('class'=>'form-control', 'placeholder'=>'Tax Value')) !!}
diff --git a/resources/views/ManageOrganiser/Customize.blade.php b/resources/views/ManageOrganiser/Customize.blade.php index 926e31e4..90c52f94 100644 --- a/resources/views/ManageOrganiser/Customize.blade.php +++ b/resources/views/ManageOrganiser/Customize.blade.php @@ -30,6 +30,25 @@ }); }); + + $(document).ready(function(){ + var charge_tax = $("input[type=radio][name='charge_tax']:checked").val(); + if (charge_tax == 1) { + $('#tax_fields').show(); + } else { + $('#tax_fields').hide(); + } + + $('input[type=radio][name=charge_tax]').change(function() { + if (this.value == 1) { + $('#tax_fields').show(); + } + else { + $('#tax_fields').hide(); + } + }); + }); + @stop @@ -94,24 +113,35 @@ )) !!}
-
+
- {!! Form::label('taxid', 'Tax ID', array('class'=>'control-label required')) !!} - {!! Form::text('taxid', Input::old('taxid'), array('class'=>'form-control', 'placeholder'=>'Tax ID')) !!} +

Do you want to Charge Tax at your Events?

+ + charge_tax == 1 ? 'checked' : '' }}> + + charge_tax == 0 ? 'checked' : '' }}>
- -
-
- {!! Form::label('taxname', 'Tax name', array('class'=>'control-label required')) !!} - {!! Form::text('taxname', Input::old('taxname'), array('class'=>'form-control', 'placeholder'=>'Tax name')) !!} +
+
+
+ {!! Form::label('tax_id', 'Tax ID', array('class'=>'control-label required')) !!} + {!! Form::text('tax_id', Input::old('tax_id'), array('class'=>'form-control', 'placeholder'=>'Tax ID')) !!} +
-
-
-
- {!! Form::label('taxvalue', 'Tax value', array('class'=>'control-label required')) !!} - {!! Form::text('taxvalue', Input::old('taxvalue'), array('class'=>'form-control', 'placeholder'=>'Tax Value')) !!} +
+
+ {!! Form::label('tax_name', 'Tax name', array('class'=>'control-label required')) !!} + {!! Form::text('tax_name', Input::old('tax_name'), array('class'=>'form-control', 'placeholder'=>'Tax name')) !!} +
+
+ +
+
+ {!! Form::label('tax_value', 'Tax value', array('class'=>'control-label required')) !!} + {!! Form::text('tax_value', Input::old('tax_value'), array('class'=>'form-control', 'placeholder'=>'Tax Value')) !!} +
diff --git a/tests/OrganiserCustomizeTest.php b/tests/OrganiserCustomizeTest.php index c21345c1..cfd1941f 100644 --- a/tests/OrganiserCustomizeTest.php +++ b/tests/OrganiserCustomizeTest.php @@ -7,18 +7,20 @@ use App\Models\Organiser; class OrganiserCustomizeTest extends TestCase { + /** + * @group passing + */ public function test_customize_organiser_is_successful() { $organiser = factory(App\Models\Organiser::class)->create(); - $this->actingAs($this->test_user) + $this->actingAs($organiser) ->visit(route('showOrganiserCustomize', ['organiser_id' => $organiser->id])) ->type($this->faker->name, 'name') ->type($this->faker->email, 'email') - ->type($this->faker->email, 'about') ->type($this->faker->word, 'facebook') ->type($this->faker->word, 'twitter') - ->press('Create Organiser') + ->press('Save Organiser') ->seeJson([ 'status' => 'success' ]); diff --git a/tests/OrganiserTest.php b/tests/OrganiserTest.php index c9be7f8e..390d59de 100644 --- a/tests/OrganiserTest.php +++ b/tests/OrganiserTest.php @@ -7,18 +7,69 @@ use App\Models\Organiser; class OrganiserTest extends TestCase { - public function test_create_organiser_is_successful() + /** + * @group passing + */ + public function test_create_organiser_is_successful_when_charge_tax_is_no() { + + $email = $this->faker->email; + $this->actingAs($this->test_user) ->visit(route('showCreateOrganiser')) ->type($this->faker->name, 'name') - ->type($this->faker->email, 'email') - ->type($this->faker->email, 'about') - ->type($this->faker->word, 'facebook') - ->type($this->faker->word, 'twitter') + ->type($email, 'email') + ->type('No', 'charge_tax') ->press('Create Organiser') ->seeJson([ 'status' => 'success' ]); + + //get the most recently created organiser from database + $this->organiser = Organiser::where('email','=', $email)->orderBy('created_at', 'desc')->first(); + //check the charge tax flag is 0 + $this->assertEquals($this->organiser->charge_tax, 0); + } + + /** + * @group passing + */ + public function test_create_organiser_is_successful_when_charge_tax_is_yes() + { + $email = $this->faker->email; + + $this->actingAs($this->test_user) + ->visit(route('showCreateOrganiser')) + ->type($this->faker->name, 'name') + ->type($email, 'email') + ->type('organisers', 'tax_name') + ->type(12323, 'tax_id') + ->type(15, 'tax_value') + ->type('Yes', 'charge_tax') + ->press('Create Organiser') + ->seeJson([ + 'status' => 'success' + ]); + + //get the most recently created organiser from database + $this->organiser = Organiser::where('email','=', $email)->orderBy('created_at', 'desc')->first(); + //check the charge tax flag is 1 + $this->assertEquals($this->organiser->charge_tax, 1); + } + + /** + * @group passing + */ + public function test_create_organiser_fails_when_organiser_details_missing() + { + $this->actingAs($this->test_user) + ->visit(route('showCreateOrganiser')) + ->type('', 'name') + ->type('', 'email') + ->type('No', 'charge_tax') + ->press('Create Organiser') + ->seeJson([ + 'status' => 'error' + ]); } } From 2fa609de2662988ceeb0ad50c1934ba7fb50fbbf Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Mon, 9 Jul 2018 18:15:48 +0200 Subject: [PATCH 02/12] removed var_dump added by mistake --- app/Http/Controllers/OrganiserCustomizeController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Http/Controllers/OrganiserCustomizeController.php b/app/Http/Controllers/OrganiserCustomizeController.php index 92ed3b4d..d35a16ff 100644 --- a/app/Http/Controllers/OrganiserCustomizeController.php +++ b/app/Http/Controllers/OrganiserCustomizeController.php @@ -55,8 +55,6 @@ class OrganiserCustomizeController extends MyBaseController $organiser->tax_id = $request->get('tax_id'); $organiser->charge_tax = ($request->get('charge_tax') == 1) ? 1 : 0; - //var_dump($organiser->charge_tax); - if ($request->get('remove_current_image') == '1') { $organiser->logo_path = ''; } From b3dae02cef6142c95c82db95445880cb4448525e Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Tue, 10 Jul 2018 10:36:42 +0200 Subject: [PATCH 03/12] Tax improvements 1) remove logic for calculating Tax out of the blade view and into a service. 2) implemented service in the correct controller. --- .../Controllers/EventCheckoutController.php | 17 +++++++++++---- app/Services/Order.php | 21 +++++++++++++++++++ .../EventCreateOrderSection.blade.php | 18 +++++----------- 3 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 app/Services/Order.php diff --git a/app/Http/Controllers/EventCheckoutController.php b/app/Http/Controllers/EventCheckoutController.php index b83fd0fa..c5f78b6d 100644 --- a/app/Http/Controllers/EventCheckoutController.php +++ b/app/Http/Controllers/EventCheckoutController.php @@ -12,6 +12,7 @@ use App\Models\OrderItem; use App\Models\QuestionAnswer; use App\Models\ReservedTickets; use App\Models\Ticket; +use App\Services\Order as OrderService; use Carbon\Carbon; use Cookie; use DB; @@ -245,11 +246,19 @@ class EventCheckoutController extends Controller $secondsToExpire = Carbon::now()->diffInSeconds($order_session['expires']); + $event = Event::findorFail($order_session['event_id']); + + $order = new OrderService(); + $orderCosts = $order->calculateFinalCosts($order_session['order_total'], + $order_session['total_booking_fee'], + $event); + $data = $order_session + [ - 'event' => Event::findorFail($order_session['event_id']), + 'event' => $event, 'secondsToExpire' => $secondsToExpire, 'is_embedded' => $this->is_embedded, - ]; + 'order_costs' => $orderCosts + ]; if ($this->is_embedded) { return view('Public.ViewEvent.Embedded.EventPageCheckout', $data); @@ -326,7 +335,7 @@ class EventCheckoutController extends Controller // Calculating grand total including tax $grand_total = $ticket_order['order_total'] + $ticket_order['organiser_booking_fee']; - $tax_amt = ($grand_total * $event->organiser->taxvalue) / 100; + $tax_amt = ($grand_total * $event->organiser->tax_value) / 100; $grand_total = $tax_amt + $grand_total; $transaction_data = [ @@ -533,7 +542,7 @@ class EventCheckoutController extends Controller // Calculating grand total including tax $grand_total = $ticket_order['order_total'] + $ticket_order['organiser_booking_fee']; - $tax_amt = ($grand_total * $event->organiser->taxvalue) / 100; + $tax_amt = ($grand_total * $event->organiser->tax_value) / 100; $order->taxamt = $tax_amt; $order->save(); diff --git a/app/Services/Order.php b/app/Services/Order.php new file mode 100644 index 00000000..924ee0d4 --- /dev/null +++ b/app/Services/Order.php @@ -0,0 +1,21 @@ +organiser->charge_tax == 1) ? ($orderTotalWithBookingFee * $event->organiser->tax_value)/100 + : 0; + + $grandTotal = $orderTotalWithBookingFee + $taxAmount; + + return ['orderTotalWithBookingFee' => money($orderTotalWithBookingFee, $event->currency), + 'taxAmount' => money($taxAmount, $event->currency), + 'grandTotal' => money($grandTotal, $event->currency )]; + } + +} diff --git a/resources/views/Public/ViewEvent/Partials/EventCreateOrderSection.blade.php b/resources/views/Public/ViewEvent/Partials/EventCreateOrderSection.blade.php index e78d662a..38552b59 100644 --- a/resources/views/Public/ViewEvent/Partials/EventCreateOrderSection.blade.php +++ b/resources/views/Public/ViewEvent/Partials/EventCreateOrderSection.blade.php @@ -35,25 +35,17 @@
@if($order_total > 0) From c5676bbe450b1b6ec6230591666f41b1de4d2fbb Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Tue, 10 Jul 2018 12:19:20 +0200 Subject: [PATCH 04/12] Improvements to charging Tax 1) Surfaced more logic from from views into service. 2) If charge_tax is set in database tax is charged. 3) Made the name of the Order service OrderService so its not confused with the Order Eloquent Model. 4) Move order totalling logic in to Service and call service where necessary. --- .../Controllers/EventCheckoutController.php | 35 +++--- app/Services/Order.php | 114 ++++++++++++++++-- .../EventCreateOrderSection.blade.php | 6 +- .../Partials/EventViewOrderSection.blade.php | 16 ++- 4 files changed, 136 insertions(+), 35 deletions(-) diff --git a/app/Http/Controllers/EventCheckoutController.php b/app/Http/Controllers/EventCheckoutController.php index c5f78b6d..aac6773b 100644 --- a/app/Http/Controllers/EventCheckoutController.php +++ b/app/Http/Controllers/EventCheckoutController.php @@ -248,16 +248,14 @@ class EventCheckoutController extends Controller $event = Event::findorFail($order_session['event_id']); - $order = new OrderService(); - $orderCosts = $order->calculateFinalCosts($order_session['order_total'], - $order_session['total_booking_fee'], - $event); + $orderService = new OrderService($order_session['order_total'], $order_session['total_booking_fee'], $event); + $orderService->calculateFinalCosts(); $data = $order_session + [ 'event' => $event, 'secondsToExpire' => $secondsToExpire, 'is_embedded' => $this->is_embedded, - 'order_costs' => $orderCosts + 'orderService' => $orderService ]; if ($this->is_embedded) { @@ -333,13 +331,12 @@ class EventCheckoutController extends Controller 'testMode' => config('attendize.enable_test_payments'), ]); - // Calculating grand total including tax - $grand_total = $ticket_order['order_total'] + $ticket_order['organiser_booking_fee']; - $tax_amt = ($grand_total * $event->organiser->tax_value) / 100; - $grand_total = $tax_amt + $grand_total; + $order = new OrderService($ticket_order['order_total'], $ticket_order['organiser_booking_fee'], $event); + $order->calculateFinalCosts(); + $transaction_data = [ - 'amount' => $grand_total, + 'amount' => $order->getGrandTotal(), 'currency' => $event->currency->code, 'description' => 'Order for customer: ' . $request->get('order_email'), ]; @@ -541,10 +538,10 @@ class EventCheckoutController extends Controller $order->is_payment_received = isset($request_data['pay_offline']) ? 0 : 1; // Calculating grand total including tax - $grand_total = $ticket_order['order_total'] + $ticket_order['organiser_booking_fee']; - $tax_amt = ($grand_total * $event->organiser->tax_value) / 100; + $orderService = new OrderService($ticket_order['order_total'], $ticket_order['organiser_booking_fee'], $event); + $orderService->calculateFinalCosts(); - $order->taxamt = $tax_amt; + $order->taxamt = $orderService->getTaxAmount(); $order->save(); /* @@ -719,11 +716,15 @@ class EventCheckoutController extends Controller abort(404); } + $orderService = new OrderService($order->amount, $order->booking_fee, $order->event); + $orderService->calculateFinalCosts(); + $data = [ - 'order' => $order, - 'event' => $order->event, - 'tickets' => $order->event->tickets, - 'is_embedded' => $this->is_embedded, + 'order' => $order, + 'orderService' => $orderService, + 'event' => $order->event, + 'tickets' => $order->event->tickets, + 'is_embedded' => $this->is_embedded, ]; if ($this->is_embedded) { diff --git a/app/Services/Order.php b/app/Services/Order.php index 924ee0d4..9f3ffa32 100644 --- a/app/Services/Order.php +++ b/app/Services/Order.php @@ -2,20 +2,116 @@ namespace App\Services; +use App\Models\Event; + class Order { - public function calculateFinalCosts($orderTotal, $totalBookingFee, $event) - { - $orderTotalWithBookingFee = $orderTotal + $totalBookingFee; - $taxAmount = ($event->organiser->charge_tax == 1) ? ($orderTotalWithBookingFee * $event->organiser->tax_value)/100 - : 0; + /** + * @var float + */ + private $orderTotal; - $grandTotal = $orderTotalWithBookingFee + $taxAmount; + /** + * @var float + */ + private $totalBookingFee; - return ['orderTotalWithBookingFee' => money($orderTotalWithBookingFee, $event->currency), - 'taxAmount' => money($taxAmount, $event->currency), - 'grandTotal' => money($grandTotal, $event->currency )]; + /** + * @var Event + */ + private $event; + + /** + * @var float + */ + public $orderTotalWithBookingFee; + + /** + * @var float + */ + public $taxAmount; + + /** + * @var float + */ + public $grandTotal; + + /** + * Order constructor. + * @param $orderTotal + * @param $totalBookingFee + * @param $event + */ + public function __construct($orderTotal, $totalBookingFee, $event) { + + $this->orderTotal = $orderTotal; + $this->totalBookingFee = $totalBookingFee; + $this->event = $event; } + + /** + * Calculates the final costs for an event and sets the various totals + */ + public function calculateFinalCosts() + { + $this->orderTotalWithBookingFee = $this->orderTotal + $this->totalBookingFee; + + if ($this->event->organiser->charge_tax == 1) { + $this->taxAmount = ($this->orderTotalWithBookingFee * $this->event->organiser->tax_value)/100; + } else { + $this->taxAmount = 0; + } + + $this->grandTotal = $this->orderTotalWithBookingFee + $this->taxAmount; + } + + /** + * @param bool $currencyFormatted + * @return float|string + */ + public function getOrderTotalWithBookingFee($currencyFormatted = false) { + + if ($currencyFormatted == false ) { + return $this->orderTotalWithBookingFee; + } + + return money($this->orderTotalWithBookingFee, $this->event->currency); + } + + /** + * @param bool $currencyFormatted + * @return float|string + */ + public function getTaxAmount($currencyFormatted = false) { + + if ($currencyFormatted == false ) { + return $this->taxAmount; + } + + return money($this->taxAmount, $this->event->currency); + } + + /** + * @param bool $currencyFormatted + * @return float|string + */ + public function getGrandTotal($currencyFormatted = false) { + + if ($currencyFormatted == false ) { + return $this->grandTotal; + } + + return money($this->grandTotal, $this->event->currency); + + } + + /** + * @return string + */ + public function getVatFormattedInBrackets() { + return "(+" . $this->getTaxAmount(true) . " " . $this->event->organiser->tax_name . ")"; + } + } diff --git a/resources/views/Public/ViewEvent/Partials/EventCreateOrderSection.blade.php b/resources/views/Public/ViewEvent/Partials/EventCreateOrderSection.blade.php index 38552b59..6a1e834f 100644 --- a/resources/views/Public/ViewEvent/Partials/EventCreateOrderSection.blade.php +++ b/resources/views/Public/ViewEvent/Partials/EventCreateOrderSection.blade.php @@ -36,16 +36,16 @@ @if($order_total > 0) diff --git a/resources/views/Public/ViewEvent/Partials/EventViewOrderSection.blade.php b/resources/views/Public/ViewEvent/Partials/EventViewOrderSection.blade.php index bbe59564..85d6191c 100644 --- a/resources/views/Public/ViewEvent/Partials/EventViewOrderSection.blade.php +++ b/resources/views/Public/ViewEvent/Partials/EventViewOrderSection.blade.php @@ -82,8 +82,10 @@
- @lang("Public_ViewEvent.amount")
{{$order->event->currency_symbol}}{{number_format($order->total_amount,2)}} - {{ ($event->organiser->taxname && $event->organiser->taxvalue) ? '(+'.money(($order->total_amount*($event->organiser->taxvalue)/100), $event->currency).' '.$event->organiser->taxname.')' : '' }} + @lang("Public_ViewEvent.amount")
{{$order->event->currency_symbol}}{{number_format($order->total_amount, 2)}} + @if($event->organiser->charge_tax) + {{ $orderService->getVatFormattedInBrackets() }} + @endif
@@ -185,9 +187,10 @@ @lang("Public_ViewEvent.sub_total") - {{money($order->total_amount, $order->event->currency)}} + {{ $orderService->getOrderTotalWithBookingFee(true) }} + @if($event->organiser->charge_tax) @@ -196,12 +199,13 @@ - {{$event->organiser->taxname}} + {{$event->organiser->tax_name}} - {{money(($order->total_amount*($event->organiser->taxvalue)/100), $event->currency)}} + {{ $orderService->getTaxAmount(true) }} + @endif @@ -213,7 +217,7 @@ Total - {{money($order->total_amount+($order->total_amount*($event->organiser->taxvalue)/100), $event->currency)}} + {{ $orderService->getGrandTotal(true) }} @if($order->is_refunded || $order->is_partially_refunded) From 43dab4087333e99cb3d72bbdf65b64c2de25203a Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Tue, 10 Jul 2018 15:04:46 +0200 Subject: [PATCH 05/12] Update attendee ticket email update tickets to have the correct V.A.T amount --- app/Mailers/OrderMailer.php | 4 +++ .../TicketMailer/SendOrderTickets.blade.php | 30 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/app/Mailers/OrderMailer.php b/app/Mailers/OrderMailer.php index eab2efcb..23d69cb1 100644 --- a/app/Mailers/OrderMailer.php +++ b/app/Mailers/OrderMailer.php @@ -3,6 +3,7 @@ namespace App\Mailers; use App\Models\Order; +use App\Services\Order as OrderService; use Log; use Mail; @@ -23,10 +24,13 @@ class OrderMailer public function sendOrderTickets($order) { + $orderService = new OrderService($order->amount, $order->booking_fee, $order->event); + $orderService->calculateFinalCosts(); Log::info("Sending ticket to: " . $order->email); $data = [ 'order' => $order, + 'orderService' => $orderService ]; Mail::send('Mailers.TicketMailer.SendOrderTickets', $data, function ($message) use ($order) { diff --git a/resources/views/en/Mailers/TicketMailer/SendOrderTickets.blade.php b/resources/views/en/Mailers/TicketMailer/SendOrderTickets.blade.php index d87e9734..6fd0acdc 100644 --- a/resources/views/en/Mailers/TicketMailer/SendOrderTickets.blade.php +++ b/resources/views/en/Mailers/TicketMailer/SendOrderTickets.blade.php @@ -86,6 +86,36 @@ Order Email: {{$order->email}}
{{money($order->amount + $order->order_fee, $order->event->currency)}} + @if($order->event->organiser->charge_tax == 1) + + + + + + + + + {{$order->event->organiser->tax_name}} + + + {{$orderService->getTaxAmount(true)}} + + + @endif + + + + + + + + + Total + + + {{$orderService->getGrandTotal(true)}} + +

From a588b634b6aed2383e84ab44ef5b48a5ca2c4716 Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Tue, 10 Jul 2018 16:50:46 +0200 Subject: [PATCH 06/12] added better formatting 1) Omnipay doesn't accept decimals with more than a precision of 2. 2) Once order is created organiser_booking_fee is the correct value to use else use total_booking_fee 3) Controller makes use of OrderService instead of Order Model --- app/Http/Controllers/EventCheckoutController.php | 13 ++++++------- app/Services/Order.php | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/EventCheckoutController.php b/app/Http/Controllers/EventCheckoutController.php index aac6773b..c0eff497 100644 --- a/app/Http/Controllers/EventCheckoutController.php +++ b/app/Http/Controllers/EventCheckoutController.php @@ -255,7 +255,7 @@ class EventCheckoutController extends Controller 'event' => $event, 'secondsToExpire' => $secondsToExpire, 'is_embedded' => $this->is_embedded, - 'orderService' => $orderService + 'orderService' => $orderService ]; if ($this->is_embedded) { @@ -331,12 +331,11 @@ class EventCheckoutController extends Controller 'testMode' => config('attendize.enable_test_payments'), ]); - $order = new OrderService($ticket_order['order_total'], $ticket_order['organiser_booking_fee'], $event); - $order->calculateFinalCosts(); - + $orderService = new OrderService($ticket_order['order_total'], $ticket_order['total_booking_fee'], $event); + $orderService->calculateFinalCosts(); $transaction_data = [ - 'amount' => $order->getGrandTotal(), + 'amount' => $orderService->getGrandTotal(), 'currency' => $event->currency->code, 'description' => 'Order for customer: ' . $request->get('order_email'), ]; @@ -538,7 +537,7 @@ class EventCheckoutController extends Controller $order->is_payment_received = isset($request_data['pay_offline']) ? 0 : 1; // Calculating grand total including tax - $orderService = new OrderService($ticket_order['order_total'], $ticket_order['organiser_booking_fee'], $event); + $orderService = new OrderService($ticket_order['order_total'], $ticket_order['total_booking_fee'], $event); $orderService->calculateFinalCosts(); $order->taxamt = $orderService->getTaxAmount(); @@ -716,7 +715,7 @@ class EventCheckoutController extends Controller abort(404); } - $orderService = new OrderService($order->amount, $order->booking_fee, $order->event); + $orderService = new OrderService($order->amount, $order->organiser_booking_fee, $order->event); $orderService->calculateFinalCosts(); $data = [ diff --git a/app/Services/Order.php b/app/Services/Order.php index 9f3ffa32..17859ac7 100644 --- a/app/Services/Order.php +++ b/app/Services/Order.php @@ -74,7 +74,7 @@ class Order public function getOrderTotalWithBookingFee($currencyFormatted = false) { if ($currencyFormatted == false ) { - return $this->orderTotalWithBookingFee; + return number_format($this->grandTotal, 2, '.', ''); } return money($this->orderTotalWithBookingFee, $this->event->currency); @@ -87,7 +87,7 @@ class Order public function getTaxAmount($currencyFormatted = false) { if ($currencyFormatted == false ) { - return $this->taxAmount; + return number_format($this->grandTotal, 2, '.', ''); } return money($this->taxAmount, $this->event->currency); @@ -100,7 +100,7 @@ class Order public function getGrandTotal($currencyFormatted = false) { if ($currencyFormatted == false ) { - return $this->grandTotal; + return number_format($this->grandTotal, 2, '.', ''); } return money($this->grandTotal, $this->event->currency); From 6dd7edec97cb7ce4056752c8451f15cb4085059f Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Tue, 10 Jul 2018 17:03:16 +0200 Subject: [PATCH 07/12] introduced a bug when I added number_format fixed --- app/Services/Order.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Services/Order.php b/app/Services/Order.php index 17859ac7..5e22b434 100644 --- a/app/Services/Order.php +++ b/app/Services/Order.php @@ -74,7 +74,7 @@ class Order public function getOrderTotalWithBookingFee($currencyFormatted = false) { if ($currencyFormatted == false ) { - return number_format($this->grandTotal, 2, '.', ''); + return number_format($this->orderTotalWithBookingFee, 2, '.', ''); } return money($this->orderTotalWithBookingFee, $this->event->currency); @@ -87,7 +87,7 @@ class Order public function getTaxAmount($currencyFormatted = false) { if ($currencyFormatted == false ) { - return number_format($this->grandTotal, 2, '.', ''); + return number_format($this->taxAmount, 2, '.', ''); } return money($this->taxAmount, $this->event->currency); From 9b5d61ffdd3b06a557951287a4e1a4adece53c44 Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Wed, 11 Jul 2018 13:47:41 +0200 Subject: [PATCH 08/12] Added Tax to emails and various views 1) When Taxed is charged display it on the various views where tax should be displayed. Orders Listing Page, Orders Summary page. 2) Use the Order service to display correct values in emails and views. --- .../Controllers/EventOrdersController.php | 9 +++++- app/Mailers/OrderMailer.php | 8 +++-- app/Models/Order.php | 2 +- .../ManageEvent/Modals/ManageOrder.blade.php | 32 ++++++++++++++++++- resources/views/ManageEvent/Orders.blade.php | 2 +- .../en/Emails/OrderNotification.blade.php | 32 ++++++++++++++++++- .../TicketMailer/SendOrderTickets.blade.php | 2 +- 7 files changed, 79 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/EventOrdersController.php b/app/Http/Controllers/EventOrdersController.php index f306196c..fe383bb1 100644 --- a/app/Http/Controllers/EventOrdersController.php +++ b/app/Http/Controllers/EventOrdersController.php @@ -8,6 +8,7 @@ use App\Models\Attendee; use App\Models\Event; use App\Models\EventStats; use App\Models\Order; +use App\Services\Order as OrderService; use DB; use Excel; use Illuminate\Http\Request; @@ -78,8 +79,14 @@ class EventOrdersController extends MyBaseController */ public function manageOrder(Request $request, $order_id) { + $order = Order::scope()->find($order_id); + + $orderService = new OrderService($order->amount, $order->booking_fee, $order->event); + $orderService->calculateFinalCosts(); + $data = [ - 'order' => Order::scope()->find($order_id), + 'order' => $order, + 'orderService' => $orderService ]; return view('ManageEvent.Modals.ManageOrder', $data); diff --git a/app/Mailers/OrderMailer.php b/app/Mailers/OrderMailer.php index 23d69cb1..183ba364 100644 --- a/app/Mailers/OrderMailer.php +++ b/app/Mailers/OrderMailer.php @@ -11,8 +11,12 @@ class OrderMailer { public function sendOrderNotification(Order $order) { + $orderService = new OrderService($order->amount, $order->booking_fee, $order->event); + $orderService->calculateFinalCosts(); + $data = [ - 'order' => $order + 'order' => $order, + 'orderService' => $orderService ]; Mail::send('Emails.OrderNotification', $data, function ($message) use ($order) { @@ -22,7 +26,7 @@ class OrderMailer } - public function sendOrderTickets($order) + public function sendOrderTickets(Order $order) { $orderService = new OrderService($order->amount, $order->booking_fee, $order->event); $orderService->calculateFinalCosts(); diff --git a/app/Models/Order.php b/app/Models/Order.php index 188b40e1..ae6924eb 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -106,7 +106,7 @@ class Order extends MyBaseModel */ public function getOrganiserAmountAttribute() { - return $this->amount + $this->organiser_booking_fee; + return $this->amount + $this->organiser_booking_fee + $this->taxamt; } /** diff --git a/resources/views/ManageEvent/Modals/ManageOrder.blade.php b/resources/views/ManageEvent/Modals/ManageOrder.blade.php index 4676e7ef..ea3295d7 100644 --- a/resources/views/ManageEvent/Modals/ManageOrder.blade.php +++ b/resources/views/ManageEvent/Modals/ManageOrder.blade.php @@ -48,7 +48,7 @@
- @lang("ManageEvent.amount")
{{money($order->total_amount, $order->event->currency)}} + @lang("ManageEvent.amount")
{{ $orderService->getGrandTotal(true) }}
@@ -143,6 +143,36 @@ {{money($order->total_amount, $order->event->currency)}} + @if($order->event->organiser->charge_tax) + + + + + + + + + {{$order->event->organiser->tax_name}} + + + {{ $orderService->getTaxAmount(true) }} + + + @endif + + + + + + + + + Total + + + {{ $orderService->getGrandTotal(true) }} + + diff --git a/resources/views/ManageEvent/Orders.blade.php b/resources/views/ManageEvent/Orders.blade.php index bd56d764..8520f929 100644 --- a/resources/views/ManageEvent/Orders.blade.php +++ b/resources/views/ManageEvent/Orders.blade.php @@ -115,7 +115,7 @@ - {{money($order->amount + $order->organiser_booking_fee, $event->currency)}} + {{money($order->amount + $order->organiser_booking_fee + $order->taxamt, $event->currency)}} @if($order->is_refunded || $order->is_partially_refunded) @endif diff --git a/resources/views/en/Emails/OrderNotification.blade.php b/resources/views/en/Emails/OrderNotification.blade.php index c4fb801c..834002bc 100644 --- a/resources/views/en/Emails/OrderNotification.blade.php +++ b/resources/views/en/Emails/OrderNotification.blade.php @@ -85,7 +85,37 @@ Order Email: {{$order->email}}
Sub Total - {{money($order->total_amount, $order->event->currency)}} + {{$orderService->getOrderTotalWithBookingFee(true)}} + + + @if($order->event->organiser->charge_tax == 1) + + + + + + + + + {{$order->event->organiser->tax_name}} + + + {{$orderService->getTaxAmount(true)}} + + + @endif + + + + + + + + + Total + + + {{$orderService->getGrandTotal(true)}} diff --git a/resources/views/en/Mailers/TicketMailer/SendOrderTickets.blade.php b/resources/views/en/Mailers/TicketMailer/SendOrderTickets.blade.php index 6fd0acdc..6a6b3b4e 100644 --- a/resources/views/en/Mailers/TicketMailer/SendOrderTickets.blade.php +++ b/resources/views/en/Mailers/TicketMailer/SendOrderTickets.blade.php @@ -83,7 +83,7 @@ Order Email: {{$order->email}}
Sub Total - {{money($order->amount + $order->order_fee, $order->event->currency)}} + {{$orderService->getOrderTotalWithBookingFee(true)}} @if($order->event->organiser->charge_tax == 1) From 1c7c8be8f7e2e3b5840f7ffde44d9fed7ff47ed8 Mon Sep 17 00:00:00 2001 From: Jeremy Quinton Date: Wed, 11 Jul 2018 19:51:11 +0200 Subject: [PATCH 09/12] Finalised Charging V.A.T 1) Added Javascript partial so display and hide of the Charge Tax functionality can be shared. 2) Moved @yield head for the the master without menus layout to the correct place. Using jQuery functionality @head anywhere wouldn't work as the library was included afterwards. 3) Moved the question for organisers about Tax and the labels for tax fields to the language file. --- app/Http/Controllers/OrganiserController.php | 6 ++-- .../OrganiserCustomizeController.php | 6 ++++ resources/lang/en/Organiser.php | 6 ++++ resources/lang/en/basic.php | 1 + .../ManageOrganiser/CreateOrganiser.blade.php | 16 +++++---- .../views/ManageOrganiser/Customize.blade.php | 35 +++++-------------- .../OrganiserCreateAndEditJS.blade.php | 17 +++++++++ .../Layouts/MasterWithoutMenus.blade.php | 4 +-- 8 files changed, 54 insertions(+), 37 deletions(-) create mode 100644 resources/views/ManageOrganiser/Partials/OrganiserCreateAndEditJS.blade.php diff --git a/app/Http/Controllers/OrganiserController.php b/app/Http/Controllers/OrganiserController.php index fa64af95..fb5db358 100644 --- a/app/Http/Controllers/OrganiserController.php +++ b/app/Http/Controllers/OrganiserController.php @@ -41,10 +41,10 @@ class OrganiserController extends MyBaseController $organiser = Organiser::createNew(false, false, true); $chargeTax = $request->get('charge_tax'); - - if ($chargeTax == 'Yes') { + if ($chargeTax == 1) { $organiser->addExtraValidationRules(); } + if (!$organiser->validate($request->all())) { return response()->json([ 'status' => 'error', @@ -62,7 +62,7 @@ class OrganiserController extends MyBaseController $organiser->tax_name = $request->get('tax_name'); $organiser->tax_value = round($request->get('tax_value'),2); $organiser->tax_id = $request->get('tax_id'); - $organiser->charge_tax = ($chargeTax == 'Yes') ? 1 : 0; + $organiser->charge_tax = ($chargeTax == 1) ? 1 : 0; if ($request->hasFile('organiser_logo')) { $organiser->setLogo($request->file('organiser_logo')); diff --git a/app/Http/Controllers/OrganiserCustomizeController.php b/app/Http/Controllers/OrganiserCustomizeController.php index d35a16ff..943378f4 100644 --- a/app/Http/Controllers/OrganiserCustomizeController.php +++ b/app/Http/Controllers/OrganiserCustomizeController.php @@ -36,6 +36,11 @@ class OrganiserCustomizeController extends MyBaseController { $organiser = Organiser::scope()->find($organiser_id); + $chargeTax = $request->get('charge_tax'); + if ($chargeTax == 1) { + $organiser->addExtraValidationRules(); + } + if (!$organiser->validate($request->all())) { return response()->json([ 'status' => 'error', @@ -50,6 +55,7 @@ class OrganiserCustomizeController extends MyBaseController $organiser->enable_organiser_page = $request->get('enable_organiser_page'); $organiser->facebook = $request->get('facebook'); $organiser->twitter = $request->get('twitter'); + $organiser->tax_name = $request->get('tax_name'); $organiser->tax_value = $request->get('tax_value'); $organiser->tax_id = $request->get('tax_id'); diff --git a/resources/lang/en/Organiser.php b/resources/lang/en/Organiser.php index 5fed9d54..891056f3 100644 --- a/resources/lang/en/Organiser.php +++ b/resources/lang/en/Organiser.php @@ -58,6 +58,12 @@ return array ( 'organiser_twitter_placeholder' => 'E.g http://www.twitter.com/MyTwitterPage', 'organiser_username_facebook_placeholder' => 'MyFacebookPage', 'organiser_username_twitter_placeholder' => 'MyTwitterPage', + 'organiser_tax_prompt' => 'Do you want to charge tax as your events?', + 'organiser_tax_id' => 'Tax ID', + 'organiser_tax_name' => 'Tax Name', + 'organiser_tax_value' => 'Tax Value', + 'yes' => 'Yes', + 'no' => 'No', 'sales_volume' => 'Sales Volume', 'select_an_organiser' => 'Select An Organiser', 'select_organiser' => 'Select Organiser', diff --git a/resources/lang/en/basic.php b/resources/lang/en/basic.php index be06d576..3c88036e 100644 --- a/resources/lang/en/basic.php +++ b/resources/lang/en/basic.php @@ -47,6 +47,7 @@ return array ( 'total' => 'total', 'whoops' => 'Whoops!', 'yes' => 'Yes', + 'no' => 'No', /* * Lines below will turn obsolete in localization helper, it is declared in app/Helpers/macros. * If you run it, it will break file input fields. diff --git a/resources/views/ManageOrganiser/CreateOrganiser.blade.php b/resources/views/ManageOrganiser/CreateOrganiser.blade.php index a3d1e0c1..21fed83c 100644 --- a/resources/views/ManageOrganiser/CreateOrganiser.blade.php +++ b/resources/views/ManageOrganiser/CreateOrganiser.blade.php @@ -12,6 +12,10 @@ text-shadow: none !important;; } + + @stop @section('content') @@ -62,31 +66,31 @@ )) !!}
-

Do you want to Charge Tax at your Events?

+

{!! trans("Organiser.organiser_tax_prompt") !!}

{!! Form::label('Yes', 'Yes', array('class'=>'control-label', 'id' => 'charge_yes')) !!} - {{ Form::radio('charge_tax', 'Yes' , false) }} + {{ Form::radio('charge_tax', '1' , false) }} {!! Form::label('No', 'No', array('class'=>'control-label','id' => 'charge_no')) !!} - {{ Form::radio('charge_tax', 'No' , true) }} + {{ Form::radio('charge_tax', '0' , true) }}
- {!! Form::label('tax_id', 'Tax ID', array('class'=>'control-label required')) !!} + {!! Form::label('tax_id', trans("Organiser.organiser_tax_id"), array('class'=>'control-label required')) !!} {!! Form::text('tax_id', Input::old('tax_id'), array('class'=>'form-control', 'placeholder'=>'Tax ID')) !!}
- {!! Form::label('tax_name', 'Tax name', array('class'=>'control-label required')) !!} + {!! Form::label('tax_name', trans("Organiser.organiser_tax_name"), array('class'=>'control-label required')) !!} {!! Form::text('tax_name', Input::old('tax_name'), array('class'=>'form-control', 'placeholder'=>'Tax name')) !!}
- {!! Form::label('tax_value', 'Tax value', array('class'=>'control-label required')) !!} + {!! Form::label('tax_value', trans("Organiser.organiser_tax_value"), array('class'=>'control-label required')) !!} {!! Form::text('tax_value', Input::old('tax_value'), array('class'=>'form-control', 'placeholder'=>'Tax Value')) !!}
diff --git a/resources/views/ManageOrganiser/Customize.blade.php b/resources/views/ManageOrganiser/Customize.blade.php index 90c52f94..2ec56abe 100644 --- a/resources/views/ManageOrganiser/Customize.blade.php +++ b/resources/views/ManageOrganiser/Customize.blade.php @@ -31,24 +31,7 @@ }); - $(document).ready(function(){ - var charge_tax = $("input[type=radio][name='charge_tax']:checked").val(); - if (charge_tax == 1) { - $('#tax_fields').show(); - } else { - $('#tax_fields').hide(); - } - - $('input[type=radio][name=charge_tax]').change(function() { - if (this.value == 1) { - $('#tax_fields').show(); - } - else { - $('#tax_fields').hide(); - } - }); - }); - + @include('ManageOrganiser.Partials.OrganiserCreateAndEditJS') @stop @@ -115,31 +98,31 @@
-

Do you want to Charge Tax at your Events?

- - charge_tax == 1 ? 'checked' : '' }}> - - charge_tax == 0 ? 'checked' : '' }}> +

{!! trans("Organiser.organiser_tax_prompt") !!}

+ + charge_tax == 1 ? 'checked' : '' }}> + + charge_tax == 0 ? 'checked' : '' }}>
- {!! Form::label('tax_id', 'Tax ID', array('class'=>'control-label required')) !!} + {!! Form::label('tax_id', trans("Organiser.organiser_tax_id"), array('class'=>'control-label required')) !!} {!! Form::text('tax_id', Input::old('tax_id'), array('class'=>'form-control', 'placeholder'=>'Tax ID')) !!}
- {!! Form::label('tax_name', 'Tax name', array('class'=>'control-label required')) !!} + {!! Form::label('tax_name', trans("Organiser.organiser_tax_name"), array('class'=>'control-label required')) !!} {!! Form::text('tax_name', Input::old('tax_name'), array('class'=>'form-control', 'placeholder'=>'Tax name')) !!}
- {!! Form::label('tax_value', 'Tax value', array('class'=>'control-label required')) !!} + {!! Form::label('tax_value', trans("Organiser.organiser_tax_value"), array('class'=>'control-label required')) !!} {!! Form::text('tax_value', Input::old('tax_value'), array('class'=>'form-control', 'placeholder'=>'Tax Value')) !!}
diff --git a/resources/views/ManageOrganiser/Partials/OrganiserCreateAndEditJS.blade.php b/resources/views/ManageOrganiser/Partials/OrganiserCreateAndEditJS.blade.php new file mode 100644 index 00000000..01737a17 --- /dev/null +++ b/resources/views/ManageOrganiser/Partials/OrganiserCreateAndEditJS.blade.php @@ -0,0 +1,17 @@ +$(document).ready(function(){ + var charge_tax = $("input[type=radio][name='charge_tax']:checked").val(); + if (charge_tax == 1) { + $('#tax_fields').show(); + } else { + $('#tax_fields').hide(); + } + + $('input[type=radio][name=charge_tax]').change(function() { + if (this.value == 1) { + $('#tax_fields').show(); + } + else { + $('#tax_fields').hide(); + } + }); +}); \ No newline at end of file diff --git a/resources/views/Shared/Layouts/MasterWithoutMenus.blade.php b/resources/views/Shared/Layouts/MasterWithoutMenus.blade.php index 48ba8c5a..9bd98d6b 100644 --- a/resources/views/Shared/Layouts/MasterWithoutMenus.blade.php +++ b/resources/views/Shared/Layouts/MasterWithoutMenus.blade.php @@ -7,8 +7,6 @@ @include('Shared.Partials.GlobalMeta') - @yield('head') - {!! HTML::script('vendor/jquery/dist/jquery.min.js') !!} @@ -17,6 +15,8 @@ {!!HTML::style('assets/stylesheet/application.css')!!} + @yield('head') +