Completed
Pull Request — development (#452)
by Ashutosh
23:51 queued 11:49
created
app/Http/Controllers/Order/BaseInvoiceController.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                 'currency'                        => $currency, 'status' => 'pending', 'description' => $description, ]);
62 62
 
63 63
             $items = $this->createInvoiceItemsByAdmin($invoice->id, $productid,
64
-             $code, $total, $currency, $qty, $plan, $user_id, $tax_name, $tax_rate);
64
+                $code, $total, $currency, $qty, $plan, $user_id, $tax_name, $tax_rate);
65 65
             $result = $this->getMessage($items, $user_id);
66 66
         } catch (\Exception $ex) {
67 67
             app('log')->useDailyFiles(storage_path().'/laravel.log');
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         $state_code = $user_state->state_code;
89 89
         if ($state_code == $origin_state) {//If user and origin state are same
90 90
             $taxClassId = TaxClass::where('name', 'Intra State GST')
91
-             ->pluck('id')->toArray(); //Get the class Id  of state
91
+                ->pluck('id')->toArray(); //Get the class Id  of state
92 92
             if ($taxClassId) {
93 93
                 $taxes = $cartController->getTaxByPriority($taxClassId);
94 94
                 $value = $cartController->getValueForSameState($productid, $c_gst, $s_gst, $taxClassId, $taxes);
Please login to merge, or discard this patch.
app/Http/Controllers/Common/TemplateController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
     public function getTemplates()
123 123
     {
124 124
         return \DataTables::of($this->template->select('id', 'name', 'type')->get())
125
-                        ->addColumn('checkbox', function ($model) {
125
+                        ->addColumn('checkbox', function($model) {
126 126
                             return "<input type='checkbox' class='template_checkbox' 
127 127
                             value=".$model->id.' name=select[] id=check>';
128 128
                         })
129 129
 
130
-                         ->addColumn('name', function ($model) {
130
+                         ->addColumn('name', function($model) {
131 131
                              return $model->name;
132 132
                          })
133
-                        ->addColumn('type', function ($model) {
133
+                        ->addColumn('type', function($model) {
134 134
                             return $this->type->where('id', $model->type)->first()->name;
135 135
                         })
136
-                        ->addColumn('action', function ($model) {
136
+                        ->addColumn('action', function($model) {
137 137
                             return '<a href='.url('templates/'.$model->id.'/edit').
138 138
                             " class='btn btn-sm btn-primary'>Edit</a>";
139 139
                         })
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             $data = $page_controller->transform($type, $data, $transform);
282 282
             $settings = \App\Model\Common\Setting::find(1);
283 283
             $fromname = $settings->company;
284
-            \Mail::send('emails.mail', ['data' => $data], function ($m) use ($from, $to, $subject, $fromname, $toname, $cc, $attach) {
284
+            \Mail::send('emails.mail', ['data' => $data], function($m) use ($from, $to, $subject, $fromname, $toname, $cc, $attach) {
285 285
                 $m->from($from, $fromname);
286 286
 
287 287
                 $m->to($to, $toname)->subject($subject);
Please login to merge, or discard this patch.
app/Http/Controllers/Front/CartController.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -192,149 +192,149 @@  discard block
 block discarded – undo
192 192
                 $tax_class_id = TaxProductRelation::where('product_id', $productid)->pluck('tax_class_id')->toArray();
193 193
 
194 194
                 if ($tax_class_id) {//If the product is allowed for tax (Check in tax_product relation table)
195
-                   if ($tax_enable == 1) {//If GST is Enabled
196
-
197
-                       $state_code = '';
198
-                       $c_gst = '';
199
-                       $s_gst = '';
200
-                       $i_gst = '';
201
-                       $ut_gst = '';
202
-                       $value = '';
203
-                       $rate = '';
204
-                       $status = 1;
205
-
206
-                       if ($user_state != '') {//Get the CGST,SGST,IGST,STATE_CODE of the user
207
-                           $c_gst = $user_state->c_gst;
208
-                           $s_gst = $user_state->s_gst;
209
-                           $i_gst = $user_state->i_gst;
210
-                           $ut_gst = $user_state->ut_gst;
211
-                           $state_code = $user_state->state_code;
212
-
213
-                           if ($state_code == $origin_state) {//If user and origin state are same
214
-                               $rateForSameState = $this->getTaxWhenIndianSameState($user_state,
195
+                    if ($tax_enable == 1) {//If GST is Enabled
196
+
197
+                        $state_code = '';
198
+                        $c_gst = '';
199
+                        $s_gst = '';
200
+                        $i_gst = '';
201
+                        $ut_gst = '';
202
+                        $value = '';
203
+                        $rate = '';
204
+                        $status = 1;
205
+
206
+                        if ($user_state != '') {//Get the CGST,SGST,IGST,STATE_CODE of the user
207
+                            $c_gst = $user_state->c_gst;
208
+                            $s_gst = $user_state->s_gst;
209
+                            $i_gst = $user_state->i_gst;
210
+                            $ut_gst = $user_state->ut_gst;
211
+                            $state_code = $user_state->state_code;
212
+
213
+                            if ($state_code == $origin_state) {//If user and origin state are same
214
+                                $rateForSameState = $this->getTaxWhenIndianSameState($user_state,
215 215
                                 $origin_state, $productid, $c_gst, $s_gst, $state_code, $status);
216 216
 
217
-                               $taxes = $rateForSameState['taxes'];
218
-                               $status = $rateForSameState['status'];
219
-                               $value = $rateForSameState['value'];
220
-                           } elseif ($state_code != $origin_state && $ut_gst == 'NULL') {//If user is from other state
221
-                               $rateForOtherState = $this->getTaxWhenIndianOtherState($user_state,
217
+                                $taxes = $rateForSameState['taxes'];
218
+                                $status = $rateForSameState['status'];
219
+                                $value = $rateForSameState['value'];
220
+                            } elseif ($state_code != $origin_state && $ut_gst == 'NULL') {//If user is from other state
221
+                                $rateForOtherState = $this->getTaxWhenIndianOtherState($user_state,
222 222
                                 $origin_state, $productid, $i_gst, $state_code, $status);
223
-                               $taxes = $rateForOtherState['taxes'];
224
-                               $status = $rateForOtherState['status'];
225
-                               $value = $rateForOtherState['value'];
226
-                           } elseif ($state_code != $origin_state && $ut_gst != 'NULL') {//if user from Union Territory
227
-                               $rateForUnionTerritory = $this->getTaxWhenUnionTerritory($user_state,
223
+                                $taxes = $rateForOtherState['taxes'];
224
+                                $status = $rateForOtherState['status'];
225
+                                $value = $rateForOtherState['value'];
226
+                            } elseif ($state_code != $origin_state && $ut_gst != 'NULL') {//if user from Union Territory
227
+                                $rateForUnionTerritory = $this->getTaxWhenUnionTerritory($user_state,
228 228
                                 $origin_state, $productid, $c_gst, $ut_gst, $state_code, $status);
229
-                               $taxes = $rateForUnionTerritory['taxes'];
230
-                               $status = $rateForUnionTerritory['status'];
231
-                               $value = $rateForUnionTerritory['value'];
232
-                           }
233
-                       } else {//If user from other Country
234
-                           $taxClassId = Tax::where('state', $geoip_state)
235
-                           ->orWhere('country', $geoip_country)
236
-                           ->pluck('tax_classes_id')->first();
237
-                           if ($taxClassId) { //if state equals the user State or country equals user country
238
-                               $taxForSpecificCountry = $this->getTaxForSpecificCountry($taxClassId,
229
+                                $taxes = $rateForUnionTerritory['taxes'];
230
+                                $status = $rateForUnionTerritory['status'];
231
+                                $value = $rateForUnionTerritory['value'];
232
+                            }
233
+                        } else {//If user from other Country
234
+                            $taxClassId = Tax::where('state', $geoip_state)
235
+                            ->orWhere('country', $geoip_country)
236
+                            ->pluck('tax_classes_id')->first();
237
+                            if ($taxClassId) { //if state equals the user State or country equals user country
238
+                                $taxForSpecificCountry = $this->getTaxForSpecificCountry($taxClassId,
239 239
                                 $productid, $status);
240
-                               $taxes = $taxForSpecificCountry['taxes'];
241
-                               $status = $taxForSpecificCountry['status'];
242
-                               $value = $taxForSpecificCountry['value'];
243
-                               $rate = $taxForSpecificCountry['value'];
244
-                           } else {//if Tax is selected for Any Country Any State
245
-                               $taxClassId = Tax::where('country', '')
246
-                               ->where('state', 'Any State')
247
-                               ->pluck('tax_classes_id')->first();
248
-                               if ($taxClassId) {
249
-                                   $taxForAnyCountry = $this->getTaxForAnyCountry($taxClassId, $productid, $status);
250
-                                   $taxes = $taxForAnyCountry['taxes'];
251
-                                   $status = $taxForAnyCountry['status'];
252
-                                   $value = $taxForAnyCountry['value'];
253
-                                   $rate = $taxForAnyCountry['value'];
254
-                               } else {
255
-                                   $taxes = [0];
256
-                               }
257
-                           }
258
-                       }
259
-                       foreach ($taxes as $key => $tax) {
240
+                                $taxes = $taxForSpecificCountry['taxes'];
241
+                                $status = $taxForSpecificCountry['status'];
242
+                                $value = $taxForSpecificCountry['value'];
243
+                                $rate = $taxForSpecificCountry['value'];
244
+                            } else {//if Tax is selected for Any Country Any State
245
+                                $taxClassId = Tax::where('country', '')
246
+                                ->where('state', 'Any State')
247
+                                ->pluck('tax_classes_id')->first();
248
+                                if ($taxClassId) {
249
+                                    $taxForAnyCountry = $this->getTaxForAnyCountry($taxClassId, $productid, $status);
250
+                                    $taxes = $taxForAnyCountry['taxes'];
251
+                                    $status = $taxForAnyCountry['status'];
252
+                                    $value = $taxForAnyCountry['value'];
253
+                                    $rate = $taxForAnyCountry['value'];
254
+                                } else {
255
+                                    $taxes = [0];
256
+                                }
257
+                            }
258
+                        }
259
+                        foreach ($taxes as $key => $tax) {
260 260
 
261 261
                                     //All the da a attribute that is sent to the checkout Page if tax_compound=0
262
-                           if ($taxes[0]) {
263
-                               $tax_attribute[$key] = ['name' => $tax->name, 'c_gst'=>$c_gst,
264
-                               's_gst'                        => $s_gst, 'i_gst'=>$i_gst, 'ut_gst'=>$ut_gst,
262
+                            if ($taxes[0]) {
263
+                                $tax_attribute[$key] = ['name' => $tax->name, 'c_gst'=>$c_gst,
264
+                                's_gst'                        => $s_gst, 'i_gst'=>$i_gst, 'ut_gst'=>$ut_gst,
265 265
                                 'state'                       => $state_code, 'origin_state'=>$origin_state,
266
-                                 'tax_enable'                 => $tax_enable, 'rate'=>$value, 'status'=>$status, ];
266
+                                    'tax_enable'                 => $tax_enable, 'rate'=>$value, 'status'=>$status, ];
267 267
 
268
-                               $taxCondition[0] = new \Darryldecode\Cart\CartCondition([
268
+                                $taxCondition[0] = new \Darryldecode\Cart\CartCondition([
269 269
 
270 270
                                             'name'   => 'no compound',
271 271
                                             'type'   => 'tax',
272 272
                                             'target' => 'item',
273 273
                                             'value'  => $value,
274
-                                          ]);
275
-                           } else {
276
-                               $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0];
277
-                               $taxCondition[0] = new \Darryldecode\Cart\CartCondition([
278
-                                           'name'   => 'null',
279
-                                           'type'   => 'tax',
280
-                                           'target' => 'item',
281
-                                           'value'  => '0%',
282
-                                         ]);
283
-                           }
284
-                       }
285
-                   } elseif ($tax_enable == 0) {//If Tax enable is 0
286
-                       $status = 1;
287
-                       if ($this->tax_option->findOrFail(1)->tax_enable == 0) {
288
-                           $taxClassId = Tax::where('country', '')
289
-                           ->where('state', 'Any State')
290
-                           ->pluck('tax_classes_id')->first(); //In case of India when
291
-                           // other tax is available and tax is not enabled
292
-                           if ($taxClassId) {
293
-                               $taxes = $this->getTaxByPriority($taxClassId);
294
-                               $value = $this->getValueForOthers($productid, $taxClassId, $taxes);
295
-                               if ($value == 0) {
296
-                                   $status = 0;
297
-                               }
298
-                               $rate = $value;
299
-                               foreach ($taxes as $key => $tax) {
300
-                                   $tax_attribute[$key] = ['name' => $tax->name,
301
-                                   'rate'                         => $value, 'tax_enable'=>0, 'status' => $status, ];
302
-                                   $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([
274
+                                            ]);
275
+                            } else {
276
+                                $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0];
277
+                                $taxCondition[0] = new \Darryldecode\Cart\CartCondition([
278
+                                            'name'   => 'null',
279
+                                            'type'   => 'tax',
280
+                                            'target' => 'item',
281
+                                            'value'  => '0%',
282
+                                            ]);
283
+                            }
284
+                        }
285
+                    } elseif ($tax_enable == 0) {//If Tax enable is 0
286
+                        $status = 1;
287
+                        if ($this->tax_option->findOrFail(1)->tax_enable == 0) {
288
+                            $taxClassId = Tax::where('country', '')
289
+                            ->where('state', 'Any State')
290
+                            ->pluck('tax_classes_id')->first(); //In case of India when
291
+                            // other tax is available and tax is not enabled
292
+                            if ($taxClassId) {
293
+                                $taxes = $this->getTaxByPriority($taxClassId);
294
+                                $value = $this->getValueForOthers($productid, $taxClassId, $taxes);
295
+                                if ($value == 0) {
296
+                                    $status = 0;
297
+                                }
298
+                                $rate = $value;
299
+                                foreach ($taxes as $key => $tax) {
300
+                                    $tax_attribute[$key] = ['name' => $tax->name,
301
+                                    'rate'                         => $value, 'tax_enable'=>0, 'status' => $status, ];
302
+                                    $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([
303 303
 
304 304
                                             'name'   => $tax->name,
305 305
                                             'type'   => 'tax',
306 306
                                             'target' => 'item',
307 307
                                             'value'  => $value,
308 308
                                         ]);
309
-                               }
310
-                           } else {//In case of other country
311
-                               //when tax is available and tax is not enabled
312
-                               //(Applicable when Global Tax class for any country and state is not there)
313
-                               $taxClassId = Tax::where('state', $geoip_state)
314
-                               ->orWhere('country', $geoip_country)
315
-                               ->pluck('tax_classes_id')->first();
316
-                               if ($taxClassId) { //if state equals the user State
317
-                                   $taxes = $this->getTaxByPriority($taxClassId);
318
-                                   $value = $this->getValueForOthers($productid, $taxClassId, $taxes);
319
-                                   if ($value == '') {
320
-                                       $status = 0;
321
-                                   }
322
-                                   $rate = $value;
323
-                               }
324
-                               foreach ($taxes as $key => $tax) {
325
-                                   $tax_attribute[$key] = ['name' => $tax->name,
326
-                                   'rate'                         => $value, 'tax_enable'=>0, 'status' => $status, ];
327
-                                   $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([
309
+                                }
310
+                            } else {//In case of other country
311
+                                //when tax is available and tax is not enabled
312
+                                //(Applicable when Global Tax class for any country and state is not there)
313
+                                $taxClassId = Tax::where('state', $geoip_state)
314
+                                ->orWhere('country', $geoip_country)
315
+                                ->pluck('tax_classes_id')->first();
316
+                                if ($taxClassId) { //if state equals the user State
317
+                                    $taxes = $this->getTaxByPriority($taxClassId);
318
+                                    $value = $this->getValueForOthers($productid, $taxClassId, $taxes);
319
+                                    if ($value == '') {
320
+                                        $status = 0;
321
+                                    }
322
+                                    $rate = $value;
323
+                                }
324
+                                foreach ($taxes as $key => $tax) {
325
+                                    $tax_attribute[$key] = ['name' => $tax->name,
326
+                                    'rate'                         => $value, 'tax_enable'=>0, 'status' => $status, ];
327
+                                    $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([
328 328
 
329 329
                                             'name'   => $tax->name,
330 330
                                             'type'   => 'tax',
331 331
                                             'target' => 'item',
332 332
                                             'value'  => $value,
333 333
                                         ]);
334
-                               }
335
-                           }
336
-                       }
337
-                   }
334
+                                }
335
+                            }
336
+                        }
337
+                    }
338 338
                 } else {
339 339
                     $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0];
340 340
                     $taxCondition[0] = new \Darryldecode\Cart\CartCondition([
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
         $value = '';
414 414
         $value = $taxes->toArray()[0]['active'] ?
415 415
              (TaxProductRelation::where('product_id', $productid)
416
-              ->where('tax_class_id', $taxClassId)->count() ? $ut_gst + $c_gst.'%' : 0) : 0;
416
+                ->where('tax_class_id', $taxClassId)->count() ? $ut_gst + $c_gst.'%' : 0) : 0;
417 417
 
418 418
         return $value;
419 419
     }
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
         $otherRate = 0;
431 431
         $status = $taxes->toArray()[0]['active'];
432 432
         if ($status && (TaxProductRelation::where('product_id', $productid)
433
-          ->where('tax_class_id', $taxClassId)->count() > 0)) {
433
+            ->where('tax_class_id', $taxClassId)->count() > 0)) {
434 434
             $otherRate = Tax::where('tax_classes_id', $taxClassId)->first()->rate;
435 435
         }
436 436
         $value = $otherRate.'%';
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
             if ($subregion) {
712 712
                 $result = ['id' => $subregion->state_subdivision_code,
713 713
 
714
-                     'name' => $subregion->state_subdivision_name, ];
714
+                        'name' => $subregion->state_subdivision_name, ];
715 715
             }
716 716
 
717 717
             return $result;
Please login to merge, or discard this patch.