@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | $query = $this->advanceSearch($name, $invoice_no, $currency, $status, $from, $till); |
| 130 | 130 | |
| 131 | 131 | return \DataTables::of($query->take(100)) |
| 132 | - ->setTotalRecords($query->count()) |
|
| 132 | + ->setTotalRecords($query->count()) |
|
| 133 | 133 | |
| 134 | - ->addColumn('checkbox', function ($model) { |
|
| 135 | - return "<input type='checkbox' class='invoice_checkbox' |
|
| 134 | + ->addColumn('checkbox', function ($model) { |
|
| 135 | + return "<input type='checkbox' class='invoice_checkbox' |
|
| 136 | 136 | value=".$model->id.' name=select[] id=check>'; |
| 137 | - }) |
|
| 137 | + }) |
|
| 138 | 138 | ->addColumn('user_id', function ($model) { |
| 139 | 139 | $first = $this->user->where('id', $model->user_id)->first()->first_name; |
| 140 | 140 | $last = $this->user->where('id', $model->user_id)->first()->last_name; |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | return '<a href='.url('clients/'.$id).'>'.ucfirst($first).' '.ucfirst($last).'</a>'; |
| 144 | 144 | }) |
| 145 | - ->addColumn('number', function ($model) { |
|
| 146 | - return ucfirst($model->number); |
|
| 147 | - }) |
|
| 145 | + ->addColumn('number', function ($model) { |
|
| 146 | + return ucfirst($model->number); |
|
| 147 | + }) |
|
| 148 | 148 | |
| 149 | 149 | ->addColumn('date', function ($model) { |
| 150 | 150 | $date = ($model->created_at); |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | return $date; |
| 153 | 153 | // return "<span style='display:none'>$model->id</span>".$date->format('l, F j, Y H:m'); |
| 154 | 154 | }) |
| 155 | - ->addColumn('grand_total', function ($model) { |
|
| 156 | - return $model->grand_total; |
|
| 157 | - }) |
|
| 158 | - ->addColumn('status', function ($model) { |
|
| 159 | - return ucfirst($model->status); |
|
| 160 | - }) |
|
| 155 | + ->addColumn('grand_total', function ($model) { |
|
| 156 | + return $model->grand_total; |
|
| 157 | + }) |
|
| 158 | + ->addColumn('status', function ($model) { |
|
| 159 | + return ucfirst($model->status); |
|
| 160 | + }) |
|
| 161 | 161 | |
| 162 | 162 | ->addColumn('action', function ($model) { |
| 163 | 163 | $action = ''; |
@@ -175,30 +175,30 @@ discard block |
||
| 175 | 175 | style='color:white;'> </i> View</a>" |
| 176 | 176 | ." $action"; |
| 177 | 177 | }) |
| 178 | - ->filterColumn('user_id', function ($query, $keyword) { |
|
| 179 | - $sql = 'first_name like ?'; |
|
| 180 | - $query->whereRaw($sql, ["%{$keyword}%"]); |
|
| 181 | - }) |
|
| 178 | + ->filterColumn('user_id', function ($query, $keyword) { |
|
| 179 | + $sql = 'first_name like ?'; |
|
| 180 | + $query->whereRaw($sql, ["%{$keyword}%"]); |
|
| 181 | + }) |
|
| 182 | 182 | |
| 183 | - ->filterColumn('status', function ($query, $keyword) { |
|
| 184 | - $sql = 'status like ?'; |
|
| 185 | - $query->whereRaw($sql, ["%{$keyword}%"]); |
|
| 186 | - }) |
|
| 183 | + ->filterColumn('status', function ($query, $keyword) { |
|
| 184 | + $sql = 'status like ?'; |
|
| 185 | + $query->whereRaw($sql, ["%{$keyword}%"]); |
|
| 186 | + }) |
|
| 187 | 187 | |
| 188 | 188 | ->filterColumn('number', function ($query, $keyword) { |
| 189 | 189 | $sql = 'number like ?'; |
| 190 | 190 | $query->whereRaw($sql, ["%{$keyword}%"]); |
| 191 | 191 | }) |
| 192 | - ->filterColumn('grand_total', function ($query, $keyword) { |
|
| 193 | - $sql = 'grand_total like ?'; |
|
| 194 | - $query->whereRaw($sql, ["%{$keyword}%"]); |
|
| 195 | - }) |
|
| 196 | - ->filterColumn('date', function ($query, $keyword) { |
|
| 197 | - $sql = 'date like ?'; |
|
| 198 | - $query->whereRaw($sql, ["%{$keyword}%"]); |
|
| 199 | - }) |
|
| 200 | - |
|
| 201 | - ->rawColumns(['checkbox', 'user_id', 'number', 'date', 'grand_total', 'status', 'action']) |
|
| 192 | + ->filterColumn('grand_total', function ($query, $keyword) { |
|
| 193 | + $sql = 'grand_total like ?'; |
|
| 194 | + $query->whereRaw($sql, ["%{$keyword}%"]); |
|
| 195 | + }) |
|
| 196 | + ->filterColumn('date', function ($query, $keyword) { |
|
| 197 | + $sql = 'date like ?'; |
|
| 198 | + $query->whereRaw($sql, ["%{$keyword}%"]); |
|
| 199 | + }) |
|
| 200 | + |
|
| 201 | + ->rawColumns(['checkbox', 'user_id', 'number', 'date', 'grand_total', 'status', 'action']) |
|
| 202 | 202 | ->make(true); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | $symbol = $attributes[0]['currency']['symbol']; |
| 295 | 295 | $invoice = $this->invoice->create(['user_id' => $user_id, 'number' => $number, |
| 296 | - 'date' => $date, 'discount'=>$codevalue, 'grand_total' => $grand_total, 'coupon_code'=>$code, 'status' => 'pending', |
|
| 297 | - 'currency' => \Auth::user()->currency, ]); |
|
| 296 | + 'date' => $date, 'discount'=>$codevalue, 'grand_total' => $grand_total, 'coupon_code'=>$code, 'status' => 'pending', |
|
| 297 | + 'currency' => \Auth::user()->currency, ]); |
|
| 298 | 298 | foreach (\Cart::getContent() as $cart) { |
| 299 | 299 | $this->createInvoiceItems($invoice->id, $cart, $codevalue); |
| 300 | 300 | } |
@@ -322,9 +322,9 @@ discard block |
||
| 322 | 322 | { |
| 323 | 323 | $code = ''; |
| 324 | 324 | $codevalue = ''; |
| 325 | - if(\Session::has('code')){//If coupon code is applied get it here from Session |
|
| 326 | - $code = \Session::get('code'); |
|
| 327 | - $codevalue = \Session::get('codevalue'); |
|
| 325 | + if(\Session::has('code')){//If coupon code is applied get it here from Session |
|
| 326 | + $code = \Session::get('code'); |
|
| 327 | + $codevalue = \Session::get('codevalue'); |
|
| 328 | 328 | } |
| 329 | 329 | return ['code'=> $code , 'codevalue'=>$codevalue] ; |
| 330 | 330 | } |
@@ -433,11 +433,11 @@ discard block |
||
| 433 | 433 | $grand_total = \App\Http\Controllers\Front\CartController::rounding($grand_total); |
| 434 | 434 | |
| 435 | 435 | $invoice = Invoice::create(['user_id' => $user_id, 'number' => $number, 'date' => $date, |
| 436 | - 'coupon_code' => $code, 'discount'=>$codeValue, |
|
| 436 | + 'coupon_code' => $code, 'discount'=>$codeValue, |
|
| 437 | 437 | 'grand_total' => $grand_total, 'currency' => $currency, 'status' => $status, 'description' => $description, ]); |
| 438 | 438 | |
| 439 | 439 | $items = $this->createInvoiceItemsByAdmin($invoice->id, $productid, |
| 440 | - $code, $total, $currency, $qty, $agents, $plan, $user_id, $tax_name, $tax_rate); |
|
| 440 | + $code, $total, $currency, $qty, $agents, $plan, $user_id, $tax_name, $tax_rate); |
|
| 441 | 441 | $result = $this->getMessage($items, $user_id); |
| 442 | 442 | } catch (\Exception $ex) { |
| 443 | 443 | app('log')->info($ex->getMessage()); |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | } elseif ($this->tax_option->tax_enable == 0) {//if tax_enable is 0 |
| 514 | 514 | |
| 515 | 515 | $taxClassId = Tax::where('country', '')->where('state', 'Any State') |
| 516 | - ->pluck('tax_classes_id')->first(); //In case of India when |
|
| 516 | + ->pluck('tax_classes_id')->first(); //In case of India when |
|
| 517 | 517 | //other tax is available and tax is not enabled |
| 518 | 518 | if ($taxClassId) { |
| 519 | 519 | $rate = $this->getTotalRate($taxClassId, $productid, $taxs); |
@@ -581,10 +581,10 @@ discard block |
||
| 581 | 581 | foreach ($taxes as $key => $tax) { |
| 582 | 582 | if ($taxes[0]) { |
| 583 | 583 | $tax_attribute[$key] = ['name' => $tax->name, 'name1' => $name1, |
| 584 | - 'name2' => $name2, 'name3' => $name3, 'name4' => $name4, |
|
| 585 | - 'rate' => $value, 'rate1'=>$c_gst, 'rate2'=>$s_gst, |
|
| 586 | - 'rate3' => $i_gst, 'rate4'=>$ut_gst, 'state'=>$state_code, |
|
| 587 | - 'origin_state' => $origin_state, ]; |
|
| 584 | + 'name2' => $name2, 'name3' => $name3, 'name4' => $name4, |
|
| 585 | + 'rate' => $value, 'rate1'=>$c_gst, 'rate2'=>$s_gst, |
|
| 586 | + 'rate3' => $i_gst, 'rate4'=>$ut_gst, 'state'=>$state_code, |
|
| 587 | + 'origin_state' => $origin_state, ]; |
|
| 588 | 588 | |
| 589 | 589 | $rate = $tax->rate; |
| 590 | 590 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $from = $request->input('from'); |
| 109 | 109 | $till = $request->input('till'); |
| 110 | 110 | |
| 111 | - return view('themes.default1.invoice.index', compact('name','invoice_no','status','currencies','currency_id','from', |
|
| 111 | + return view('themes.default1.invoice.index', compact('name', 'invoice_no', 'status', 'currencies', 'currency_id', 'from', |
|
| 112 | 112 | |
| 113 | 113 | 'till')); |
| 114 | 114 | } catch (\Exception $ex) { |
@@ -131,35 +131,35 @@ discard block |
||
| 131 | 131 | return \DataTables::of($query->take(100)) |
| 132 | 132 | ->setTotalRecords($query->count()) |
| 133 | 133 | |
| 134 | - ->addColumn('checkbox', function ($model) { |
|
| 134 | + ->addColumn('checkbox', function($model) { |
|
| 135 | 135 | return "<input type='checkbox' class='invoice_checkbox' |
| 136 | 136 | value=".$model->id.' name=select[] id=check>'; |
| 137 | 137 | }) |
| 138 | - ->addColumn('user_id', function ($model) { |
|
| 138 | + ->addColumn('user_id', function($model) { |
|
| 139 | 139 | $first = $this->user->where('id', $model->user_id)->first()->first_name; |
| 140 | 140 | $last = $this->user->where('id', $model->user_id)->first()->last_name; |
| 141 | 141 | $id = $this->user->where('id', $model->user_id)->first()->id; |
| 142 | 142 | |
| 143 | 143 | return '<a href='.url('clients/'.$id).'>'.ucfirst($first).' '.ucfirst($last).'</a>'; |
| 144 | 144 | }) |
| 145 | - ->addColumn('number', function ($model) { |
|
| 145 | + ->addColumn('number', function($model) { |
|
| 146 | 146 | return ucfirst($model->number); |
| 147 | 147 | }) |
| 148 | 148 | |
| 149 | - ->addColumn('date', function ($model) { |
|
| 149 | + ->addColumn('date', function($model) { |
|
| 150 | 150 | $date = ($model->created_at); |
| 151 | 151 | |
| 152 | 152 | return $date; |
| 153 | 153 | // return "<span style='display:none'>$model->id</span>".$date->format('l, F j, Y H:m'); |
| 154 | 154 | }) |
| 155 | - ->addColumn('grand_total', function ($model) { |
|
| 155 | + ->addColumn('grand_total', function($model) { |
|
| 156 | 156 | return $model->grand_total; |
| 157 | 157 | }) |
| 158 | - ->addColumn('status', function ($model) { |
|
| 158 | + ->addColumn('status', function($model) { |
|
| 159 | 159 | return ucfirst($model->status); |
| 160 | 160 | }) |
| 161 | 161 | |
| 162 | - ->addColumn('action', function ($model) { |
|
| 162 | + ->addColumn('action', function($model) { |
|
| 163 | 163 | $action = ''; |
| 164 | 164 | |
| 165 | 165 | $check = $this->checkExecution($model->id); |
@@ -175,25 +175,25 @@ discard block |
||
| 175 | 175 | style='color:white;'> </i> View</a>" |
| 176 | 176 | ." $action"; |
| 177 | 177 | }) |
| 178 | - ->filterColumn('user_id', function ($query, $keyword) { |
|
| 178 | + ->filterColumn('user_id', function($query, $keyword) { |
|
| 179 | 179 | $sql = 'first_name like ?'; |
| 180 | 180 | $query->whereRaw($sql, ["%{$keyword}%"]); |
| 181 | 181 | }) |
| 182 | 182 | |
| 183 | - ->filterColumn('status', function ($query, $keyword) { |
|
| 183 | + ->filterColumn('status', function($query, $keyword) { |
|
| 184 | 184 | $sql = 'status like ?'; |
| 185 | 185 | $query->whereRaw($sql, ["%{$keyword}%"]); |
| 186 | 186 | }) |
| 187 | 187 | |
| 188 | - ->filterColumn('number', function ($query, $keyword) { |
|
| 188 | + ->filterColumn('number', function($query, $keyword) { |
|
| 189 | 189 | $sql = 'number like ?'; |
| 190 | 190 | $query->whereRaw($sql, ["%{$keyword}%"]); |
| 191 | 191 | }) |
| 192 | - ->filterColumn('grand_total', function ($query, $keyword) { |
|
| 192 | + ->filterColumn('grand_total', function($query, $keyword) { |
|
| 193 | 193 | $sql = 'grand_total like ?'; |
| 194 | 194 | $query->whereRaw($sql, ["%{$keyword}%"]); |
| 195 | 195 | }) |
| 196 | - ->filterColumn('date', function ($query, $keyword) { |
|
| 196 | + ->filterColumn('date', function($query, $keyword) { |
|
| 197 | 197 | $sql = 'date like ?'; |
| 198 | 198 | $query->whereRaw($sql, ["%{$keyword}%"]); |
| 199 | 199 | }) |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | { |
| 323 | 323 | $code = ''; |
| 324 | 324 | $codevalue = ''; |
| 325 | - if(\Session::has('code')){//If coupon code is applied get it here from Session |
|
| 325 | + if (\Session::has('code')) {//If coupon code is applied get it here from Session |
|
| 326 | 326 | $code = \Session::get('code'); |
| 327 | 327 | $codevalue = \Session::get('codevalue'); |
| 328 | 328 | } |
| 329 | - return ['code'=> $code , 'codevalue'=>$codevalue] ; |
|
| 329 | + return ['code'=> $code, 'codevalue'=>$codevalue]; |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | public function createInvoiceItems($invoiceid, $cart, $codevalue = '') |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | |
| 435 | 435 | $invoice = Invoice::create(['user_id' => $user_id, 'number' => $number, 'date' => $date, |
| 436 | 436 | 'coupon_code' => $code, 'discount'=>$codeValue, |
| 437 | - 'grand_total' => $grand_total, 'currency' => $currency, 'status' => $status, 'description' => $description, ]); |
|
| 437 | + 'grand_total' => $grand_total, 'currency' => $currency, 'status' => $status, 'description' => $description, ]); |
|
| 438 | 438 | |
| 439 | 439 | $items = $this->createInvoiceItemsByAdmin($invoice->id, $productid, |
| 440 | 440 | $code, $total, $currency, $qty, $agents, $plan, $user_id, $tax_name, $tax_rate); |
@@ -318,11 +318,12 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @return array |
| 320 | 320 | */ |
| 321 | - protected function getCodeFromSession() |
|
| 321 | + protected function getCodeFromSession() |
|
| 322 | 322 | { |
| 323 | 323 | $code = ''; |
| 324 | 324 | $codevalue = ''; |
| 325 | - if(\Session::has('code')){//If coupon code is applied get it here from Session |
|
| 325 | + if(\Session::has('code')) { |
|
| 326 | +//If coupon code is applied get it here from Session |
|
| 326 | 327 | $code = \Session::get('code'); |
| 327 | 328 | $codevalue = \Session::get('codevalue'); |
| 328 | 329 | } |
@@ -510,7 +511,8 @@ discard block |
||
| 510 | 511 | if ($this->tax_option->findOrFail(1)->inclusive == 0) { |
| 511 | 512 | if ($this->tax_option->findOrFail(1)->tax_enable == 1) { |
| 512 | 513 | $taxs = $this->getTaxWhenEnable($productid, $taxs[0], $userid); |
| 513 | - } elseif ($this->tax_option->tax_enable == 0) {//if tax_enable is 0 |
|
| 514 | + } elseif ($this->tax_option->tax_enable == 0) { |
|
| 515 | +//if tax_enable is 0 |
|
| 514 | 516 | |
| 515 | 517 | $taxClassId = Tax::where('country', '')->where('state', 'Any State') |
| 516 | 518 | ->pluck('tax_classes_id')->first(); //In case of India when |
@@ -519,13 +521,15 @@ discard block |
||
| 519 | 521 | $rate = $this->getTotalRate($taxClassId, $productid, $taxs); |
| 520 | 522 | $taxs = $rate['taxes']; |
| 521 | 523 | $rate = $rate['rate']; |
| 522 | - } elseif ($geoip_country != 'IN') {//In case of other country |
|
| 524 | + } elseif ($geoip_country != 'IN') { |
|
| 525 | +//In case of other country |
|
| 523 | 526 | // when tax is available and tax is not enabled(Applicable |
| 524 | 527 | //when Global Tax class for any country and state is not there) |
| 525 | 528 | |
| 526 | 529 | $taxClassId = Tax::where('state', $geoip_state) |
| 527 | 530 | ->orWhere('country', $geoip_country)->pluck('tax_classes_id')->first(); |
| 528 | - if ($taxClassId) { //if state equals the user State |
|
| 531 | + if ($taxClassId) { |
|
| 532 | +//if state equals the user State |
|
| 529 | 533 | $rate = $this->getTotalRate($taxClassId, $productid, $taxs); |
| 530 | 534 | $taxs = $rate['taxes']; |
| 531 | 535 | $rate = $rate['rate']; |
@@ -567,11 +571,13 @@ discard block |
||
| 567 | 571 | $i_gst = 0; |
| 568 | 572 | $ut_gst = 0; |
| 569 | 573 | $state_code = ''; |
| 570 | - if ($user_state != '') {//Get the CGST,SGST,IGST,STATE_CODE of the user |
|
| 574 | + if ($user_state != '') { |
|
| 575 | +//Get the CGST,SGST,IGST,STATE_CODE of the user |
|
| 571 | 576 | $tax = $this->getTaxWhenState($user_state, $productid, $origin_state); |
| 572 | 577 | $taxes = $tax['taxes']; |
| 573 | 578 | $value = $tax['value']; |
| 574 | - } else {//If user from other Country |
|
| 579 | + } else { |
|
| 580 | +//If user from other Country |
|
| 575 | 581 | $tax = $this->getTaxWhenOtherCountry($geoip_state, $geoip_country, $productid); |
| 576 | 582 | $taxes = $tax['taxes']; |
| 577 | 583 | $value = $tax['value']; |
@@ -213,6 +213,6 @@ |
||
| 213 | 213 | if ($promo && $code) { |
| 214 | 214 | return $promo->value; |
| 215 | 215 | } |
| 216 | - return ; |
|
| 216 | + return; |
|
| 217 | 217 | } |
| 218 | 218 | } |
@@ -28,7 +28,8 @@ discard block |
||
| 28 | 28 | $i_gst = $user_state->i_gst; |
| 29 | 29 | $ut_gst = $user_state->ut_gst; |
| 30 | 30 | $state_code = $user_state->state_code; |
| 31 | - if ($state_code == $origin_state) {//If user and origin state are same |
|
| 31 | + if ($state_code == $origin_state) { |
|
| 32 | +//If user and origin state are same |
|
| 32 | 33 | $taxClassId = TaxClass::where('name', 'Intra State GST') |
| 33 | 34 | ->pluck('id')->toArray(); //Get the class Id of state |
| 34 | 35 | if ($taxClassId) { |
@@ -37,7 +38,8 @@ discard block |
||
| 37 | 38 | } else { |
| 38 | 39 | $taxes = [0]; |
| 39 | 40 | } |
| 40 | - } elseif ($state_code != $origin_state && $ut_gst == 'NULL') {//If user is from other state |
|
| 41 | + } elseif ($state_code != $origin_state && $ut_gst == 'NULL') { |
|
| 42 | +//If user is from other state |
|
| 41 | 43 | $taxClassId = TaxClass::where('name', 'Inter State GST') |
| 42 | 44 | ->pluck('id')->toArray(); //Get the class Id of state |
| 43 | 45 | if ($taxClassId) { |
@@ -46,7 +48,8 @@ discard block |
||
| 46 | 48 | } else { |
| 47 | 49 | $taxes = [0]; |
| 48 | 50 | } |
| 49 | - } elseif ($state_code != $origin_state && $ut_gst != 'NULL') {//if user from Union Territory |
|
| 51 | + } elseif ($state_code != $origin_state && $ut_gst != 'NULL') { |
|
| 52 | +//if user from Union Territory |
|
| 50 | 53 | $taxClassId = TaxClass::where('name', 'Union Territory GST') |
| 51 | 54 | ->pluck('id')->toArray(); //Get the class Id of state |
| 52 | 55 | if ($taxClassId) { |
@@ -71,13 +74,15 @@ discard block |
||
| 71 | 74 | ->pluck('tax_classes_id')->first(); |
| 72 | 75 | $value = ''; |
| 73 | 76 | $rate = ''; |
| 74 | - if ($taxClassId) { //if state equals the user State |
|
| 77 | + if ($taxClassId) { |
|
| 78 | +//if state equals the user State |
|
| 75 | 79 | $taxes = $cartController->getTaxByPriority($taxClassId); |
| 76 | 80 | |
| 77 | 81 | // $taxes = $this->cartController::getTaxByPriority($taxClassId); |
| 78 | 82 | $value = $cartController->getValueForOthers($productid, $taxClassId, $taxes); |
| 79 | 83 | $rate = $value; |
| 80 | - } else {//if Tax is selected for Any State Any Country |
|
| 84 | + } else { |
|
| 85 | +//if Tax is selected for Any State Any Country |
|
| 81 | 86 | $taxClassId = Tax::where('country', '')->where('state', 'Any State')->pluck('tax_classes_id')->first(); |
| 82 | 87 | if ($taxClassId) { |
| 83 | 88 | $taxes = $cartController->getTaxByPriority($taxClassId); |