@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | 'zip' => 'required|numeric', |
| 37 | 37 | 'user_name' => 'required|unique:users,user_name,'.$userid, |
| 38 | 38 | 'bussiness' => 'required', |
| 39 | - 'profile_pic' => 'sometimes|mimes:jpeg,jpg,png,gif|max:100000', |
|
| 39 | + 'profile_pic' => 'sometimes|mimes:jpeg,jpg,png,gif|max:100000', |
|
| 40 | 40 | |
| 41 | 41 | ]; |
| 42 | 42 | } |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | $userid = \Auth::user()->id; |
| 46 | 46 | |
| 47 | 47 | return [ |
| 48 | - 'first_name' => 'required|min:3|max:20', |
|
| 48 | + 'first_name' => 'required|min:3|max:20', |
|
| 49 | 49 | 'last_name' => 'required|max:20', |
| 50 | - 'mobile' => 'required|regex:/[0-9]/|min:5|max:20', |
|
| 50 | + 'mobile' => 'required|regex:/[0-9]/|min:5|max:20', |
|
| 51 | 51 | 'mobile_code' => 'required|numeric', |
| 52 | 52 | |
| 53 | 53 | 'zip' => 'required|numeric', |
@@ -198,146 +198,146 @@ discard block |
||
| 198 | 198 | $tax_class_id = TaxProductRelation::where('product_id', $productid)->pluck('tax_class_id')->toArray(); |
| 199 | 199 | |
| 200 | 200 | if ($tax_class_id) {//If the product is allowed for tax (Check in tax_product relation table) |
| 201 | - if ($tax_enable == 1) {//If GST is Enabled |
|
| 202 | - |
|
| 203 | - $state_code = ''; |
|
| 204 | - $c_gst = ''; |
|
| 205 | - $s_gst = ''; |
|
| 206 | - $i_gst = ''; |
|
| 207 | - $ut_gst = ''; |
|
| 208 | - $value = ''; |
|
| 209 | - $rate = ''; |
|
| 210 | - $status = 1; |
|
| 211 | - |
|
| 212 | - if ($user_state != '') {//Get the CGST,SGST,IGST,STATE_CODE of the user |
|
| 213 | - $c_gst = $user_state->c_gst; |
|
| 214 | - $s_gst = $user_state->s_gst; |
|
| 215 | - $i_gst = $user_state->i_gst; |
|
| 216 | - $ut_gst = $user_state->ut_gst; |
|
| 217 | - $state_code = $user_state->state_code; |
|
| 218 | - |
|
| 219 | - if ($state_code == $origin_state) {//If user and origin state are same |
|
| 220 | - $rateForSameState = $this->getTaxWhenIndianSameState($user_state, |
|
| 201 | + if ($tax_enable == 1) {//If GST is Enabled |
|
| 202 | + |
|
| 203 | + $state_code = ''; |
|
| 204 | + $c_gst = ''; |
|
| 205 | + $s_gst = ''; |
|
| 206 | + $i_gst = ''; |
|
| 207 | + $ut_gst = ''; |
|
| 208 | + $value = ''; |
|
| 209 | + $rate = ''; |
|
| 210 | + $status = 1; |
|
| 211 | + |
|
| 212 | + if ($user_state != '') {//Get the CGST,SGST,IGST,STATE_CODE of the user |
|
| 213 | + $c_gst = $user_state->c_gst; |
|
| 214 | + $s_gst = $user_state->s_gst; |
|
| 215 | + $i_gst = $user_state->i_gst; |
|
| 216 | + $ut_gst = $user_state->ut_gst; |
|
| 217 | + $state_code = $user_state->state_code; |
|
| 218 | + |
|
| 219 | + if ($state_code == $origin_state) {//If user and origin state are same |
|
| 220 | + $rateForSameState = $this->getTaxWhenIndianSameState($user_state, |
|
| 221 | 221 | $origin_state, $productid, $c_gst, $s_gst, $state_code, $status); |
| 222 | 222 | |
| 223 | - $taxes = $rateForSameState['taxes']; |
|
| 224 | - $status = $rateForSameState['status']; |
|
| 225 | - $value = $rateForSameState['value']; |
|
| 226 | - } elseif ($state_code != $origin_state && $ut_gst == 'NULL') {//If user is from other state |
|
| 227 | - $rateForOtherState = $this->getTaxWhenIndianOtherState($user_state, |
|
| 223 | + $taxes = $rateForSameState['taxes']; |
|
| 224 | + $status = $rateForSameState['status']; |
|
| 225 | + $value = $rateForSameState['value']; |
|
| 226 | + } elseif ($state_code != $origin_state && $ut_gst == 'NULL') {//If user is from other state |
|
| 227 | + $rateForOtherState = $this->getTaxWhenIndianOtherState($user_state, |
|
| 228 | 228 | $origin_state, $productid, $i_gst, $state_code, $status); |
| 229 | - $taxes = $rateForOtherState['taxes']; |
|
| 230 | - $status = $rateForOtherState['status']; |
|
| 231 | - $value = $rateForOtherState['value']; |
|
| 232 | - } elseif ($state_code != $origin_state && $ut_gst != 'NULL') {//if user from Union Territory |
|
| 233 | - $rateForUnionTerritory = $this->getTaxWhenUnionTerritory($user_state, |
|
| 229 | + $taxes = $rateForOtherState['taxes']; |
|
| 230 | + $status = $rateForOtherState['status']; |
|
| 231 | + $value = $rateForOtherState['value']; |
|
| 232 | + } elseif ($state_code != $origin_state && $ut_gst != 'NULL') {//if user from Union Territory |
|
| 233 | + $rateForUnionTerritory = $this->getTaxWhenUnionTerritory($user_state, |
|
| 234 | 234 | $origin_state, $productid, $c_gst, $ut_gst, $state_code, $status); |
| 235 | - $taxes = $rateForUnionTerritory['taxes']; |
|
| 236 | - $status = $rateForUnionTerritory['status']; |
|
| 237 | - $value = $rateForUnionTerritory['value']; |
|
| 238 | - } |
|
| 239 | - } else {//If user from other Country |
|
| 240 | - $taxClassId = Tax::where('state', $geoip_state) |
|
| 241 | - ->orWhere('country', $geoip_country) |
|
| 242 | - ->pluck('tax_classes_id')->first(); |
|
| 243 | - if ($taxClassId) { //if state equals the user State or country equals user country |
|
| 244 | - $taxForSpecificCountry = $this->getTaxForSpecificCountry($taxClassId, |
|
| 235 | + $taxes = $rateForUnionTerritory['taxes']; |
|
| 236 | + $status = $rateForUnionTerritory['status']; |
|
| 237 | + $value = $rateForUnionTerritory['value']; |
|
| 238 | + } |
|
| 239 | + } else {//If user from other Country |
|
| 240 | + $taxClassId = Tax::where('state', $geoip_state) |
|
| 241 | + ->orWhere('country', $geoip_country) |
|
| 242 | + ->pluck('tax_classes_id')->first(); |
|
| 243 | + if ($taxClassId) { //if state equals the user State or country equals user country |
|
| 244 | + $taxForSpecificCountry = $this->getTaxForSpecificCountry($taxClassId, |
|
| 245 | 245 | $productid, $status); |
| 246 | - $taxes = $taxForSpecificCountry['taxes']; |
|
| 247 | - $status = $taxForSpecificCountry['status']; |
|
| 248 | - $value = $taxForSpecificCountry['value']; |
|
| 249 | - $rate = $taxForSpecificCountry['value']; |
|
| 250 | - } else {//if Tax is selected for Any Country Any State |
|
| 251 | - $taxClassId = Tax::where('country', '') |
|
| 252 | - ->where('state', 'Any State') |
|
| 253 | - ->pluck('tax_classes_id')->first(); |
|
| 254 | - if ($taxClassId) { |
|
| 255 | - $taxForAnyCountry = $this->getTaxForAnyCountry($taxClassId, $productid, $status); |
|
| 256 | - $taxes = $taxForAnyCountry['taxes']; |
|
| 257 | - $status = $taxForAnyCountry['status']; |
|
| 258 | - $value = $taxForAnyCountry['value']; |
|
| 259 | - $rate = $taxForAnyCountry['value']; |
|
| 260 | - } else { |
|
| 261 | - $taxes = [0]; |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - foreach ($taxes as $key => $tax) { |
|
| 246 | + $taxes = $taxForSpecificCountry['taxes']; |
|
| 247 | + $status = $taxForSpecificCountry['status']; |
|
| 248 | + $value = $taxForSpecificCountry['value']; |
|
| 249 | + $rate = $taxForSpecificCountry['value']; |
|
| 250 | + } else {//if Tax is selected for Any Country Any State |
|
| 251 | + $taxClassId = Tax::where('country', '') |
|
| 252 | + ->where('state', 'Any State') |
|
| 253 | + ->pluck('tax_classes_id')->first(); |
|
| 254 | + if ($taxClassId) { |
|
| 255 | + $taxForAnyCountry = $this->getTaxForAnyCountry($taxClassId, $productid, $status); |
|
| 256 | + $taxes = $taxForAnyCountry['taxes']; |
|
| 257 | + $status = $taxForAnyCountry['status']; |
|
| 258 | + $value = $taxForAnyCountry['value']; |
|
| 259 | + $rate = $taxForAnyCountry['value']; |
|
| 260 | + } else { |
|
| 261 | + $taxes = [0]; |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + foreach ($taxes as $key => $tax) { |
|
| 266 | 266 | |
| 267 | 267 | //All the da a attribute that is sent to the checkout Page if tax_compound=0 |
| 268 | - if ($taxes[0]) { |
|
| 269 | - $tax_attribute[$key] = ['name' => $tax->name, 'c_gst'=>$c_gst, |
|
| 270 | - 's_gst' => $s_gst, 'i_gst'=>$i_gst, 'ut_gst'=>$ut_gst, |
|
| 268 | + if ($taxes[0]) { |
|
| 269 | + $tax_attribute[$key] = ['name' => $tax->name, 'c_gst'=>$c_gst, |
|
| 270 | + 's_gst' => $s_gst, 'i_gst'=>$i_gst, 'ut_gst'=>$ut_gst, |
|
| 271 | 271 | 'state' => $state_code, 'origin_state'=>$origin_state, |
| 272 | - 'tax_enable' => $tax_enable, 'rate'=>$value, 'status'=>$status, ]; |
|
| 272 | + 'tax_enable' => $tax_enable, 'rate'=>$value, 'status'=>$status, ]; |
|
| 273 | 273 | |
| 274 | - $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
|
| 274 | + $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
|
| 275 | 275 | |
| 276 | 276 | 'name' => 'no compound', |
| 277 | 277 | 'type' => 'tax', |
| 278 | 278 | 'target' => 'item', |
| 279 | 279 | 'value' => $value, |
| 280 | - ]); |
|
| 281 | - } else { |
|
| 282 | - $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
|
| 283 | - $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
|
| 284 | - 'name' => 'null', |
|
| 285 | - 'type' => 'tax', |
|
| 286 | - 'target' => 'item', |
|
| 287 | - 'value' => '0%', |
|
| 288 | - ]); |
|
| 289 | - } |
|
| 290 | - } |
|
| 291 | - } elseif ($tax_enable == 0) {//If Tax enable is 0 |
|
| 292 | - $status = 1; |
|
| 293 | - if ($this->tax_option->findOrFail(1)->tax_enable == 0) { |
|
| 294 | - $taxClassId = Tax::where('country', '') |
|
| 295 | - ->where('state', 'Any State') |
|
| 296 | - ->pluck('tax_classes_id')->first(); //In case of India when other tax is available and tax is not enabled |
|
| 297 | - if ($taxClassId) { |
|
| 298 | - $taxes = $this->getTaxByPriority($taxClassId); |
|
| 299 | - $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
|
| 300 | - if ($value == 0) { |
|
| 301 | - $status = 0; |
|
| 302 | - } |
|
| 303 | - $rate = $value; |
|
| 304 | - foreach ($taxes as $key => $tax) { |
|
| 305 | - $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
|
| 306 | - $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
|
| 280 | + ]); |
|
| 281 | + } else { |
|
| 282 | + $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
|
| 283 | + $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
|
| 284 | + 'name' => 'null', |
|
| 285 | + 'type' => 'tax', |
|
| 286 | + 'target' => 'item', |
|
| 287 | + 'value' => '0%', |
|
| 288 | + ]); |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | + } elseif ($tax_enable == 0) {//If Tax enable is 0 |
|
| 292 | + $status = 1; |
|
| 293 | + if ($this->tax_option->findOrFail(1)->tax_enable == 0) { |
|
| 294 | + $taxClassId = Tax::where('country', '') |
|
| 295 | + ->where('state', 'Any State') |
|
| 296 | + ->pluck('tax_classes_id')->first(); //In case of India when other tax is available and tax is not enabled |
|
| 297 | + if ($taxClassId) { |
|
| 298 | + $taxes = $this->getTaxByPriority($taxClassId); |
|
| 299 | + $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
|
| 300 | + if ($value == 0) { |
|
| 301 | + $status = 0; |
|
| 302 | + } |
|
| 303 | + $rate = $value; |
|
| 304 | + foreach ($taxes as $key => $tax) { |
|
| 305 | + $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
|
| 306 | + $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
|
| 307 | 307 | |
| 308 | 308 | 'name' => $tax->name, |
| 309 | 309 | 'type' => 'tax', |
| 310 | 310 | 'target' => 'item', |
| 311 | 311 | 'value' => $value, |
| 312 | 312 | ]); |
| 313 | - } |
|
| 314 | - } else {//In case of other country |
|
| 315 | - //when tax is available and tax is not enabled |
|
| 316 | - //(Applicable when Global Tax class for any country and state is not there) |
|
| 317 | - $taxClassId = Tax::where('state', $geoip_state) |
|
| 318 | - ->orWhere('country', $geoip_country) |
|
| 319 | - ->pluck('tax_classes_id')->first(); |
|
| 320 | - if ($taxClassId) { //if state equals the user State |
|
| 321 | - $taxes = $this->getTaxByPriority($taxClassId); |
|
| 322 | - $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
|
| 323 | - if ($value == '') { |
|
| 324 | - $status = 0; |
|
| 325 | - } |
|
| 326 | - $rate = $value; |
|
| 327 | - } |
|
| 328 | - foreach ($taxes as $key => $tax) { |
|
| 329 | - $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
|
| 330 | - $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
|
| 313 | + } |
|
| 314 | + } else {//In case of other country |
|
| 315 | + //when tax is available and tax is not enabled |
|
| 316 | + //(Applicable when Global Tax class for any country and state is not there) |
|
| 317 | + $taxClassId = Tax::where('state', $geoip_state) |
|
| 318 | + ->orWhere('country', $geoip_country) |
|
| 319 | + ->pluck('tax_classes_id')->first(); |
|
| 320 | + if ($taxClassId) { //if state equals the user State |
|
| 321 | + $taxes = $this->getTaxByPriority($taxClassId); |
|
| 322 | + $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
|
| 323 | + if ($value == '') { |
|
| 324 | + $status = 0; |
|
| 325 | + } |
|
| 326 | + $rate = $value; |
|
| 327 | + } |
|
| 328 | + foreach ($taxes as $key => $tax) { |
|
| 329 | + $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
|
| 330 | + $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
|
| 331 | 331 | |
| 332 | 332 | 'name' => $tax->name, |
| 333 | 333 | 'type' => 'tax', |
| 334 | 334 | 'target' => 'item', |
| 335 | 335 | 'value' => $value, |
| 336 | 336 | ]); |
| 337 | - } |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | 341 | } else { |
| 342 | 342 | $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
| 343 | 343 | $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | 'attributes' => ['tax' => $tax_attribute, |
| 356 | 356 | 'currency' => $currency_attribute, ], ]; |
| 357 | 357 | } catch (\Exception $ex) { |
| 358 | - return redirect()->back()->with('fails',$ex->getMessage()); |
|
| 358 | + return redirect()->back()->with('fails',$ex->getMessage()); |
|
| 359 | 359 | Bugsnag::notifyException($ex); |
| 360 | 360 | |
| 361 | 361 | throw new \Exception('Can not check the tax'); |
@@ -355,7 +355,7 @@ |
||
| 355 | 355 | 'attributes' => ['tax' => $tax_attribute, |
| 356 | 356 | 'currency' => $currency_attribute, ], ]; |
| 357 | 357 | } catch (\Exception $ex) { |
| 358 | - return redirect()->back()->with('fails',$ex->getMessage()); |
|
| 358 | + return redirect()->back()->with('fails', $ex->getMessage()); |
|
| 359 | 359 | Bugsnag::notifyException($ex); |
| 360 | 360 | |
| 361 | 361 | throw new \Exception('Can not check the tax'); |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | $geoip_country = ''; |
| 198 | 198 | if (\Auth::user()){ |
| 199 | 199 | if (\Auth::user()->role == 'admin') { |
| 200 | - $geoip_country = $user_country; |
|
| 200 | + $geoip_country = $user_country; |
|
| 201 | 201 | } elseif(\Auth::user()->role == 'user') { |
| 202 | - $geoip_country = \Auth::user()->country; |
|
| 202 | + $geoip_country = \Auth::user()->country; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | if ($geoip_country == '') { |
@@ -217,10 +217,10 @@ discard block |
||
| 217 | 217 | if (\Auth::user()->role == 'admin') { |
| 218 | 218 | $geoip_state = $user_state; |
| 219 | 219 | } elseif(\Auth::user()->role == 'user') { |
| 220 | - $geoip_state = \Auth::user()->state; |
|
| 220 | + $geoip_state = \Auth::user()->state; |
|
| 221 | 221 | } |
| 222 | 222 | if ($geoip_state == '') { |
| 223 | - $geoip_state_array = \App\Http\Controllers\Front\CartController::getStateByCode($state_code); |
|
| 223 | + $geoip_state_array = \App\Http\Controllers\Front\CartController::getStateByCode($state_code); |
|
| 224 | 224 | if (array_key_exists('id', $geoip_state_array)) { |
| 225 | 225 | $geoip_state = $geoip_state_array['id']; |
| 226 | 226 | } |
@@ -195,10 +195,10 @@ discard block |
||
| 195 | 195 | public function getGeoipCountry($country_iso, $user_country = '') |
| 196 | 196 | { |
| 197 | 197 | $geoip_country = ''; |
| 198 | - if (\Auth::user()){ |
|
| 198 | + if (\Auth::user()) { |
|
| 199 | 199 | if (\Auth::user()->role == 'admin') { |
| 200 | 200 | $geoip_country = $user_country; |
| 201 | - } elseif(\Auth::user()->role == 'user') { |
|
| 201 | + } elseif (\Auth::user()->role == 'user') { |
|
| 202 | 202 | $geoip_country = \Auth::user()->country; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | public function getGeoipState($state_code, $user_state = '') |
| 214 | 214 | { |
| 215 | 215 | $geoip_state = ''; |
| 216 | - if (\Auth::user()){ |
|
| 216 | + if (\Auth::user()) { |
|
| 217 | 217 | if (\Auth::user()->role == 'admin') { |
| 218 | 218 | $geoip_state = $user_state; |
| 219 | - } elseif(\Auth::user()->role == 'user') { |
|
| 219 | + } elseif (\Auth::user()->role == 'user') { |
|
| 220 | 220 | $geoip_state = \Auth::user()->state; |
| 221 | 221 | } |
| 222 | 222 | if ($geoip_state == '') { |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | public function getGeoipCountry($country_iso, $user_country = '') |
| 196 | 196 | { |
| 197 | 197 | $geoip_country = ''; |
| 198 | - if (\Auth::user()){ |
|
| 198 | + if (\Auth::user()) { |
|
| 199 | 199 | if (\Auth::user()->role == 'admin') { |
| 200 | 200 | $geoip_country = $user_country; |
| 201 | 201 | } elseif(\Auth::user()->role == 'user') { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | public function getGeoipState($state_code, $user_state = '') |
| 214 | 214 | { |
| 215 | 215 | $geoip_state = ''; |
| 216 | - if (\Auth::user()){ |
|
| 216 | + if (\Auth::user()) { |
|
| 217 | 217 | if (\Auth::user()->role == 'admin') { |
| 218 | 218 | $geoip_state = $user_state; |
| 219 | 219 | } elseif(\Auth::user()->role == 'user') { |