ifnex/04_Laravel/debug_compare.php
Kazem Alghasi 3aaa9a5481 refactor(api): improve shipping rate import and pricing logic
Refactor the shipping rate import process to support bidirectional
data handling (import/export) and implement currency conversion using
system settings. Update the price calculator to ensure valid zone
data is retrieved.

- Update `ShippingRatesImport` to handle both import and export
  directions via `SimpleRateSheetImport`.
- Implement AED to IRR conversion during rate importation using
  `SystemSetting`.
- Add validation for zone numbers and rate values during import.
- Enhance `PriceCalculatorService` to filter for non-zero zone values.
- Add various debug and testing scripts for pricing and data
  structure verification.
2026-08-04 07:24:23 +03:30

33 lines
1.4 KiB
PHP

<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
$file = 'storage/app/public/01KYWGVNKS5TNMN37RV77PCYNZ.xlsx';
$ss = IOFactory::load($file);
$sheet = $ss->getSheetByName('DocNor');
echo "=== Raw Excel values (DocNor) ===" . PHP_EOL;
for ($r = 9; $r <= 11; $r++) {
$row = $sheet->rangeToArray("A{$r}:C{$r}")[0];
echo "Row {$r}: weight={$row[0]}, zone={$row[1]}, raw={$row[2]}, /455000=" . ($row[2] / 455000) . PHP_EOL;
}
echo PHP_EOL . "=== Stored values (DB) ===" . PHP_EOL;
$records = \App\Models\ShippingRate::where('direction', 'export')
->where('type', 'DOC_NORMAL')
->where('weight', 1)
->first(['zone_1', 'zone_2', 'zone_3', 'zone_4', 'zone_5', 'zone_6', 'zone_7']);
echo json_encode($records, JSON_PRETTY_PRINT) . PHP_EOL;
echo PHP_EOL . "=== Raw Excel values (Export Rate) ===" . PHP_EOL;
$sheet2 = $ss->getSheetByName('Export Rate');
for ($r = 6; $r <= 9; $r++) {
$row = $sheet2->rangeToArray("A{$r}:J{$r}")[0];
echo "Row {$r}: " . implode(' | ', array_map(function($c) { return $c === null ? '(null)' : $c; }, $row)) . PHP_EOL;
}
echo PHP_EOL . "=== System Settings ===" . PHP_EOL;
echo "aed_to_irr: " . \App\Models\SystemSetting::get('aed_to_irr', 455000) . PHP_EOL;
echo "profit_margin: " . \App\Models\SystemSetting::get('profit_margin', 1.25) . PHP_EOL;
echo "vat_rate: " . \App\Models\SystemSetting::get('vat_rate', 0.09) . PHP_EOL;