Merge pull request #380 from samdb/master

Addition of tax options
This commit is contained in:
Sam Bell 2018-06-04 17:03:47 +01:00 committed by GitHub
commit d2180ea92b
21 changed files with 300 additions and 16 deletions

View File

@ -324,13 +324,17 @@ 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->taxvalue) / 100;
$grand_total = $tax_amt + $grand_total;
$transaction_data = [
'amount' => ($ticket_order['order_total'] + $ticket_order['organiser_booking_fee']),
'amount' => $grand_total,
'currency' => $event->currency->code,
'description' => 'Order for customer: ' . $request->get('order_email'),
];
switch ($ticket_order['payment_gateway']->id) {
case config('attendize.payment_gateway_paypal'):
case config('attendize.payment_gateway_coinbase'):
@ -379,7 +383,6 @@ class EventCheckoutController extends Controller
break;
}
$transaction = $gateway->purchase($transaction_data);
$response = $transaction->send();
@ -527,6 +530,12 @@ class EventCheckoutController extends Controller
$order->account_id = $event->account->id;
$order->event_id = $ticket_order['event_id'];
$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->taxvalue) / 100;
$order->taxamt = $tax_amt;
$order->save();
/*

View File

@ -53,6 +53,13 @@ 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');
if ($request->hasFile('organiser_logo')) {
$organiser->setLogo($request->file('organiser_logo'));

View File

@ -50,6 +50,9 @@ 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');
if ($request->get('remove_current_image') == '1') {
$organiser->logo_path = '';

View File

@ -86,7 +86,7 @@ class MyBaseModel extends \Illuminate\Database\Eloquent\Model
*/
public function validate($data)
{
$v = Validator::make($data, $this->rules, $this->messages);
$v = Validator::make($data, $this->rules, $this->messages, $this->attributes);
if ($v->fails()) {
$this->errors = $v->messages();

View File

@ -16,9 +16,23 @@ 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'],
];
/**
* The validation rules for the model.
*
* @var array $attributes
*/
protected $attributes = [
'taxname' => 'Tax Name',
'taxvalue' => 'Tax Rate',
'taxid' => 'Tax ID',
];
/**
* The validation error messages for the model.
*
@ -148,3 +162,4 @@ class Organiser extends MyBaseModel
}
}
}

View File

@ -65,6 +65,7 @@ return [
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'port' => env('DB_PORT'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => env('DB_PREFIX'),

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTaxToOrganizers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('organisers', function($table) {
$table->string('taxname',15);
$table->float('taxvalue');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('organisers', function($table) {
$table->dropColumn('taxname');
$table->dropColumn('taxvalue');
});
}
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTaxamtToOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('orders', function($table) {
$table->float('taxamt');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('orders', function($table) {
$table->dropColumn('taxamt');
});
}
}

View File

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddTaxidToOrganisers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('organisers', function($table) {
$table->string('taxid',100);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('organisers', function($table) {
$table->dropColumn('taxid');
});
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -85,6 +85,12 @@ h6 > small {
.text-muted {
color: darken(@gray, 30%) !important;
}
/*
* smaller
*/
.text-smaller {
font-size:0.8em;
}
/*
* primary
*/

View File

@ -76,16 +76,44 @@ Order Email: <b>{{$order->email}}</b><br>
<td>
</td>
<td>
<b>Sub Total</b>
Sub Total
</td>
<td colspan="2">
{{money($order->amount + $order->order_fee, $order->event->currency)}}
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
{{$event->organiser->taxname}}
</td>
<td colspan="2">
{{money(($order->amount*($event->organiser->taxvalue)/100), $event->currency)}}
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
<b>Total</b>
</td>
<td colspan="2">
{{money($order->amount+($order->amount*($event->organiser->taxvalue)/100), $event->currency)}}
</td>
</tr>
</table>
<br><br>
</div>
<br><br>
Thank you
@stop
@stop

View File

@ -0,0 +1,10 @@
@extends('Emails.Layouts.Master')
@section('message_content')
Hello,<br><br>
Your email was sent successfully.
<br><br>
Thank you
@stop

View File

@ -65,6 +65,30 @@
'rows' => 4
)) !!}
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{!! Form::label('taxid', 'Tax ID', array('class'=>'control-label required')) !!}
{!! Form::text('taxid', Input::old('taxid'), array('class'=>'form-control', 'placeholder'=>'Tax ID')) !!}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{!! Form::label('taxname', 'Tax name', array('class'=>'control-label required')) !!}
{!! Form::text('taxname', Input::old('taxname'), array('class'=>'form-control', 'placeholder'=>'Tax name')) !!}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{!! Form::label('taxvalue', 'Tax value', array('class'=>'control-label required')) !!}
{!! Form::text('taxvalue', Input::old('taxvalue'), array('class'=>'form-control', 'placeholder'=>'Tax Value')) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
@ -108,4 +132,3 @@
</div>
</div>
@stop

View File

@ -93,6 +93,28 @@
'rows' => 4
)) !!}
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
{!! Form::label('taxid', 'Tax ID', array('class'=>'control-label required')) !!}
{!! Form::text('taxid', Input::old('taxid'), array('class'=>'form-control', 'placeholder'=>'Tax ID')) !!}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{!! Form::label('taxname', 'Tax name', array('class'=>'control-label required')) !!}
{!! Form::text('taxname', Input::old('taxname'), array('class'=>'form-control', 'placeholder'=>'Tax name')) !!}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{!! Form::label('taxvalue', 'Tax value', array('class'=>'control-label required')) !!}
{!! Form::text('taxvalue', Input::old('taxvalue'), array('class'=>'form-control', 'placeholder'=>'Tax Value')) !!}
</div>
</div>
</div>
<div class="form-group">
{!! Form::label('google_analytics_code', 'Google Analytics Code', array('class'=>'control-label')) !!}
{!! Form::text('google_analytics_code', Input::old('google_analytics_code'),
@ -213,5 +235,3 @@
</div>
</div>
@stop

View File

@ -2,4 +2,5 @@
{{--See https://www.attendize.com/licence.php for more information.--}}
<div class="powered_by_embedded">
@include('Shared.Partials.PoweredBy')
</div>
</div>
<script type="text/javascript" src="/assets/javascript/iframeSizer.contentWindow.min.js"></script>

View File

@ -32,9 +32,27 @@
</div>
@if($order_total > 0)
<div class="panel-footer">
@php
$grand_total = $order_total + $total_booking_fee;
@endphp
<h5>
Total: <span style="float: right;"><b>{{ money($order_total + $total_booking_fee,$event->currency) }}</b></span>
Total: <span style="float: right;"><b>{{ money($grand_total,$event->currency) }}</b></span>
</h5>
@if($event->organiser->taxname && $event->organiser->taxvalue && $event->organiser->taxvalue > 0)
<h5>
{{ $event->organiser->taxname }} ({{ $event->organiser->taxvalue }}%):
@php
// Calculating grand total including tax
$tax_amt = ($grand_total * $event->organiser->taxvalue) / 100;
$grand_total = $tax_amt + $grand_total;
@endphp
<span style="float: right;"><b>{{ money($tax_amt,$event->currency) }}</b></span>
</h5>
<h5>
<strong>Grand Total:</strong>
<span style="float: right;"><b>{{ money($grand_total,$event->currency) }}</b></span>
</h5>
@endif
</div>
@endif

View File

@ -32,7 +32,7 @@
{{$ticket->description}}
</p>
</td>
<td style="width:180px; text-align: right;">
<td style="width:200px; text-align: right;">
<div class="ticket-pricing" style="margin-right: 20px;">
@if($ticket->is_free)
FREE
@ -42,6 +42,7 @@
$is_free_event = false;
?>
<span title='{{money($ticket->price, $event->currency)}} Ticket Price + {{money($ticket->total_booking_fee, $event->currency)}} Booking Fees'>{{money($ticket->total_price, $event->currency)}} </span>
<span class="tax-amount text-muted text-smaller">{{ ($event->organiser->taxname && $event->organiser->taxvalue) ? '(+'.money(($ticket->total_price*($event->organiser->taxvalue)/100), $event->currency).' '.$event->organiser->taxname.')' : '' }}</span>
<meta property="priceCurrency"
content="{{ $event->currency->code }}">
<meta property="price"
@ -127,4 +128,4 @@
@endif
</section>
</section>

View File

@ -82,6 +82,7 @@
<div class="col-sm-4 col-xs-6">
<b>Amount</b><br> {{$order->event->currency_symbol}}{{number_format($order->total_amount,2)}}
<small>{{ ($event->organiser->taxname && $event->organiser->taxvalue) ? '(+'.money(($order->total_amount*($event->organiser->taxvalue)/100), $event->currency).' '.$event->organiser->taxname.')' : '' }}</small>
</div>
<div class="col-sm-4 col-xs-6">
@ -186,6 +187,34 @@
{{money($order->total_amount, $order->event->currency)}}
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
{{$event->organiser->taxname}}
</td>
<td colspan="2">
{{money(($order->total_amount*($event->organiser->taxvalue)/100), $event->currency)}}
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
<b>Total</b>
</td>
<td colspan="2">
{{money($order->total_amount+($order->total_amount*($event->organiser->taxvalue)/100), $event->currency)}}
</td>
</tr>
@if($order->is_refunded || $order->is_partially_refunded)
<tr>
<td>

View File

@ -85,7 +85,14 @@
<h4>Attendee Ref.</h4>
{{$attendee->reference}}
<h4>Price</h4>
{{money($attendee->ticket->total_price, $order->event->currency)}} (inc. {{money($attendee->ticket->total_booking_fee, $order->event->currency)}} Fees)
@php
// Calculating grand total including tax
$grand_total = $attendee->ticket->total_price;
$tax_amt = ($grand_total * $event->organiser->taxvalue) / 100;
$grand_total = $tax_amt + $grand_total;
@endphp
{{money($grand_total, $order->event->currency)}} (inc. {{money($attendee->ticket->total_booking_fee, $order->event->currency)}} Fees) (inc. {{money($tax_amt, $order->event->currency)}} {{$event->organiser->taxname}})
<br><br>{{$event->organiser->taxname}} ID: {{ $event->organiser->taxid }}
</div>
<div class="barcode">
@ -108,3 +115,4 @@
</div>
</body>
</html>