Projekt

Allgemein

Profil

GX-Bug #68815 » tax-fix.patch

GX 4.5 fix - Moritz Bunjes, 30.06.2021 18:00

Unterschiede anzeigen:

src/GXMainComponents/Application.inc.php
1 1
<?php
2 2
/* --------------------------------------------------------------
3
   Application.inc.php 2021-05-14
3
   Application.inc.php 2021-06-30
4 4
   Gambio GmbH
5 5
   http://www.gambio.de
6 6
   Copyright (c) 2021 Gambio GmbH
......
270 270

  
271 271
        // write customers status in session
272 272
        if (isset($_SESSION['customer_id'])) {
273
            $customerStatusQuery1  = $db->select('c.customers_status, a.customer_b2b_status')
273
            $customerStatusQuery1 = $db->select('c.customers_status, 
274
                                                        a.address_book_id, 
275
                                                        a.customer_b2b_status, 
276
                                                        a.entry_country_id, 
277
                                                        a.entry_zone_id')
274 278
                ->from('customers c')
275 279
                ->join('address_book a', 'a.address_book_id = c.customers_default_address_id')
276 280
                ->where('c.customers_id', $_SESSION['customer_id'])
......
311 315
                if (!isset($_SESSION['customer_b2b_status'])) {
312 316
                    update_customer_b2b_status($customersStatusValue1['customer_b2b_status']);
313 317
                }
318
    
319
                $customerCountryId = $customersStatusValue1['entry_country_id'];
320
                $customerZoneId    = $customersStatusValue1['entry_zone_id'];
321
    
322
                $selfpickupSelected = isset($_SESSION['shipping']['id'])
323
                                      && $_SESSION['shipping']['id'] === 'selfpickup_selfpickup';
324
    
325
                // For selfpickup the taxation must be calculated based on the country/zone the shop is located in
326
                if ($selfpickupSelected) {
327
                    $query             = 'SELECT
328
                                               g.`value` AS entry_country_id,
329
                                               z.`zone_id` AS entry_zone_id
330
                                            FROM `gx_configurations` g
331
                                            INNER JOIN `zones_to_geo_zones` z ON g.`value` = z.`zone_country_id`
332
                                            WHERE `key` = "configuration/SHIPPING_ORIGIN_COUNTRY" LIMIT 1';
333
                    $result            = xtc_db_query($query);
334
                    $row               = xtc_db_fetch_array($result);
335
                    $customerCountryId = $row['entry_country_id'];
336
                    $customerZoneId    = $row['entry_zone_id'];
337
                } else {
338
                    $cartContentType = isset($_SESSION['cart'])
339
                                       && method_exists($_SESSION['cart'],
340
                                                        'get_content_type') ? $_SESSION['cart']->get_content_type() : null;
341
        
342
                    // $cartContentType is null in Gambio Admin
343
                    if ($cartContentType !== null) {
344
                        $addressBookId = null;
345
                        $query         = 'SELECT
346
                                                ab.`entry_country_id`,
347
                                                ab.`entry_zone_id`
348
                                            FROM ' . TABLE_ADDRESS_BOOK . ' ab
349
                                            LEFT JOIN ' . TABLE_ZONES . ' z ON (ab.`entry_zone_id` = z.`zone_id`)
350
                                            WHERE
351
                                                ab.`customers_id` = ' . (int)$_SESSION['customer_id'] . ' AND
352
                                                ab.`address_book_id` = ';
353
                        if ($cartContentType === 'virtual' && !empty($_SESSION['billto'])
354
                            && $customersStatusValue1['address_book_id'] !== $_SESSION['billto']) {
355
                            $addressBookId = (int)$_SESSION['billto'];
356
                            $query         .= $addressBookId;
357
                        } elseif ($cartContentType !== 'virtual' && !empty($_SESSION['sendto'])
358
                                  && $customersStatusValue1['address_book_id'] !== $_SESSION['sendto']) {
359
                            $addressBookId = (int)$_SESSION['sendto'];
360
                            $query         .= $addressBookId;
361
                        }
362
            
363
                        if ($addressBookId !== null) {
364
                            $result            = xtc_db_query($query);
365
                            $row               = xtc_db_fetch_array($result);
366
                            $customerCountryId = $row['entry_country_id'];
367
                            $customerZoneId    = $row['entry_zone_id'];
368
                        }
369
                    }
370
                }
371
    
372
                $_SESSION['customer_country_id'] = $customerCountryId;
373
                $_SESSION['customer_zone_id']    = $customerZoneId;
314 374
            } else // (int)xtc_db_num_rows($customers_status_query_1) !== 1
315 375
            {
316 376
                if (!StyleEditServiceFactory::service()->isEditing()) {
......
351 411
                ];
352 412

  
353 413
                update_customer_b2b_status('0');
414
    
415
                if (!isset ($_SESSION['customer_country_id'])) {
416
                    $_SESSION['customer_country_id'] = STORE_COUNTRY;
417
                    $_SESSION['customer_zone_id']    = STORE_ZONE;
418
                }
354 419
            }
355 420
        } else // isset($_SESSION['customer_id']) === false
356 421
        {
......
385 450
            ];
386 451

  
387 452
            update_customer_b2b_status('0');
388
        }
389

  
390
        if (!isset ($_SESSION['customer_country_id'])) {
391
            $_SESSION['customer_country_id'] = STORE_COUNTRY;
392
            $_SESSION['customer_zone_id']    = STORE_ZONE;
453
    
454
            if (!isset ($_SESSION['customer_country_id'])) {
455
                $_SESSION['customer_country_id'] = STORE_COUNTRY;
456
                $_SESSION['customer_zone_id']    = STORE_ZONE;
457
            }
393 458
        }
394 459
    }
395 460
    
src/system/classes/tax/CountrySessionWriter.inc.php
1 1
<?php
2 2
/* --------------------------------------------------------------
3
   CountrySessionWriter.inc.php 2014-12-15 gm
3
   CountrySessionWriter.inc.php 2021-06-30 gm
4 4
   Gambio GmbH
5 5
   http://www.gambio.de
6
   Copyright (c) 2014 Gambio GmbH
6
   Copyright (c) 2021 Gambio GmbH
7 7
   Released under the GNU General Public License (Version 2)
8 8
   [http://www.gnu.org/licenses/gpl-2.0.html]
9 9
   --------------------------------------------------------------
......
36 36
			if(isset($countriesArray[$p_countryIsoCode]))
37 37
			{
38 38
				$countryId = $this->countries->get_country_id_by_iso_code($p_countryIsoCode);
39
				$_SESSION['customer_country_id'] = $countryId;
39
				$_SESSION['customer_country_id']   = $countryId;
40
				$_SESSION['cart_shipping_country'] = $countryId;
40 41
			}
41 42
		}
42 43
	}
    (1-1/1)