Merge pull request #537 from cuneytsenturk/1.3-dev
Invoice/Bill: Multiple tax rate
This commit is contained in:
commit
8315665daf
@ -345,6 +345,22 @@ 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->items = $items;
|
||||||
|
|
||||||
$json->sub_total = money($sub_total, $currency_code, true)->format();
|
$json->sub_total = money($sub_total, $currency_code, true)->format();
|
||||||
@ -362,10 +378,32 @@ class Items extends Controller
|
|||||||
$sub_total = $sub_total - ($sub_total * ($discount / 100));
|
$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;
|
$grand_total = $sub_total + $tax_total;
|
||||||
|
|
||||||
$json->grand_total = money($grand_total, $currency_code, true)->format();
|
$json->grand_total = money($grand_total, $currency_code, true)->format();
|
||||||
|
|
||||||
|
$json->multible_taxes = false;
|
||||||
|
|
||||||
|
if (!empty($taxes)) {
|
||||||
|
$json->multible_taxes = $taxes;
|
||||||
|
}
|
||||||
|
|
||||||
// Get currency object
|
// Get currency object
|
||||||
$currency = Currency::where('code', $currency_code)->first();
|
$currency = Currency::where('code', $currency_code)->first();
|
||||||
|
|
||||||
|
@ -211,10 +211,10 @@ class Bills extends Controller
|
|||||||
|
|
||||||
// Set taxes
|
// Set taxes
|
||||||
if (isset($tax_object)) {
|
if (isset($tax_object)) {
|
||||||
if (array_key_exists($tax_object->id, $taxes)) {
|
if (isset($taxes['VAT']) && array_key_exists($tax_object->id, $taxes['VAT'])) {
|
||||||
$taxes[$tax_object->id]['amount'] += $tax;
|
$taxes['VAT'][$tax_object->id]['amount'] += $tax;
|
||||||
} else {
|
} else {
|
||||||
$taxes[$tax_object->id] = [
|
$taxes['VAT'][$tax_object->id] = [
|
||||||
'name' => $tax_object->name,
|
'name' => $tax_object->name,
|
||||||
'amount' => $tax
|
'amount' => $tax
|
||||||
];
|
];
|
||||||
@ -229,6 +229,30 @@ 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;
|
$s_total = $sub_total;
|
||||||
|
|
||||||
// Apply discount to total
|
// Apply discount to total
|
||||||
@ -238,6 +262,30 @@ class Bills extends Controller
|
|||||||
$s_total = $s_total - $s_discount;
|
$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;
|
$amount = $s_total + $tax_total;
|
||||||
|
|
||||||
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
||||||
@ -422,10 +470,10 @@ class Bills extends Controller
|
|||||||
$bill_item['total'] = (double) $item['price'] * (double) $item['quantity'];
|
$bill_item['total'] = (double) $item['price'] * (double) $item['quantity'];
|
||||||
|
|
||||||
if (isset($tax_object)) {
|
if (isset($tax_object)) {
|
||||||
if (array_key_exists($tax_object->id, $taxes)) {
|
if (isset($taxes['VAT']) && array_key_exists($tax_object->id, $taxes['VAT'])) {
|
||||||
$taxes[$tax_object->id]['amount'] += $tax;
|
$taxes['VAT'][$tax_object->id]['amount'] += $tax;
|
||||||
} else {
|
} else {
|
||||||
$taxes[$tax_object->id] = [
|
$taxes['VAT'][$tax_object->id] = [
|
||||||
'name' => $tax_object->name,
|
'name' => $tax_object->name,
|
||||||
'amount' => $tax
|
'amount' => $tax
|
||||||
];
|
];
|
||||||
@ -439,6 +487,30 @@ 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;
|
$s_total = $sub_total;
|
||||||
|
|
||||||
// Apply discount to total
|
// Apply discount to total
|
||||||
@ -448,6 +520,30 @@ class Bills extends Controller
|
|||||||
$s_total = $s_total - $s_discount;
|
$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;
|
$amount = $s_total + $tax_total;
|
||||||
|
|
||||||
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
||||||
@ -796,6 +892,21 @@ class Bills extends Controller
|
|||||||
{
|
{
|
||||||
$sort_order = 1;
|
$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
|
// Added bill sub total
|
||||||
BillTotal::create([
|
BillTotal::create([
|
||||||
'company_id' => $request['company_id'],
|
'company_id' => $request['company_id'],
|
||||||
@ -821,13 +932,28 @@ class Bills extends Controller
|
|||||||
|
|
||||||
// This is for total
|
// This is for total
|
||||||
$sub_total = $sub_total - $discount_total;
|
$sub_total = $sub_total - $discount_total;
|
||||||
|
|
||||||
|
$sort_order++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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
|
// Added bill taxes
|
||||||
if ($taxes) {
|
if (isset($taxes['VAT'])) {
|
||||||
foreach ($taxes as $tax) {
|
foreach ($taxes['VAT'] as $tax) {
|
||||||
BillTotal::create([
|
BillTotal::create([
|
||||||
'company_id' => $request['company_id'],
|
'company_id' => $request['company_id'],
|
||||||
'bill_id' => $bill->id,
|
'bill_id' => $bill->id,
|
||||||
|
@ -243,10 +243,10 @@ class Invoices extends Controller
|
|||||||
|
|
||||||
// Set taxes
|
// Set taxes
|
||||||
if (isset($tax_object)) {
|
if (isset($tax_object)) {
|
||||||
if (array_key_exists($tax_object->id, $taxes)) {
|
if (isset($taxes['VAT']) && array_key_exists($tax_object->id, $taxes['VAT'])) {
|
||||||
$taxes[$tax_object->id]['amount'] += $tax;
|
$taxes['VAT'][$tax_object->id]['amount'] += $tax;
|
||||||
} else {
|
} else {
|
||||||
$taxes[$tax_object->id] = [
|
$taxes['VAT'][$tax_object->id] = [
|
||||||
'name' => $tax_object->name,
|
'name' => $tax_object->name,
|
||||||
'amount' => $tax
|
'amount' => $tax
|
||||||
];
|
];
|
||||||
@ -261,6 +261,30 @@ 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;
|
$s_total = $sub_total;
|
||||||
|
|
||||||
// Apply discount to total
|
// Apply discount to total
|
||||||
@ -270,6 +294,30 @@ class Invoices extends Controller
|
|||||||
$s_total = $s_total - $s_discount;
|
$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;
|
$amount = $s_total + $tax_total;
|
||||||
|
|
||||||
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
||||||
@ -460,10 +508,10 @@ class Invoices extends Controller
|
|||||||
$invoice_item['total'] = (double) $item['price'] * (double) $item['quantity'];
|
$invoice_item['total'] = (double) $item['price'] * (double) $item['quantity'];
|
||||||
|
|
||||||
if (isset($tax_object)) {
|
if (isset($tax_object)) {
|
||||||
if (array_key_exists($tax_object->id, $taxes)) {
|
if (isset($taxes['VAT']) && array_key_exists($tax_object->id, $taxes['VAT'])) {
|
||||||
$taxes[$tax_object->id]['amount'] += $tax;
|
$taxes['VAT'][$tax_object->id]['amount'] += $tax;
|
||||||
} else {
|
} else {
|
||||||
$taxes[$tax_object->id] = [
|
$taxes['VAT'][$tax_object->id] = [
|
||||||
'name' => $tax_object->name,
|
'name' => $tax_object->name,
|
||||||
'amount' => $tax
|
'amount' => $tax
|
||||||
];
|
];
|
||||||
@ -477,6 +525,30 @@ 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;
|
$s_total = $sub_total;
|
||||||
|
|
||||||
// Apply discount to total
|
// Apply discount to total
|
||||||
@ -486,6 +558,30 @@ class Invoices extends Controller
|
|||||||
$s_total = $s_total - $s_discount;
|
$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;
|
$amount = $s_total + $tax_total;
|
||||||
|
|
||||||
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
$request['amount'] = money($amount, $request['currency_code'])->getAmount();
|
||||||
@ -950,6 +1046,21 @@ class Invoices extends Controller
|
|||||||
{
|
{
|
||||||
$sort_order = 1;
|
$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
|
// Added invoice sub total
|
||||||
InvoiceTotal::create([
|
InvoiceTotal::create([
|
||||||
'company_id' => $request['company_id'],
|
'company_id' => $request['company_id'],
|
||||||
@ -975,13 +1086,28 @@ class Invoices extends Controller
|
|||||||
|
|
||||||
// This is for total
|
// This is for total
|
||||||
$sub_total = $sub_total - $discount_total;
|
$sub_total = $sub_total - $discount_total;
|
||||||
|
|
||||||
|
$sort_order++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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
|
// Added invoice taxes
|
||||||
if ($taxes) {
|
if (isset($taxes['VAT'])) {
|
||||||
foreach ($taxes as $tax) {
|
foreach ($taxes['VAT'] as $tax) {
|
||||||
InvoiceTotal::create([
|
InvoiceTotal::create([
|
||||||
'company_id' => $request['company_id'],
|
'company_id' => $request['company_id'],
|
||||||
'invoice_id' => $invoice->id,
|
'invoice_id' => $invoice->id,
|
||||||
|
@ -39,6 +39,14 @@ return [
|
|||||||
'paid' => 'Paid',
|
'paid' => 'Paid',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'taxes' => [
|
||||||
|
'position' => 'Position',
|
||||||
|
'positions' => [
|
||||||
|
'before' => 'Before Subtotal (GST)',
|
||||||
|
'after' => 'After Subtotal (PST)',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
'messages' => [
|
'messages' => [
|
||||||
'received' => 'Bill marked as received successfully!',
|
'received' => 'Bill marked as received successfully!',
|
||||||
],
|
],
|
||||||
|
@ -41,6 +41,14 @@ return [
|
|||||||
'paid' => 'Paid',
|
'paid' => 'Paid',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'taxes' => [
|
||||||
|
'position' => 'Position',
|
||||||
|
'positions' => [
|
||||||
|
'before' => 'Before Subtotal (GST)',
|
||||||
|
'after' => 'After Subtotal (PST)',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
'messages' => [
|
'messages' => [
|
||||||
'email_sent' => 'Invoice email has been sent successfully!',
|
'email_sent' => 'Invoice email has been sent successfully!',
|
||||||
'marked_sent' => 'Invoice marked as sent successfully!',
|
'marked_sent' => 'Invoice marked as sent successfully!',
|
||||||
|
@ -77,13 +77,13 @@
|
|||||||
</tr>
|
</tr>
|
||||||
@stack('add_item_td_end')
|
@stack('add_item_td_end')
|
||||||
@stack('sub_total_td_start')
|
@stack('sub_total_td_start')
|
||||||
<tr>
|
<tr id="tr-subtotal">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans('bills.sub_total') }}</strong></td>
|
<td class="text-right" colspan="5"><strong>{{ trans('bills.sub_total') }}</strong></td>
|
||||||
<td class="text-right"><span id="sub-total">0</span></td>
|
<td class="text-right"><span id="sub-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('sub_total_td_end')
|
@stack('sub_total_td_end')
|
||||||
@stack('add_discount_td_start')
|
@stack('add_discount_td_start')
|
||||||
<tr>
|
<tr id="tr-discount">
|
||||||
<td class="text-right" style="vertical-align: middle;" colspan="5">
|
<td class="text-right" style="vertical-align: middle;" colspan="5">
|
||||||
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('bills.add_discount') }}</a>
|
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('bills.add_discount') }}</a>
|
||||||
</td>
|
</td>
|
||||||
@ -94,13 +94,16 @@
|
|||||||
</tr>
|
</tr>
|
||||||
@stack('add_discount_td_end')
|
@stack('add_discount_td_end')
|
||||||
@stack('tax_total_td_start')
|
@stack('tax_total_td_start')
|
||||||
<tr>
|
<tr id="tr-tax">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans_choice('general.taxes', 1) }}</strong></td>
|
<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>
|
<td class="text-right"><span id="tax-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('tax_total_td_end')
|
@stack('tax_total_td_end')
|
||||||
@stack('grand_total_td_start')
|
@stack('grand_total_td_start')
|
||||||
<tr>
|
<tr id="tr-total">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans('bills.total') }}</strong></td>
|
<td class="text-right" colspan="5"><strong>{{ trans('bills.total') }}</strong></td>
|
||||||
<td class="text-right"><span id="grand-total">0</span></td>
|
<td class="text-right"><span id="grand-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -167,6 +170,7 @@
|
|||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var item_row = '{{ $item_row }}';
|
var item_row = '{{ $item_row }}';
|
||||||
|
var tax_row = '0';
|
||||||
|
|
||||||
$(document).on('click', '#button-add-item', function (e) {
|
$(document).on('click', '#button-add-item', function (e) {
|
||||||
var currency_code = $('#currency_code').val();
|
var currency_code = $('#currency_code').val();
|
||||||
@ -358,6 +362,115 @@
|
|||||||
$('a[rel=popover]').trigger('click');
|
$('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(){
|
$(document).on('change', '#currency_code, #items tbody select', function(){
|
||||||
totalItem();
|
totalItem();
|
||||||
});
|
});
|
||||||
@ -451,6 +564,12 @@
|
|||||||
$('#tax-total').html(data.tax_total);
|
$('#tax-total').html(data.tax_total);
|
||||||
$('#grand-total').html(data.grand_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').each(function(){
|
||||||
input_price_id = $(this).attr('id');
|
input_price_id = $(this).attr('id');
|
||||||
input_currency_id = input_price_id.replace('price', 'currency');
|
input_currency_id = input_price_id.replace('price', 'currency');
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@php $item_row = 0; @endphp
|
@php $item_row = 0; $tax_row = 0; @endphp
|
||||||
@if(old('item'))
|
@if(old('item'))
|
||||||
@foreach(old('item') as $old_item)
|
@foreach(old('item') as $old_item)
|
||||||
@php $item = (object) $old_item; @endphp
|
@php $item = (object) $old_item; @endphp
|
||||||
@ -70,14 +70,32 @@
|
|||||||
<td class="text-right" colspan="5"></td>
|
<td class="text-right" colspan="5"></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('add_item_td_end')
|
@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')
|
@stack('sub_total_td_start')
|
||||||
<tr>
|
<tr id="tr-subtotal">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans('bills.sub_total') }}</strong></td>
|
<td class="text-right" colspan="5"><strong>{{ trans('bills.sub_total') }}</strong></td>
|
||||||
<td class="text-right"><span id="sub-total">0</span></td>
|
<td class="text-right"><span id="sub-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('sub_total_td_end')
|
@stack('sub_total_td_end')
|
||||||
@stack('add_discount_td_start')
|
@stack('add_discount_td_start')
|
||||||
<tr>
|
<tr id="tr-discount">
|
||||||
<td class="text-right" style="vertical-align: middle;" colspan="5">
|
<td class="text-right" style="vertical-align: middle;" colspan="5">
|
||||||
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('bills.add_discount') }}</a>
|
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('bills.add_discount') }}</a>
|
||||||
</td>
|
</td>
|
||||||
@ -87,14 +105,35 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('add_discount_td_end')
|
@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')
|
@stack('tax_total_td_start')
|
||||||
<tr>
|
<tr id="tr-tax">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans_choice('general.taxes', 1) }}</strong></td>
|
<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>
|
<td class="text-right"><span id="tax-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('tax_total_td_end')
|
@stack('tax_total_td_end')
|
||||||
@stack('grand_total_td_start')
|
@stack('grand_total_td_start')
|
||||||
<tr>
|
<tr id="tr-total">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans('bills.total') }}</strong></td>
|
<td class="text-right" colspan="5"><strong>{{ trans('bills.total') }}</strong></td>
|
||||||
<td class="text-right"><span id="grand-total">0</span></td>
|
<td class="text-right"><span id="grand-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -366,6 +405,115 @@
|
|||||||
$('a[rel=popover]').trigger('click');
|
$('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(){
|
$(document).on('change', '#currency_code, #items tbody select', function(){
|
||||||
totalItem();
|
totalItem();
|
||||||
});
|
});
|
||||||
@ -459,6 +607,12 @@
|
|||||||
$('#tax-total').html(data.tax_total);
|
$('#tax-total').html(data.tax_total);
|
||||||
$('#grand-total').html(data.grand_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').each(function(){
|
||||||
input_price_id = $(this).attr('id');
|
input_price_id = $(this).attr('id');
|
||||||
input_currency_id = input_price_id.replace('price', 'currency');
|
input_currency_id = input_price_id.replace('price', 'currency');
|
||||||
|
@ -77,13 +77,13 @@
|
|||||||
</tr>
|
</tr>
|
||||||
@stack('add_item_td_end')
|
@stack('add_item_td_end')
|
||||||
@stack('sub_total_td_start')
|
@stack('sub_total_td_start')
|
||||||
<tr>
|
<tr id="tr-subtotal">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans('invoices.sub_total') }}</strong></td>
|
<td class="text-right" colspan="5"><strong>{{ trans('invoices.sub_total') }}</strong></td>
|
||||||
<td class="text-right"><span id="sub-total">0</span></td>
|
<td class="text-right"><span id="sub-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('sub_total_td_end')
|
@stack('sub_total_td_end')
|
||||||
@stack('add_discount_td_start')
|
@stack('add_discount_td_start')
|
||||||
<tr>
|
<tr id="tr-discount">
|
||||||
<td class="text-right" style="vertical-align: middle;" colspan="5">
|
<td class="text-right" style="vertical-align: middle;" colspan="5">
|
||||||
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('invoices.add_discount') }}</a>
|
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('invoices.add_discount') }}</a>
|
||||||
</td>
|
</td>
|
||||||
@ -94,13 +94,16 @@
|
|||||||
</tr>
|
</tr>
|
||||||
@stack('add_discount_td_end')
|
@stack('add_discount_td_end')
|
||||||
@stack('tax_total_td_start')
|
@stack('tax_total_td_start')
|
||||||
<tr>
|
<tr id="tr-tax">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans_choice('general.taxes', 1) }}</strong></td>
|
<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>
|
<td class="text-right"><span id="tax-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('tax_total_td_end')
|
@stack('tax_total_td_end')
|
||||||
@stack('grand_total_td_start')
|
@stack('grand_total_td_start')
|
||||||
<tr>
|
<tr id="tr-total">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans('invoices.total') }}</strong></td>
|
<td class="text-right" colspan="5"><strong>{{ trans('invoices.total') }}</strong></td>
|
||||||
<td class="text-right"><span id="grand-total">0</span></td>
|
<td class="text-right"><span id="grand-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -167,6 +170,7 @@
|
|||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var item_row = '{{ $item_row }}';
|
var item_row = '{{ $item_row }}';
|
||||||
|
var tax_row = '0';
|
||||||
|
|
||||||
$(document).on('click', '#button-add-item', function (e) {
|
$(document).on('click', '#button-add-item', function (e) {
|
||||||
var currency_code = $('#currency_code').val();
|
var currency_code = $('#currency_code').val();
|
||||||
@ -245,6 +249,7 @@
|
|||||||
$(".tax-select2").select2({
|
$(".tax-select2").select2({
|
||||||
placeholder: {
|
placeholder: {
|
||||||
id: '-1', // the value of the option
|
id: '-1', // the value of the option
|
||||||
|
minimumResultsForSearch: '1',
|
||||||
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
|
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -358,6 +363,115 @@
|
|||||||
$('a[rel=popover]').trigger('click');
|
$('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(){
|
$(document).on('change', '#currency_code, #items tbody select', function(){
|
||||||
totalItem();
|
totalItem();
|
||||||
});
|
});
|
||||||
@ -451,6 +565,12 @@
|
|||||||
$('#tax-total').html(data.tax_total);
|
$('#tax-total').html(data.tax_total);
|
||||||
$('#grand-total').html(data.grand_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').each(function(){
|
||||||
input_price_id = $(this).attr('id');
|
input_price_id = $(this).attr('id');
|
||||||
input_currency_id = input_price_id.replace('price', 'currency');
|
input_currency_id = input_price_id.replace('price', 'currency');
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@php $item_row = 0; @endphp
|
@php $item_row = 0; $tax_row = 0; @endphp
|
||||||
@if(old('item'))
|
@if(old('item'))
|
||||||
@foreach(old('item') as $old_item)
|
@foreach(old('item') as $old_item)
|
||||||
@php $item = (object) $old_item; @endphp
|
@php $item = (object) $old_item; @endphp
|
||||||
@ -70,14 +70,32 @@
|
|||||||
<td class="text-right" colspan="5"></td>
|
<td class="text-right" colspan="5"></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('add_item_td_end')
|
@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')
|
@stack('sub_total_td_start')
|
||||||
<tr>
|
<tr id="tr-subtotal">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans('invoices.sub_total') }}</strong></td>
|
<td class="text-right" colspan="5"><strong>{{ trans('invoices.sub_total') }}</strong></td>
|
||||||
<td class="text-right"><span id="sub-total">0</span></td>
|
<td class="text-right"><span id="sub-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('sub_total_td_end')
|
@stack('sub_total_td_end')
|
||||||
@stack('add_discount_td_start')
|
@stack('add_discount_td_start')
|
||||||
<tr>
|
<tr id="tr-discount">
|
||||||
<td class="text-right" style="vertical-align: middle;" colspan="5">
|
<td class="text-right" style="vertical-align: middle;" colspan="5">
|
||||||
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('invoices.add_discount') }}</a>
|
<a href="javascript:void(0)" id="discount-text" rel="popover">{{ trans('invoices.add_discount') }}</a>
|
||||||
</td>
|
</td>
|
||||||
@ -87,14 +105,35 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('add_discount_td_end')
|
@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')
|
@stack('tax_total_td_start')
|
||||||
<tr>
|
<tr id="tr-tax">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans_choice('general.taxes', 1) }}</strong></td>
|
<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>
|
<td class="text-right"><span id="tax-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@stack('tax_total_td_end')
|
@stack('tax_total_td_end')
|
||||||
@stack('grand_total_td_start')
|
@stack('grand_total_td_start')
|
||||||
<tr>
|
<tr id="tr-total">
|
||||||
<td class="text-right" colspan="5"><strong>{{ trans('invoices.total') }}</strong></td>
|
<td class="text-right" colspan="5"><strong>{{ trans('invoices.total') }}</strong></td>
|
||||||
<td class="text-right"><span id="grand-total">0</span></td>
|
<td class="text-right"><span id="grand-total">0</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -366,6 +405,115 @@
|
|||||||
$('a[rel=popover]').trigger('click');
|
$('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(){
|
$(document).on('change', '#currency_code, #items tbody select', function(){
|
||||||
totalItem();
|
totalItem();
|
||||||
});
|
});
|
||||||
@ -459,6 +607,12 @@
|
|||||||
$('#tax-total').html(data.tax_total);
|
$('#tax-total').html(data.tax_total);
|
||||||
$('#grand-total').html(data.grand_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').each(function(){
|
||||||
input_price_id = $(this).attr('id');
|
input_price_id = $(this).attr('id');
|
||||||
input_currency_id = input_price_id.replace('price', 'currency');
|
input_currency_id = input_price_id.replace('price', 'currency');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user