Multible Tax files for Items
This commit is contained in:
parent
42d5690a57
commit
983015509a
@ -345,22 +345,6 @@ class Items extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $tax_row => $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'GST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($sub_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
$sub_total += $multiple_tax_amount;
|
||||
|
||||
$taxes['multiple-tax-' . $tax_row . '-total'] = money($multiple_tax_amount, $currency_code, true)->format();
|
||||
}
|
||||
}
|
||||
|
||||
$json->items = $items;
|
||||
|
||||
$json->sub_total = money($sub_total, $currency_code, true)->format();
|
||||
@ -378,32 +362,10 @@ class Items extends Controller
|
||||
$sub_total = $sub_total - ($sub_total * ($discount / 100));
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $tax_row => $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'PST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($sub_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
$tax_total += $multiple_tax_amount;
|
||||
|
||||
$taxes['multiple-tax-' . $tax_row . '-total'] = money($multiple_tax_amount, $currency_code, true)->format();
|
||||
}
|
||||
}
|
||||
|
||||
$grand_total = $sub_total + $tax_total;
|
||||
|
||||
$json->grand_total = money($grand_total, $currency_code, true)->format();
|
||||
|
||||
$json->multible_taxes = false;
|
||||
|
||||
if (!empty($taxes)) {
|
||||
$json->multible_taxes = $taxes;
|
||||
}
|
||||
|
||||
// Get currency object
|
||||
$currency = Currency::where('code', $currency_code)->first();
|
||||
|
||||
|
@ -211,10 +211,10 @@ class Bills extends Controller
|
||||
|
||||
// Set taxes
|
||||
if (isset($tax_object)) {
|
||||
if (isset($taxes['VAT']) && array_key_exists($tax_object->id, $taxes['VAT'])) {
|
||||
$taxes['VAT'][$tax_object->id]['amount'] += $tax;
|
||||
if (isset($taxes) && array_key_exists($tax_object->id, $taxes)) {
|
||||
$taxes[$tax_object->id]['amount'] += $tax;
|
||||
} else {
|
||||
$taxes['VAT'][$tax_object->id] = [
|
||||
$taxes[$tax_object->id] = [
|
||||
'name' => $tax_object->name,
|
||||
'amount' => $tax
|
||||
];
|
||||
@ -229,30 +229,6 @@ class Bills extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'GST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($sub_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
if (isset($taxes['GST']) && array_key_exists($multible_tax_object->id, $taxes['GST'])) {
|
||||
$taxes['GST'][$multible_tax_object->id]['amount'] += $multiple_tax_amount;
|
||||
} else {
|
||||
$taxes['GST'][$multible_tax_object->id] = [
|
||||
'id' => $multible_tax_object->id,
|
||||
'name' => $multible_tax_object->name,
|
||||
'amount' => $multiple_tax_amount
|
||||
];
|
||||
}
|
||||
|
||||
$sub_total += $multiple_tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
$s_total = $sub_total;
|
||||
|
||||
// Apply discount to total
|
||||
@ -262,30 +238,6 @@ class Bills extends Controller
|
||||
$s_total = $s_total - $s_discount;
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'PST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($s_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
if (isset($taxes['PST']) && array_key_exists($multible_tax_object->id, $taxes['PST'])) {
|
||||
$taxes['PST'][$multible_tax_object->id]['amount'] += $multiple_tax_amount;
|
||||
} else {
|
||||
$taxes['PST'][$multible_tax_object->id] = [
|
||||
'id' => $multible_tax_object->id,
|
||||
'name' => $multible_tax_object->name,
|
||||
'amount' => $multiple_tax_amount
|
||||
];
|
||||
}
|
||||
|
||||
$tax_total += $multiple_tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
$amount = $s_total + $tax_total;
|
||||
|
||||
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
||||
@ -422,6 +374,7 @@ class Bills extends Controller
|
||||
public function update(Bill $bill, Request $request)
|
||||
{
|
||||
$taxes = [];
|
||||
|
||||
$tax_total = 0;
|
||||
$sub_total = 0;
|
||||
$discount_total = 0;
|
||||
@ -470,10 +423,10 @@ class Bills extends Controller
|
||||
$bill_item['total'] = (double) $item['price'] * (double) $item['quantity'];
|
||||
|
||||
if (isset($tax_object)) {
|
||||
if (isset($taxes['VAT']) && array_key_exists($tax_object->id, $taxes['VAT'])) {
|
||||
$taxes['VAT'][$tax_object->id]['amount'] += $tax;
|
||||
if (isset($taxes) && array_key_exists($tax_object->id, $taxes)) {
|
||||
$taxes[$tax_object->id]['amount'] += $tax;
|
||||
} else {
|
||||
$taxes['VAT'][$tax_object->id] = [
|
||||
$taxes[$tax_object->id] = [
|
||||
'name' => $tax_object->name,
|
||||
'amount' => $tax
|
||||
];
|
||||
@ -487,30 +440,6 @@ class Bills extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'GST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($sub_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
if (isset($taxes['GST']) && array_key_exists($multible_tax_object->id, $taxes['GST'])) {
|
||||
$taxes['GST'][$multible_tax_object->id]['amount'] += $multiple_tax_amount;
|
||||
} else {
|
||||
$taxes['GST'][$multible_tax_object->id] = [
|
||||
'id' => $multible_tax_object->id,
|
||||
'name' => $multible_tax_object->name,
|
||||
'amount' => $multiple_tax_amount
|
||||
];
|
||||
}
|
||||
|
||||
$sub_total += $multiple_tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
$s_total = $sub_total;
|
||||
|
||||
// Apply discount to total
|
||||
@ -520,30 +449,6 @@ class Bills extends Controller
|
||||
$s_total = $s_total - $s_discount;
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'PST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($s_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
if (isset($taxes['PST']) && array_key_exists($multible_tax_object->id, $taxes['PST'])) {
|
||||
$taxes['PST'][$multible_tax_object->id]['amount'] += $multiple_tax_amount;
|
||||
} else {
|
||||
$taxes['PST'][$multible_tax_object->id] = [
|
||||
'id' => $multible_tax_object->id,
|
||||
'name' => $multible_tax_object->name,
|
||||
'amount' => $multiple_tax_amount
|
||||
];
|
||||
}
|
||||
|
||||
$tax_total += $multiple_tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
$amount = $s_total + $tax_total;
|
||||
|
||||
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
||||
@ -892,21 +797,6 @@ class Bills extends Controller
|
||||
{
|
||||
$sort_order = 1;
|
||||
|
||||
if (isset($taxes['GST'])) {
|
||||
foreach ($taxes['GST'] as $tax) {
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'gst-' . $tax['id'],
|
||||
'name' => $tax['name'],
|
||||
'amount' => $tax['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
|
||||
$sort_order++;
|
||||
}
|
||||
}
|
||||
|
||||
// Added bill sub total
|
||||
BillTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
@ -936,24 +826,9 @@ class Bills extends Controller
|
||||
$sort_order++;
|
||||
}
|
||||
|
||||
if (isset($taxes['PST'])) {
|
||||
foreach ($taxes['PST'] as $tax) {
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'pst-' . $tax['id'],
|
||||
'name' => $tax['name'],
|
||||
'amount' => $tax['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
|
||||
$sort_order++;
|
||||
}
|
||||
}
|
||||
|
||||
// Added bill taxes
|
||||
if (isset($taxes['VAT'])) {
|
||||
foreach ($taxes['VAT'] as $tax) {
|
||||
if (isset($taxes)) {
|
||||
foreach ($taxes as $tax) {
|
||||
BillTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'bill_id' => $bill->id,
|
||||
|
@ -246,10 +246,10 @@ class Invoices extends Controller
|
||||
|
||||
// Set taxes
|
||||
if (isset($tax_object)) {
|
||||
if (isset($taxes['VAT']) && array_key_exists($tax_object->id, $taxes['VAT'])) {
|
||||
$taxes['VAT'][$tax_object->id]['amount'] += $tax;
|
||||
if (isset($taxes) && array_key_exists($tax_object->id, $taxes)) {
|
||||
$taxes[$tax_object->id]['amount'] += $tax;
|
||||
} else {
|
||||
$taxes['VAT'][$tax_object->id] = [
|
||||
$taxes[$tax_object->id] = [
|
||||
'name' => $tax_object->name,
|
||||
'amount' => $tax
|
||||
];
|
||||
@ -264,30 +264,6 @@ class Invoices extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'GST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($sub_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
if (isset($taxes['GST']) && array_key_exists($multible_tax_object->id, $taxes['GST'])) {
|
||||
$taxes['GST'][$multible_tax_object->id]['amount'] += $multiple_tax_amount;
|
||||
} else {
|
||||
$taxes['GST'][$multible_tax_object->id] = [
|
||||
'id' => $multible_tax_object->id,
|
||||
'name' => $multible_tax_object->name,
|
||||
'amount' => $multiple_tax_amount
|
||||
];
|
||||
}
|
||||
|
||||
$sub_total += $multiple_tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
$s_total = $sub_total;
|
||||
|
||||
// Apply discount to total
|
||||
@ -297,30 +273,6 @@ class Invoices extends Controller
|
||||
$s_total = $s_total - $s_discount;
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'PST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($s_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
if (isset($taxes['PST']) && array_key_exists($multible_tax_object->id, $taxes['PST'])) {
|
||||
$taxes['PST'][$multible_tax_object->id]['amount'] += $multiple_tax_amount;
|
||||
} else {
|
||||
$taxes['PST'][$multible_tax_object->id] = [
|
||||
'id' => $multible_tax_object->id,
|
||||
'name' => $multible_tax_object->name,
|
||||
'amount' => $multiple_tax_amount
|
||||
];
|
||||
}
|
||||
|
||||
$tax_total += $multiple_tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
$amount = $s_total + $tax_total;
|
||||
|
||||
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
||||
@ -463,6 +415,7 @@ class Invoices extends Controller
|
||||
public function update(Invoice $invoice, Request $request)
|
||||
{
|
||||
$taxes = [];
|
||||
|
||||
$tax_total = 0;
|
||||
$sub_total = 0;
|
||||
$discount_total = 0;
|
||||
@ -511,10 +464,10 @@ class Invoices extends Controller
|
||||
$invoice_item['total'] = (double) $item['price'] * (double) $item['quantity'];
|
||||
|
||||
if (isset($tax_object)) {
|
||||
if (isset($taxes['VAT']) && array_key_exists($tax_object->id, $taxes['VAT'])) {
|
||||
$taxes['VAT'][$tax_object->id]['amount'] += $tax;
|
||||
if (isset($taxes) && array_key_exists($tax_object->id, $taxes)) {
|
||||
$taxes[$tax_object->id]['amount'] += $tax;
|
||||
} else {
|
||||
$taxes['VAT'][$tax_object->id] = [
|
||||
$taxes[$tax_object->id] = [
|
||||
'name' => $tax_object->name,
|
||||
'amount' => $tax
|
||||
];
|
||||
@ -528,30 +481,6 @@ class Invoices extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'GST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($sub_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
if (isset($taxes['GST']) && array_key_exists($multible_tax_object->id, $taxes['GST'])) {
|
||||
$taxes['GST'][$multible_tax_object->id]['amount'] += $multiple_tax_amount;
|
||||
} else {
|
||||
$taxes['GST'][$multible_tax_object->id] = [
|
||||
'id' => $multible_tax_object->id,
|
||||
'name' => $multible_tax_object->name,
|
||||
'amount' => $multiple_tax_amount
|
||||
];
|
||||
}
|
||||
|
||||
$sub_total += $multiple_tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
$s_total = $sub_total;
|
||||
|
||||
// Apply discount to total
|
||||
@ -561,30 +490,6 @@ class Invoices extends Controller
|
||||
$s_total = $s_total - $s_discount;
|
||||
}
|
||||
|
||||
if ($request['multiple_tax']) {
|
||||
foreach ($request['multiple_tax'] as $multiple_tax) {
|
||||
if ($multiple_tax['position'] != 'PST') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$multible_tax_object = Tax::find($multiple_tax['tax_id']);
|
||||
|
||||
$multiple_tax_amount = ($s_total / 100) * $multible_tax_object->rate;
|
||||
|
||||
if (isset($taxes['PST']) && array_key_exists($multible_tax_object->id, $taxes['PST'])) {
|
||||
$taxes['PST'][$multible_tax_object->id]['amount'] += $multiple_tax_amount;
|
||||
} else {
|
||||
$taxes['PST'][$multible_tax_object->id] = [
|
||||
'id' => $multible_tax_object->id,
|
||||
'name' => $multible_tax_object->name,
|
||||
'amount' => $multiple_tax_amount
|
||||
];
|
||||
}
|
||||
|
||||
$tax_total += $multiple_tax_amount;
|
||||
}
|
||||
}
|
||||
|
||||
$amount = $s_total + $tax_total;
|
||||
|
||||
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
||||
@ -1049,21 +954,6 @@ class Invoices extends Controller
|
||||
{
|
||||
$sort_order = 1;
|
||||
|
||||
if (isset($taxes['GST'])) {
|
||||
foreach ($taxes['GST'] as $tax) {
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'gst-' . $tax['id'],
|
||||
'name' => $tax['name'],
|
||||
'amount' => $tax['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
|
||||
$sort_order++;
|
||||
}
|
||||
}
|
||||
|
||||
// Added invoice sub total
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
@ -1093,24 +983,9 @@ class Invoices extends Controller
|
||||
$sort_order++;
|
||||
}
|
||||
|
||||
if (isset($taxes['PST'])) {
|
||||
foreach ($taxes['PST'] as $tax) {
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
'code' => 'pst-' . $tax['id'],
|
||||
'name' => $tax['name'],
|
||||
'amount' => $tax['amount'],
|
||||
'sort_order' => $sort_order,
|
||||
]);
|
||||
|
||||
$sort_order++;
|
||||
}
|
||||
}
|
||||
|
||||
// Added invoice taxes
|
||||
if (isset($taxes['VAT'])) {
|
||||
foreach ($taxes['VAT'] as $tax) {
|
||||
if (isset($taxes)) {
|
||||
foreach ($taxes as $tax) {
|
||||
InvoiceTotal::create([
|
||||
'company_id' => $request['company_id'],
|
||||
'invoice_id' => $invoice->id,
|
||||
|
63
app/Http/Controllers/Modals/Taxes.php
Normal file
63
app/Http/Controllers/Modals/Taxes.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Modals;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Setting\Tax as Request;
|
||||
use App\Models\Setting\Tax;
|
||||
|
||||
class Taxes extends Controller
|
||||
{
|
||||
/**
|
||||
* Instantiate a new controller instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-taxes')->only(['create', 'store']);
|
||||
$this->middleware('permission:read-settings-taxes')->only(['index', 'edit']);
|
||||
$this->middleware('permission:update-settings-taxes')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:delete-settings-taxes')->only('destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$html = view('modals.taxes.create')->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'message' => 'null',
|
||||
'html' => $html,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request['enabled'] = 1;
|
||||
|
||||
$tax = Tax::create($request->all());
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans_choice('general.taxes', 1)]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'error' => false,
|
||||
'data' => $tax,
|
||||
'message' => $message,
|
||||
'html' => 'null',
|
||||
]);
|
||||
}
|
||||
}
|
2
public/css/app.css
vendored
2
public/css/app.css
vendored
@ -744,4 +744,4 @@ input[type="number"] {
|
||||
.col-md-6.input-group-invoice-text {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
|
@ -39,14 +39,6 @@ return [
|
||||
'paid' => 'Paid',
|
||||
],
|
||||
|
||||
'taxes' => [
|
||||
'position' => 'Position',
|
||||
'positions' => [
|
||||
'before' => 'Before Subtotal (GST)',
|
||||
'after' => 'After Subtotal (PST)',
|
||||
],
|
||||
],
|
||||
|
||||
'messages' => [
|
||||
'received' => 'Bill marked as received successfully!',
|
||||
],
|
||||
|
@ -42,14 +42,6 @@ return [
|
||||
'paid' => 'Paid',
|
||||
],
|
||||
|
||||
'taxes' => [
|
||||
'position' => 'Position',
|
||||
'positions' => [
|
||||
'before' => 'Before Subtotal (GST)',
|
||||
'after' => 'After Subtotal (PST)',
|
||||
],
|
||||
],
|
||||
|
||||
'messages' => [
|
||||
'email_sent' => 'Invoice email has been sent successfully!',
|
||||
'marked_sent' => 'Invoice marked as sent successfully!',
|
||||
|
@ -96,7 +96,6 @@
|
||||
@stack('tax_total_td_start')
|
||||
<tr id="tr-tax">
|
||||
<td class="text-right" colspan="5">
|
||||
<button type="button" id="button-tax" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-xs btn-primary" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button>
|
||||
<strong>{{ trans_choice('general.taxes', 1) }}</strong>
|
||||
</td>
|
||||
<td class="text-right"><span id="tax-total">0</span></td>
|
||||
@ -362,115 +361,6 @@
|
||||
$('a[rel=popover]').trigger('click');
|
||||
});
|
||||
|
||||
$('#button-tax').popover({
|
||||
html: true,
|
||||
placement: 'left',
|
||||
title: '{{ trans('bills.tax') }}',
|
||||
content: function () {
|
||||
html = '<div class="tax box-body">';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('position', trans('bills.taxes.position'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group" id="input-tax">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' {!! Form::select('position', ['GST' => trans('bills.taxes.positions.before'), 'PST' => trans('bills.taxes.positions.after')], null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans('bills.taxes.position')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('tax_id', trans_choice('general.taxes', 1), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group" id="input-tax-id">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' <select class="form-control" id="tax_id" name="tax_id">';
|
||||
html += ' <option selected="selected" value="">{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}</option>';
|
||||
@foreach($taxes as $tax_id => $tax_title)
|
||||
html += ' <option value="{{ $tax_id }}">{{ $tax_title }}</option>';
|
||||
@endforeach
|
||||
html += ' <option value="add-new">+ {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</option>';
|
||||
html += ' </select>';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
html += '<div class="tax box-footer">';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' <div class="form-group no-margin">';
|
||||
html += ' {!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' => 'save-tax','class' => 'btn btn-success']) !!}';
|
||||
html += ' <a href="javascript:void(0)" id="cancel-tax" class="btn btn-default"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</a>';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
|
||||
return html;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', '#tax_id', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
if ($(this).val() == 'add-new') {
|
||||
html = ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('name', trans('general.name'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-id-card-o"></i></div>';
|
||||
html += ' {!! Form::text('name', null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.enter', ['field' => trans('general.name')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('rate', trans('taxes.rate'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' {!! Form::text('rate', null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.enter', ['field' => trans('taxes.rate')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
|
||||
$('.tax.box-body').append(html);
|
||||
} else {
|
||||
$('.tax.box-body #name').parent().parent().remove();
|
||||
$('.tax.box-body #rate').parent().parent().remove();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#save-tax', function(){
|
||||
position = $('.tax.box-body #position').val();
|
||||
tax_id = $('.tax.box-body #tax_id').val();
|
||||
|
||||
html = '';
|
||||
|
||||
if (tax_id == 'add-new') {
|
||||
|
||||
} else {
|
||||
html = '<tr id="tr-multiple-tax-' + tax_row + '">';
|
||||
html += ' <td class="text-right" colspan="5">';
|
||||
html += ' <button type="button" onclick="$(this).tooltip(\'destroy\'); $(this).parent().parent().remove(); totalItem();" data-toggle="tooltip" title="{{ trans('general.delete') }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>';
|
||||
html += ' <strong>' + $(".tax.box-body #tax_id option:selected").text() + '</strong>';
|
||||
html += ' </td>';
|
||||
html += ' <td class="text-right">';
|
||||
html += ' <input name="multiple_tax[' + tax_row + '][position]" value="' + position + '" type="hidden" id="input-position-multiple-tax-' + tax_row + '">';
|
||||
html += ' <input name="multiple_tax[' + tax_row + '][tax_id]" value="' + tax_id + '" type="hidden" id="input-tax-id-multiple-tax-' + tax_row + '">';
|
||||
html += ' <span id="multiple-tax-' + tax_row + '-total">0</span>';
|
||||
html += ' </td>';
|
||||
html += '</tr>';
|
||||
}
|
||||
|
||||
if (position == 'GST') {
|
||||
$('#tr-subtotal').before(html);
|
||||
} else {
|
||||
$('#tr-discount').after(html);
|
||||
}
|
||||
|
||||
tax_row++;
|
||||
|
||||
$('#button-tax').trigger('click');
|
||||
|
||||
totalItem();
|
||||
});
|
||||
|
||||
$(document).on('click', '#cancel-tax', function(){
|
||||
$('#discount').val('');
|
||||
|
||||
totalItem();
|
||||
|
||||
$('#button-tax').trigger('click');
|
||||
});
|
||||
|
||||
$(document).on('change', '#currency_code, #items tbody select', function(){
|
||||
totalItem();
|
||||
});
|
||||
@ -564,12 +454,6 @@
|
||||
$('#tax-total').html(data.tax_total);
|
||||
$('#grand-total').html(data.grand_total);
|
||||
|
||||
if (data.multible_taxes) {
|
||||
$.each( data.multible_taxes, function( key, value ) {
|
||||
$('#' + key).html(value);
|
||||
});
|
||||
}
|
||||
|
||||
$('.input-price').each(function(){
|
||||
input_price_id = $(this).attr('id');
|
||||
input_currency_id = input_price_id.replace('price', 'currency');
|
||||
|
@ -70,24 +70,6 @@
|
||||
<td class="text-right" colspan="5"></td>
|
||||
</tr>
|
||||
@stack('add_item_td_end')
|
||||
@foreach($bill->totals as $bill_total)
|
||||
@if(strpos($bill_total, 'gst') === false)
|
||||
@php continue; @endphp
|
||||
@endif
|
||||
@php $tax_code = explode('-', $bill_total->code); @endphp
|
||||
<tr>
|
||||
<td class="text-right" colspan="5">
|
||||
<button type="button" onclick="$(this).tooltip('destroy'); $(this).parent().parent().remove(); totalItem();" data-toggle="tooltip" title="{{ trans('general.delete') }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>
|
||||
<strong>{{ $bill_total->name }}</strong>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<input name="multiple_tax[{{ $tax_row }}][position]" value="GST" type="hidden" id="input-position-multiple-tax-{{ $tax_row }}">
|
||||
<input name="multiple_tax[{{ $tax_row }}][tax_id]" value="{{ $tax_code[1] }}" type="hidden" id="input-tax-id-multiple-tax-{{ $tax_row }}">
|
||||
<span id="multiple-tax-{{ $tax_row }}-total">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
@php $tax_row++; @endphp
|
||||
@endforeach
|
||||
@stack('sub_total_td_start')
|
||||
<tr id="tr-subtotal">
|
||||
<td class="text-right" colspan="5"><strong>{{ trans('bills.sub_total') }}</strong></td>
|
||||
@ -105,28 +87,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
@stack('add_discount_td_end')
|
||||
@foreach($bill->totals as $bill_total)
|
||||
@if(strpos($bill_total, 'pst') === false)
|
||||
@php continue; @endphp
|
||||
@endif
|
||||
@php $tax_code = explode('-', $bill_total->code); @endphp
|
||||
<tr>
|
||||
<td class="text-right" colspan="5">
|
||||
<button type="button" onclick="$(this).tooltip('destroy'); $(this).parent().parent().remove(); totalItem();" data-toggle="tooltip" title="{{ trans('general.delete') }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>
|
||||
<strong>{{ $bill_total->name }}</strong>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<input name="multiple_tax[{{ $tax_row }}][position]" value="PST" type="hidden" id="input-position-multiple-tax-{{ $tax_row }}">
|
||||
<input name="multiple_tax[{{ $tax_row }}][tax_id]" value="{{ $tax_code[1] }}" type="hidden" id="input-tax-id-multiple-tax-{{ $tax_row }}">
|
||||
<span id="multiple-tax-{{ $tax_row }}-total">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
@php $tax_row++; @endphp
|
||||
@endforeach
|
||||
@stack('tax_total_td_start')
|
||||
<tr id="tr-tax">
|
||||
<td class="text-right" colspan="5">
|
||||
<button type="button" id="button-tax" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-xs btn-primary" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button>
|
||||
<strong>{{ trans_choice('general.taxes', 1) }}</strong>
|
||||
</td>
|
||||
<td class="text-right"><span id="tax-total">0</span></td>
|
||||
@ -405,115 +368,6 @@
|
||||
$('a[rel=popover]').trigger('click');
|
||||
});
|
||||
|
||||
$('#button-tax').popover({
|
||||
html: true,
|
||||
placement: 'left',
|
||||
title: '{{ trans('bills.tax') }}',
|
||||
content: function () {
|
||||
html = '<div class="tax box-body">';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('position', trans('bills.taxes.position'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group" id="input-tax">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' {!! Form::select('position', ['GST' => trans('bills.taxes.positions.before'), 'PST' => trans('bills.taxes.positions.after')], null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans('bills.taxes.position')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('tax_id', trans_choice('general.taxes', 1), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group" id="input-tax-id">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' <select class="form-control" id="tax_id" name="tax_id">';
|
||||
html += ' <option selected="selected" value="">{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}</option>';
|
||||
@foreach($taxes as $tax_id => $tax_title)
|
||||
html += ' <option value="{{ $tax_id }}">{{ $tax_title }}</option>';
|
||||
@endforeach
|
||||
html += ' <option value="add-new">+ {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</option>';
|
||||
html += ' </select>';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
html += '<div class="tax box-footer">';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' <div class="form-group no-margin">';
|
||||
html += ' {!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' => 'save-tax','class' => 'btn btn-success']) !!}';
|
||||
html += ' <a href="javascript:void(0)" id="cancel-tax" class="btn btn-default"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</a>';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
|
||||
return html;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', '#tax_id', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
if ($(this).val() == 'add-new') {
|
||||
html = ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('name', trans('general.name'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-id-card-o"></i></div>';
|
||||
html += ' {!! Form::text('name', null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.enter', ['field' => trans('general.name')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('rate', trans('taxes.rate'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' {!! Form::text('rate', null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.enter', ['field' => trans('taxes.rate')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
|
||||
$('.tax.box-body').append(html);
|
||||
} else {
|
||||
$('.tax.box-body #name').parent().parent().remove();
|
||||
$('.tax.box-body #rate').parent().parent().remove();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#save-tax', function(){
|
||||
position = $('.tax.box-body #position').val();
|
||||
tax_id = $('.tax.box-body #tax_id').val();
|
||||
|
||||
html = '';
|
||||
|
||||
if (tax_id == 'add-new') {
|
||||
|
||||
} else {
|
||||
html = '<tr id="tr-multiple-tax-' + tax_row + '">';
|
||||
html += ' <td class="text-right" colspan="5">';
|
||||
html += ' <button type="button" onclick="$(this).tooltip(\'destroy\'); $(this).parent().parent().remove(); totalItem();" data-toggle="tooltip" title="{{ trans('general.delete') }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>';
|
||||
html += ' <strong>' + $(".tax.box-body #tax_id option:selected").text() + '</strong>';
|
||||
html += ' </td>';
|
||||
html += ' <td class="text-right">';
|
||||
html += ' <input name="multiple_tax[' + tax_row + '][position]" value="' + position + '" type="hidden" id="input-position-multiple-tax-' + tax_row + '">';
|
||||
html += ' <input name="multiple_tax[' + tax_row + '][tax_id]" value="' + tax_id + '" type="hidden" id="input-tax-id-multiple-tax-' + tax_row + '">';
|
||||
html += ' <span id="multiple-tax-' + tax_row + '-total">0</span>';
|
||||
html += ' </td>';
|
||||
html += '</tr>';
|
||||
}
|
||||
|
||||
if (position == 'GST') {
|
||||
$('#tr-subtotal').before(html);
|
||||
} else {
|
||||
$('#tr-discount').after(html);
|
||||
}
|
||||
|
||||
tax_row++;
|
||||
|
||||
$('#button-tax').trigger('click');
|
||||
|
||||
totalItem();
|
||||
});
|
||||
|
||||
$(document).on('click', '#cancel-tax', function(){
|
||||
$('#discount').val('');
|
||||
|
||||
totalItem();
|
||||
|
||||
$('#button-tax').trigger('click');
|
||||
});
|
||||
|
||||
$(document).on('change', '#currency_code, #items tbody select', function(){
|
||||
totalItem();
|
||||
});
|
||||
@ -607,12 +461,6 @@
|
||||
$('#tax-total').html(data.tax_total);
|
||||
$('#grand-total').html(data.grand_total);
|
||||
|
||||
if (data.multible_taxes) {
|
||||
$.each( data.multible_taxes, function( key, value ) {
|
||||
$('#' + key).html(value);
|
||||
});
|
||||
}
|
||||
|
||||
$('.input-price').each(function(){
|
||||
input_price_id = $(this).attr('id');
|
||||
input_currency_id = input_price_id.replace('price', 'currency');
|
||||
|
@ -96,7 +96,6 @@
|
||||
@stack('tax_total_td_start')
|
||||
<tr id="tr-tax">
|
||||
<td class="text-right" colspan="5">
|
||||
<button type="button" id="button-tax" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-xs btn-primary" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button>
|
||||
<strong>{{ trans_choice('general.taxes', 1) }}</strong>
|
||||
</td>
|
||||
<td class="text-right"><span id="tax-total">0</span></td>
|
||||
@ -170,7 +169,6 @@
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var item_row = '{{ $item_row }}';
|
||||
var tax_row = '0';
|
||||
|
||||
$(document).on('click', '#button-add-item', function (e) {
|
||||
var currency_code = $('#currency_code').val();
|
||||
@ -249,7 +247,6 @@
|
||||
$(".tax-select2").select2({
|
||||
placeholder: {
|
||||
id: '-1', // the value of the option
|
||||
minimumResultsForSearch: '1',
|
||||
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
|
||||
}
|
||||
});
|
||||
@ -363,121 +360,12 @@
|
||||
$('a[rel=popover]').trigger('click');
|
||||
});
|
||||
|
||||
$('#button-tax').popover({
|
||||
html: true,
|
||||
placement: 'left',
|
||||
title: '{{ trans('invoices.tax') }}',
|
||||
content: function () {
|
||||
html = '<div class="tax box-body">';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('position', trans('invoices.taxes.position'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group" id="input-tax">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' {!! Form::select('position', ['GST' => trans('invoices.taxes.positions.before'), 'PST' => trans('invoices.taxes.positions.after')], null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans('invoices.taxes.position')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('tax_id', trans_choice('general.taxes', 1), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group" id="input-tax-id">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' <select class="form-control" id="tax_id" name="tax_id">';
|
||||
html += ' <option selected="selected" value="">{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}</option>';
|
||||
@foreach($taxes as $tax_id => $tax_title)
|
||||
html += ' <option value="{{ $tax_id }}">{{ $tax_title }}</option>';
|
||||
@endforeach
|
||||
html += ' <option value="add-new">+ {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</option>';
|
||||
html += ' </select>';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
html += '<div class="tax box-footer">';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' <div class="form-group no-margin">';
|
||||
html += ' {!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' => 'save-tax','class' => 'btn btn-success']) !!}';
|
||||
html += ' <a href="javascript:void(0)" id="cancel-tax" class="btn btn-default"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</a>';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
|
||||
return html;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', '#tax_id', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
if ($(this).val() == 'add-new') {
|
||||
html = ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('name', trans('general.name'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-id-card-o"></i></div>';
|
||||
html += ' {!! Form::text('name', null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.enter', ['field' => trans('general.name')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('rate', trans('taxes.rate'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' {!! Form::text('rate', null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.enter', ['field' => trans('taxes.rate')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
|
||||
$('.tax.box-body').append(html);
|
||||
} else {
|
||||
$('.tax.box-body #name').parent().parent().remove();
|
||||
$('.tax.box-body #rate').parent().parent().remove();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#save-tax', function(){
|
||||
position = $('.tax.box-body #position').val();
|
||||
tax_id = $('.tax.box-body #tax_id').val();
|
||||
|
||||
html = '';
|
||||
|
||||
if (tax_id == 'add-new') {
|
||||
|
||||
} else {
|
||||
html = '<tr id="tr-multiple-tax-' + tax_row + '">';
|
||||
html += ' <td class="text-right" colspan="5">';
|
||||
html += ' <button type="button" onclick="$(this).tooltip(\'destroy\'); $(this).parent().parent().remove(); totalItem();" data-toggle="tooltip" title="{{ trans('general.delete') }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>';
|
||||
html += ' <strong>' + $(".tax.box-body #tax_id option:selected").text() + '</strong>';
|
||||
html += ' </td>';
|
||||
html += ' <td class="text-right">';
|
||||
html += ' <input name="multiple_tax[' + tax_row + '][position]" value="' + position + '" type="hidden" id="input-position-multiple-tax-' + tax_row + '">';
|
||||
html += ' <input name="multiple_tax[' + tax_row + '][tax_id]" value="' + tax_id + '" type="hidden" id="input-tax-id-multiple-tax-' + tax_row + '">';
|
||||
html += ' <span id="multiple-tax-' + tax_row + '-total">0</span>';
|
||||
html += ' </td>';
|
||||
html += '</tr>';
|
||||
}
|
||||
|
||||
if (position == 'GST') {
|
||||
$('#tr-subtotal').before(html);
|
||||
} else {
|
||||
$('#tr-discount').after(html);
|
||||
}
|
||||
|
||||
tax_row++;
|
||||
|
||||
$('#button-tax').trigger('click');
|
||||
|
||||
totalItem();
|
||||
});
|
||||
|
||||
$(document).on('click', '#cancel-tax', function(){
|
||||
$('#discount').val('');
|
||||
|
||||
totalItem();
|
||||
|
||||
$('#button-tax').trigger('click');
|
||||
});
|
||||
|
||||
$(document).on('change', '#currency_code, #items tbody select', function(){
|
||||
totalItem();
|
||||
});
|
||||
|
||||
var focus = false;
|
||||
|
||||
var focus = false;
|
||||
|
||||
$(document).on('focusin', '#items .input-price', function(){
|
||||
focus = true;
|
||||
});
|
||||
@ -565,12 +453,6 @@
|
||||
$('#tax-total').html(data.tax_total);
|
||||
$('#grand-total').html(data.grand_total);
|
||||
|
||||
if (data.multible_taxes) {
|
||||
$.each( data.multible_taxes, function( key, value ) {
|
||||
$('#' + key).html(value);
|
||||
});
|
||||
}
|
||||
|
||||
$('.input-price').each(function(){
|
||||
input_price_id = $(this).attr('id');
|
||||
input_currency_id = input_price_id.replace('price', 'currency');
|
||||
|
@ -70,24 +70,6 @@
|
||||
<td class="text-right" colspan="5"></td>
|
||||
</tr>
|
||||
@stack('add_item_td_end')
|
||||
@foreach($invoice->totals as $invoice_total)
|
||||
@if(strpos($invoice_total, 'gst') === false)
|
||||
@php continue; @endphp
|
||||
@endif
|
||||
@php $tax_code = explode('-', $invoice_total->code); @endphp
|
||||
<tr>
|
||||
<td class="text-right" colspan="5">
|
||||
<button type="button" onclick="$(this).tooltip('destroy'); $(this).parent().parent().remove(); totalItem();" data-toggle="tooltip" title="{{ trans('general.delete') }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>
|
||||
<strong>{{ $invoice_total->name }}</strong>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<input name="multiple_tax[{{ $tax_row }}][position]" value="GST" type="hidden" id="input-position-multiple-tax-{{ $tax_row }}">
|
||||
<input name="multiple_tax[{{ $tax_row }}][tax_id]" value="{{ $tax_code[1] }}" type="hidden" id="input-tax-id-multiple-tax-{{ $tax_row }}">
|
||||
<span id="multiple-tax-{{ $tax_row }}-total">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
@php $tax_row++; @endphp
|
||||
@endforeach
|
||||
@stack('sub_total_td_start')
|
||||
<tr id="tr-subtotal">
|
||||
<td class="text-right" colspan="5"><strong>{{ trans('invoices.sub_total') }}</strong></td>
|
||||
@ -105,28 +87,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
@stack('add_discount_td_end')
|
||||
@foreach($invoice->totals as $invoice_total)
|
||||
@if(strpos($invoice_total, 'pst') === false)
|
||||
@php continue; @endphp
|
||||
@endif
|
||||
@php $tax_code = explode('-', $invoice_total->code); @endphp
|
||||
<tr>
|
||||
<td class="text-right" colspan="5">
|
||||
<button type="button" onclick="$(this).tooltip('destroy'); $(this).parent().parent().remove(); totalItem();" data-toggle="tooltip" title="{{ trans('general.delete') }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>
|
||||
<strong>{{ $invoice_total->name }}</strong>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<input name="multiple_tax[{{ $tax_row }}][position]" value="PST" type="hidden" id="input-position-multiple-tax-{{ $tax_row }}">
|
||||
<input name="multiple_tax[{{ $tax_row }}][tax_id]" value="{{ $tax_code[1] }}" type="hidden" id="input-tax-id-multiple-tax-{{ $tax_row }}">
|
||||
<span id="multiple-tax-{{ $tax_row }}-total">0</span>
|
||||
</td>
|
||||
</tr>
|
||||
@php $tax_row++; @endphp
|
||||
@endforeach
|
||||
@stack('tax_total_td_start')
|
||||
<tr id="tr-tax">
|
||||
<td class="text-right" colspan="5">
|
||||
<button type="button" id="button-tax" data-toggle="tooltip" title="{{ trans('general.add') }}" class="btn btn-xs btn-primary" data-original-title="{{ trans('general.add') }}"><i class="fa fa-plus"></i></button>
|
||||
<strong>{{ trans_choice('general.taxes', 1) }}</strong>
|
||||
</td>
|
||||
<td class="text-right"><span id="tax-total">0</span></td>
|
||||
@ -405,121 +368,12 @@
|
||||
$('a[rel=popover]').trigger('click');
|
||||
});
|
||||
|
||||
$('#button-tax').popover({
|
||||
html: true,
|
||||
placement: 'left',
|
||||
title: '{{ trans('invoices.tax') }}',
|
||||
content: function () {
|
||||
html = '<div class="tax box-body">';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('position', trans('invoices.taxes.position'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group" id="input-tax">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' {!! Form::select('position', ['GST' => trans('invoices.taxes.positions.before'), 'PST' => trans('invoices.taxes.positions.after')], null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans('invoices.taxes.position')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('tax_id', trans_choice('general.taxes', 1), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group" id="input-tax-id">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' <select class="form-control" id="tax_id" name="tax_id">';
|
||||
html += ' <option selected="selected" value="">{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}</option>';
|
||||
@foreach($taxes as $tax_id => $tax_title)
|
||||
html += ' <option value="{{ $tax_id }}">{{ $tax_title }}</option>';
|
||||
@endforeach
|
||||
html += ' <option value="add-new">+ {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</option>';
|
||||
html += ' </select>';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
html += '<div class="tax box-footer">';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' <div class="form-group no-margin">';
|
||||
html += ' {!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' => 'save-tax','class' => 'btn btn-success']) !!}';
|
||||
html += ' <a href="javascript:void(0)" id="cancel-tax" class="btn btn-default"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</a>';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += '</div>';
|
||||
|
||||
return html;
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', '#tax_id', function(e){
|
||||
e.preventDefault();
|
||||
|
||||
if ($(this).val() == 'add-new') {
|
||||
html = ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('name', trans('general.name'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-id-card-o"></i></div>';
|
||||
html += ' {!! Form::text('name', null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.enter', ['field' => trans('general.name')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
html += ' <div class="col-md-12">';
|
||||
html += ' {!! Form::label('rate', trans('taxes.rate'), ['class' => 'control-label']) !!}';
|
||||
html += ' <div class="input-group">';
|
||||
html += ' <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
|
||||
html += ' {!! Form::text('rate', null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.enter', ['field' => trans('taxes.rate')])])) !!}';
|
||||
html += ' </div>';
|
||||
html += ' </div>';
|
||||
|
||||
$('.tax.box-body').append(html);
|
||||
} else {
|
||||
$('.tax.box-body #name').parent().parent().remove();
|
||||
$('.tax.box-body #rate').parent().parent().remove();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#save-tax', function(){
|
||||
position = $('.tax.box-body #position').val();
|
||||
tax_id = $('.tax.box-body #tax_id').val();
|
||||
|
||||
html = '';
|
||||
|
||||
if (tax_id == 'add-new') {
|
||||
|
||||
} else {
|
||||
html = '<tr id="tr-multiple-tax-' + tax_row + '">';
|
||||
html += ' <td class="text-right" colspan="5">';
|
||||
html += ' <button type="button" onclick="$(this).tooltip(\'destroy\'); $(this).parent().parent().remove(); totalItem();" data-toggle="tooltip" title="{{ trans('general.delete') }}" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>';
|
||||
html += ' <strong>' + $(".tax.box-body #tax_id option:selected").text() + '</strong>';
|
||||
html += ' </td>';
|
||||
html += ' <td class="text-right">';
|
||||
html += ' <input name="multiple_tax[' + tax_row + '][position]" value="' + position + '" type="hidden" id="input-position-multiple-tax-' + tax_row + '">';
|
||||
html += ' <input name="multiple_tax[' + tax_row + '][tax_id]" value="' + tax_id + '" type="hidden" id="input-tax-id-multiple-tax-' + tax_row + '">';
|
||||
html += ' <span id="multiple-tax-' + tax_row + '-total">0</span>';
|
||||
html += ' </td>';
|
||||
html += '</tr>';
|
||||
}
|
||||
|
||||
if (position == 'GST') {
|
||||
$('#tr-subtotal').before(html);
|
||||
} else {
|
||||
$('#tr-discount').after(html);
|
||||
}
|
||||
|
||||
tax_row++;
|
||||
|
||||
$('#button-tax').trigger('click');
|
||||
|
||||
totalItem();
|
||||
});
|
||||
|
||||
$(document).on('click', '#cancel-tax', function(){
|
||||
$('#discount').val('');
|
||||
|
||||
totalItem();
|
||||
|
||||
$('#button-tax').trigger('click');
|
||||
});
|
||||
|
||||
$(document).on('change', '#currency_code, #items tbody select', function(){
|
||||
totalItem();
|
||||
});
|
||||
|
||||
var focus = false;
|
||||
|
||||
|
||||
$(document).on('focusin', '#items .input-price', function(){
|
||||
focus = true;
|
||||
});
|
||||
@ -607,12 +461,6 @@
|
||||
$('#tax-total').html(data.tax_total);
|
||||
$('#grand-total').html(data.grand_total);
|
||||
|
||||
if (data.multible_taxes) {
|
||||
$.each( data.multible_taxes, function( key, value ) {
|
||||
$('#' + key).html(value);
|
||||
});
|
||||
}
|
||||
|
||||
$('.input-price').each(function(){
|
||||
input_price_id = $(this).attr('id');
|
||||
input_currency_id = input_price_id.replace('price', 'currency');
|
||||
|
71
resources/views/modals/taxes/create.blade.php
Normal file
71
resources/views/modals/taxes/create.blade.php
Normal file
@ -0,0 +1,71 @@
|
||||
<div class="modal fade" id="modal-create-tax" style="display: none;">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.taxes', 1)]) }}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{!! Form::open(['id' => 'form-create-tax', 'role' => 'form', 'class' => 'form-loading-button']) !!}
|
||||
<div class="row">
|
||||
{{ Form::textGroup('name', trans('general.name'), 'id-card-o') }}
|
||||
|
||||
{{ Form::textGroup('rate', trans('taxes.rate'), 'percent') }}
|
||||
|
||||
{!! Form::hidden('enabled', '1', []) !!}
|
||||
</div>
|
||||
{!! Form::close() !!}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="pull-left">
|
||||
{!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-tax', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!}
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span> {{ trans('general.cancel') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#modal-create-tax').modal('show');
|
||||
});
|
||||
|
||||
$(document).on('click', '#button-create-tax', function (e) {
|
||||
$('#modal-create-tax .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>');
|
||||
|
||||
$.ajax({
|
||||
url: '{{ url("modals/taxes") }}',
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
data: $("#form-create-tax").serialize(),
|
||||
beforeSend: function () {
|
||||
$(".form-group").removeClass("has-error");
|
||||
$(".help-block").remove();
|
||||
},
|
||||
success: function(json) {
|
||||
var data = json['data'];
|
||||
|
||||
$('#span-loading').remove();
|
||||
|
||||
$('#modal-create-tax').modal('hide');
|
||||
|
||||
$("#tax_id").append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>');
|
||||
$('#tax_id').trigger('change');
|
||||
$("#tax_id").select2('refresh');
|
||||
},
|
||||
error: function(error, textStatus, errorThrown) {
|
||||
$('#span-loading').remove();
|
||||
|
||||
if (error.responseJSON.name) {
|
||||
$("#modal-create-tax input[name='name']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-tax input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>');
|
||||
}
|
||||
|
||||
if (error.responseJSON.rate) {
|
||||
$("#modal-create-tax input[name='rate']").parent().parent().addClass('has-error');
|
||||
$("#modal-create-tax input[name='rate']").parent().after('<p class="help-block">' + error.responseJSON.rate + '</p>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
@ -202,6 +202,15 @@ Route::group(['middleware' => 'language'], function () {
|
||||
]]);
|
||||
Route::resource('invoices/{invoice}/payment', 'Modals\InvoicePayments', ['middleware' => ['dateformat', 'money']]);
|
||||
Route::resource('bills/{bill}/payment', 'Modals\BillPayments', ['middleware' => ['dateformat', 'money']]);
|
||||
Route::resource('taxes', 'Modals\Taxes', ['names' => [
|
||||
'index' => 'modals.taxes.index',
|
||||
'create' => 'modals.taxes.create',
|
||||
'store' => 'modals.taxes.store',
|
||||
'show' => 'modals.taxes.show',
|
||||
'edit' => 'modals.taxes.edit',
|
||||
'update' => 'modals.taxes.update',
|
||||
'destroy' => 'modals.taxes.destroy',
|
||||
]]);
|
||||
});
|
||||
|
||||
/* @deprecated */
|
||||
|
Loading…
x
Reference in New Issue
Block a user