@@ -46,7 +46,7 @@ |
||
| 46 | 46 | return view('themes.default1.common.dashboard', compact('totalSalesINR', 'totalSalesUSD', |
| 47 | 47 | 'yearlySalesINR', 'yearlySalesUSD', 'monthlySalesINR', 'monthlySalesUSD', 'users', |
| 48 | 48 | |
| 49 | - 'count_users', 'arraylists', 'productSoldlists','orders','subscriptions','invoices', |
|
| 49 | + 'count_users', 'arraylists', 'productSoldlists', 'orders', 'subscriptions', 'invoices', |
|
| 50 | 50 | 'products', 'arrayCountList')); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -187,147 +187,147 @@ |
||
| 187 | 187 | $tax_class_id = TaxProductRelation::where('product_id', $productid)->pluck('tax_class_id')->toArray(); |
| 188 | 188 | |
| 189 | 189 | if ($tax_class_id) {//If the product is allowed for tax (Check in tax_product relation table) |
| 190 | - if ($tax_enable == 1) {//If GST is Enabled |
|
| 191 | - |
|
| 192 | - $state_code = ''; |
|
| 193 | - $c_gst = ''; |
|
| 194 | - $s_gst = ''; |
|
| 195 | - $i_gst = ''; |
|
| 196 | - $ut_gst = ''; |
|
| 197 | - $value = ''; |
|
| 198 | - $rate = ''; |
|
| 199 | - $status = 1; |
|
| 200 | - |
|
| 201 | - if ($user_state != '') {//Get the CGST,SGST,IGST,STATE_CODE of the user |
|
| 202 | - $c_gst = $user_state->c_gst; |
|
| 203 | - $s_gst = $user_state->s_gst; |
|
| 204 | - $i_gst = $user_state->i_gst; |
|
| 205 | - $ut_gst = $user_state->ut_gst; |
|
| 206 | - $state_code = $user_state->state_code; |
|
| 207 | - |
|
| 208 | - if ($state_code == $origin_state) {//If user and origin state are same |
|
| 209 | - $rateForSameState = $this->getTaxWhenIndianSameState($user_state, |
|
| 190 | + if ($tax_enable == 1) {//If GST is Enabled |
|
| 191 | + |
|
| 192 | + $state_code = ''; |
|
| 193 | + $c_gst = ''; |
|
| 194 | + $s_gst = ''; |
|
| 195 | + $i_gst = ''; |
|
| 196 | + $ut_gst = ''; |
|
| 197 | + $value = ''; |
|
| 198 | + $rate = ''; |
|
| 199 | + $status = 1; |
|
| 200 | + |
|
| 201 | + if ($user_state != '') {//Get the CGST,SGST,IGST,STATE_CODE of the user |
|
| 202 | + $c_gst = $user_state->c_gst; |
|
| 203 | + $s_gst = $user_state->s_gst; |
|
| 204 | + $i_gst = $user_state->i_gst; |
|
| 205 | + $ut_gst = $user_state->ut_gst; |
|
| 206 | + $state_code = $user_state->state_code; |
|
| 207 | + |
|
| 208 | + if ($state_code == $origin_state) {//If user and origin state are same |
|
| 209 | + $rateForSameState = $this->getTaxWhenIndianSameState($user_state, |
|
| 210 | 210 | $origin_state, $productid, $c_gst, $s_gst, $state_code, $status); |
| 211 | 211 | |
| 212 | - $taxes = $rateForSameState['taxes']; |
|
| 213 | - $status = $rateForSameState['status']; |
|
| 214 | - $value = $rateForSameState['value']; |
|
| 215 | - } elseif ($state_code != $origin_state && $ut_gst == 'NULL') {//If user is from other state |
|
| 216 | - $rateForOtherState = $this->getTaxWhenIndianOtherState($user_state, |
|
| 212 | + $taxes = $rateForSameState['taxes']; |
|
| 213 | + $status = $rateForSameState['status']; |
|
| 214 | + $value = $rateForSameState['value']; |
|
| 215 | + } elseif ($state_code != $origin_state && $ut_gst == 'NULL') {//If user is from other state |
|
| 216 | + $rateForOtherState = $this->getTaxWhenIndianOtherState($user_state, |
|
| 217 | 217 | $origin_state, $productid, $i_gst, $state_code, $status); |
| 218 | - $taxes = $rateForOtherState['taxes']; |
|
| 219 | - $status = $rateForOtherState['status']; |
|
| 220 | - $value = $rateForOtherState['value']; |
|
| 221 | - } elseif ($state_code != $origin_state && $ut_gst != 'NULL') {//if user from Union Territory |
|
| 222 | - $rateForUnionTerritory = $this->getTaxWhenUnionTerritory($user_state, |
|
| 218 | + $taxes = $rateForOtherState['taxes']; |
|
| 219 | + $status = $rateForOtherState['status']; |
|
| 220 | + $value = $rateForOtherState['value']; |
|
| 221 | + } elseif ($state_code != $origin_state && $ut_gst != 'NULL') {//if user from Union Territory |
|
| 222 | + $rateForUnionTerritory = $this->getTaxWhenUnionTerritory($user_state, |
|
| 223 | 223 | $origin_state, $productid, $c_gst, $ut_gst, $state_code, $status); |
| 224 | - $taxes = $rateForUnionTerritory['taxes']; |
|
| 225 | - $status = $rateForUnionTerritory['status']; |
|
| 226 | - $value = $rateForUnionTerritory['value']; |
|
| 227 | - } |
|
| 228 | - } else {//If user from other Country |
|
| 229 | - $taxClassId = Tax::where('state', $geoip_state) |
|
| 230 | - ->orWhere('country', $geoip_country) |
|
| 231 | - ->pluck('tax_classes_id')->first(); |
|
| 232 | - if ($taxClassId) { //if state equals the user State or country equals user country |
|
| 233 | - $taxForSpecificCountry = $this->getTaxForSpecificCountry($taxClassId, |
|
| 224 | + $taxes = $rateForUnionTerritory['taxes']; |
|
| 225 | + $status = $rateForUnionTerritory['status']; |
|
| 226 | + $value = $rateForUnionTerritory['value']; |
|
| 227 | + } |
|
| 228 | + } else {//If user from other Country |
|
| 229 | + $taxClassId = Tax::where('state', $geoip_state) |
|
| 230 | + ->orWhere('country', $geoip_country) |
|
| 231 | + ->pluck('tax_classes_id')->first(); |
|
| 232 | + if ($taxClassId) { //if state equals the user State or country equals user country |
|
| 233 | + $taxForSpecificCountry = $this->getTaxForSpecificCountry($taxClassId, |
|
| 234 | 234 | $productid, $status); |
| 235 | - $taxes = $taxForSpecificCountry['taxes']; |
|
| 236 | - $status = $taxForSpecificCountry['status']; |
|
| 237 | - $value = $taxForSpecificCountry['value']; |
|
| 238 | - $rate = $taxForSpecificCountry['value']; |
|
| 239 | - } else {//if Tax is selected for Any Country Any State |
|
| 240 | - $taxClassId = Tax::where('country', '') |
|
| 241 | - ->where('state', 'Any State') |
|
| 242 | - ->pluck('tax_classes_id')->first(); |
|
| 243 | - if ($taxClassId) { |
|
| 244 | - $taxForAnyCountry = $this->getTaxForAnyCountry($taxClassId, $productid, $status); |
|
| 245 | - $taxes = $taxForAnyCountry['taxes']; |
|
| 246 | - $status = $taxForAnyCountry['status']; |
|
| 247 | - $value = $taxForAnyCountry['value']; |
|
| 248 | - $rate = $taxForAnyCountry['value']; |
|
| 249 | - } else { |
|
| 250 | - $taxes = [0]; |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - foreach ($taxes as $key => $tax) { |
|
| 235 | + $taxes = $taxForSpecificCountry['taxes']; |
|
| 236 | + $status = $taxForSpecificCountry['status']; |
|
| 237 | + $value = $taxForSpecificCountry['value']; |
|
| 238 | + $rate = $taxForSpecificCountry['value']; |
|
| 239 | + } else {//if Tax is selected for Any Country Any State |
|
| 240 | + $taxClassId = Tax::where('country', '') |
|
| 241 | + ->where('state', 'Any State') |
|
| 242 | + ->pluck('tax_classes_id')->first(); |
|
| 243 | + if ($taxClassId) { |
|
| 244 | + $taxForAnyCountry = $this->getTaxForAnyCountry($taxClassId, $productid, $status); |
|
| 245 | + $taxes = $taxForAnyCountry['taxes']; |
|
| 246 | + $status = $taxForAnyCountry['status']; |
|
| 247 | + $value = $taxForAnyCountry['value']; |
|
| 248 | + $rate = $taxForAnyCountry['value']; |
|
| 249 | + } else { |
|
| 250 | + $taxes = [0]; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + foreach ($taxes as $key => $tax) { |
|
| 255 | 255 | |
| 256 | 256 | //All the da a attribute that is sent to the checkout Page if tax_compound=0 |
| 257 | - if ($taxes[0]) { |
|
| 258 | - $tax_attribute[$key] = ['name' => $tax->name, 'c_gst'=>$c_gst, |
|
| 259 | - 's_gst' => $s_gst, 'i_gst'=>$i_gst, 'ut_gst'=>$ut_gst, |
|
| 257 | + if ($taxes[0]) { |
|
| 258 | + $tax_attribute[$key] = ['name' => $tax->name, 'c_gst'=>$c_gst, |
|
| 259 | + 's_gst' => $s_gst, 'i_gst'=>$i_gst, 'ut_gst'=>$ut_gst, |
|
| 260 | 260 | 'state' => $state_code, 'origin_state'=>$origin_state, |
| 261 | - 'tax_enable' => $tax_enable, 'rate'=>$value, 'status'=>$status, ]; |
|
| 261 | + 'tax_enable' => $tax_enable, 'rate'=>$value, 'status'=>$status, ]; |
|
| 262 | 262 | |
| 263 | - $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
|
| 263 | + $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
|
| 264 | 264 | |
| 265 | 265 | 'name' => 'no compound', |
| 266 | 266 | 'type' => 'tax', |
| 267 | 267 | 'target' => 'item', |
| 268 | 268 | 'value' => $value, |
| 269 | - ]); |
|
| 270 | - } else { |
|
| 271 | - $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
|
| 272 | - $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
|
| 273 | - 'name' => 'null', |
|
| 274 | - 'type' => 'tax', |
|
| 275 | - 'target' => 'item', |
|
| 276 | - 'value' => '0%', |
|
| 277 | - ]); |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - } elseif ($tax_enable == 0) {//If Tax enable is 0 |
|
| 281 | - $status = 1; |
|
| 282 | - if ($this->tax_option->findOrFail(1)->tax_enable == 0) { |
|
| 283 | - $taxClassId = Tax::where('country', '') |
|
| 284 | - ->where('state', 'Any State') |
|
| 285 | - ->pluck('tax_classes_id')->first(); //In case of India when other |
|
| 286 | - //tax is available and tax is not enabled |
|
| 287 | - if ($taxClassId) { |
|
| 288 | - $taxes = $this->getTaxByPriority($taxClassId); |
|
| 289 | - $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
|
| 290 | - if ($value == 0) { |
|
| 291 | - $status = 0; |
|
| 292 | - } |
|
| 293 | - $rate = $value; |
|
| 294 | - foreach ($taxes as $key => $tax) { |
|
| 295 | - $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
|
| 296 | - $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
|
| 269 | + ]); |
|
| 270 | + } else { |
|
| 271 | + $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
|
| 272 | + $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |
|
| 273 | + 'name' => 'null', |
|
| 274 | + 'type' => 'tax', |
|
| 275 | + 'target' => 'item', |
|
| 276 | + 'value' => '0%', |
|
| 277 | + ]); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + } elseif ($tax_enable == 0) {//If Tax enable is 0 |
|
| 281 | + $status = 1; |
|
| 282 | + if ($this->tax_option->findOrFail(1)->tax_enable == 0) { |
|
| 283 | + $taxClassId = Tax::where('country', '') |
|
| 284 | + ->where('state', 'Any State') |
|
| 285 | + ->pluck('tax_classes_id')->first(); //In case of India when other |
|
| 286 | + //tax is available and tax is not enabled |
|
| 287 | + if ($taxClassId) { |
|
| 288 | + $taxes = $this->getTaxByPriority($taxClassId); |
|
| 289 | + $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
|
| 290 | + if ($value == 0) { |
|
| 291 | + $status = 0; |
|
| 292 | + } |
|
| 293 | + $rate = $value; |
|
| 294 | + foreach ($taxes as $key => $tax) { |
|
| 295 | + $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
|
| 296 | + $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
|
| 297 | 297 | |
| 298 | 298 | 'name' => $tax->name, |
| 299 | 299 | 'type' => 'tax', |
| 300 | 300 | 'target' => 'item', |
| 301 | 301 | 'value' => $value, |
| 302 | 302 | ]); |
| 303 | - } |
|
| 304 | - } else {//In case of other country |
|
| 305 | - //when tax is available and tax is not enabled |
|
| 306 | - //(Applicable when Global Tax class for any country and state is not there) |
|
| 307 | - $taxClassId = Tax::where('state', $geoip_state) |
|
| 308 | - ->orWhere('country', $geoip_country) |
|
| 309 | - ->pluck('tax_classes_id')->first(); |
|
| 310 | - if ($taxClassId) { //if state equals the user State |
|
| 311 | - $taxes = $this->getTaxByPriority($taxClassId); |
|
| 312 | - $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
|
| 313 | - if ($value == '') { |
|
| 314 | - $status = 0; |
|
| 315 | - } |
|
| 316 | - $rate = $value; |
|
| 317 | - } |
|
| 318 | - foreach ($taxes as $key => $tax) { |
|
| 319 | - $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
|
| 320 | - $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
|
| 303 | + } |
|
| 304 | + } else {//In case of other country |
|
| 305 | + //when tax is available and tax is not enabled |
|
| 306 | + //(Applicable when Global Tax class for any country and state is not there) |
|
| 307 | + $taxClassId = Tax::where('state', $geoip_state) |
|
| 308 | + ->orWhere('country', $geoip_country) |
|
| 309 | + ->pluck('tax_classes_id')->first(); |
|
| 310 | + if ($taxClassId) { //if state equals the user State |
|
| 311 | + $taxes = $this->getTaxByPriority($taxClassId); |
|
| 312 | + $value = $this->getValueForOthers($productid, $taxClassId, $taxes); |
|
| 313 | + if ($value == '') { |
|
| 314 | + $status = 0; |
|
| 315 | + } |
|
| 316 | + $rate = $value; |
|
| 317 | + } |
|
| 318 | + foreach ($taxes as $key => $tax) { |
|
| 319 | + $tax_attribute[$key] = ['name' => $tax->name, 'rate' => $value, 'tax_enable'=>0, 'status' => $status]; |
|
| 320 | + $taxCondition[$key] = new \Darryldecode\Cart\CartCondition([ |
|
| 321 | 321 | |
| 322 | 322 | 'name' => $tax->name, |
| 323 | 323 | 'type' => 'tax', |
| 324 | 324 | 'target' => 'item', |
| 325 | 325 | 'value' => $value, |
| 326 | 326 | ]); |
| 327 | - } |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - } |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | 331 | } else { |
| 332 | 332 | $tax_attribute[0] = ['name' => 'null', 'rate' => 0, 'tax_enable' =>0]; |
| 333 | 333 | $taxCondition[0] = new \Darryldecode\Cart\CartCondition([ |