From 030668e43bc8476d246a483c854407336c82f720 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Wed, 7 Nov 2018 22:29:08 +0800 Subject: [PATCH 1/6] Fix plate number cleaning #168 --- src/Entity/Warranty.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Entity/Warranty.php b/src/Entity/Warranty.php index a7b538af..6ea1f0cb 100644 --- a/src/Entity/Warranty.php +++ b/src/Entity/Warranty.php @@ -133,9 +133,23 @@ class Warranty // remove invalid characters $clean_plate = preg_replace("/[^A-Z0-9]/", '', $clean_plate); - // check if format is correct - // AAA123 or AAA1234 - $res = preg_match("/^[A-Z]{3}[0-9]{3,4}$/", $clean_plate); + // check for 4 to 5 digit diplomatic plate + $res = preg_match("/^[0-9]{4,5}$/", $clean_plate); + if ($res) + return $clean_plate; + + // ABC-1234 or ABC-123 or ABC-12 format + $res = preg_match("/^[A-Z]{3}[0-9]{2,4}$/", $clean_plate); + if ($res) + return $clean_plate; + + // AB-123 or AB-12345 or AB-1234 format (motorcycles) + $res = preg_match("/^[A-Z]{2}[0-9]{3,5}$/", $clean_plate); + if ($res) + return $clean_plate; + + // 1234-AB format (motorcycles) + $res = preg_match("/^[0-9]{4}[A-Z]{2}$/", $clean_plate); if ($res) return $clean_plate; From 6031b6c367da10595d79bea52c7067744bc4c948 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Wed, 7 Nov 2018 22:30:47 +0800 Subject: [PATCH 2/6] Add /migration folder to gitignore #168 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 806b0a96..90038562 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /vendor/ /sql/ /pem/ +/migration/ ###< symfony/framework-bundle ### *.swp From cdbc7897ca0f9d4642aeb1af54b65ea9490f4e9b Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Tue, 13 Nov 2018 17:42:05 +0800 Subject: [PATCH 3/6] Add legacy battery to current battery translation #168 --- src/Command/ImportLegacyJobOrderCommand.php | 401 ++++++++++++++++++++ src/Ramcar/LegacyBattery.php | 71 ++++ 2 files changed, 472 insertions(+) create mode 100644 src/Command/ImportLegacyJobOrderCommand.php create mode 100644 src/Ramcar/LegacyBattery.php diff --git a/src/Command/ImportLegacyJobOrderCommand.php b/src/Command/ImportLegacyJobOrderCommand.php new file mode 100644 index 00000000..8838986a --- /dev/null +++ b/src/Command/ImportLegacyJobOrderCommand.php @@ -0,0 +1,401 @@ +em = $om; + + $this->loadBatteryModels(); + $this->loadBatterySizes(); + + parent::__construct(); + } + + protected function configure() + { + $this->setName('legacy:import_jo') + ->setDescription('Import a CSV file with legacy job orders.') + ->setHelp('Updates job order, plate number and warranty database from imported CSV entries.') + ->addArgument('file', InputArgument::REQUIRED, 'Path to the CSV file.'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $csv_file = $input->getArgument('file'); + $output->writeln("parsing $csv_file...\n"); + + /* + CSV column order: + 0 - Internal ID + 1 - Type + 2 - Transaction Number + 3 - Primary Information : Date of Transaction + 4 - Primary Information : Job Order Number + 5 - Primary Information : MEH : Transaction Type + 6 - Primary Information : Reference JO Number + 7 - Primary Information : Type of Service + 8 - Primary Information : Warranty Status + 9 - Primary Information : Transaction Origin + 10 - Primary Information : Existing Battery + 11 - Primary Information : Existing Battery Type + 12 - Primary Information : Recommended Battery + 13 - Primary Infromation : Alternative Battery + 14 - Primary Information : Vehicle Plate Number + 15 - Primary Information : Brand + 16 - Primary Information : Make + 17 - Primary Information : Model + 18 - Primary Information : Vehicle Color + 19 - Primary Information : Caller Name + 20 - First Name + 21 - Middle Name + 22 - Last Name + 23 - Primary Information : Caller Contact + 24 - Primary Information : Caller Mobile No. + 25 - Primary Information : Caller Landline No. + 26 - Primary Information : Invoice / Company Name + 27 - Primary Information : New Name? + 28 - Primary Information : New Invoice / Company Name + 29 - Primary Information : Delivery Instructions + 30 - Primary Information : Agent Notes - Tier 1 + 31 - Primary Information : Delivery Date + 32 - Primary Information : Delivery Time + 33 - Primary Information : Advance Order + 34 - Primary Information : Stages + 35 - Primary Information : Reason for Cancellation + 36 - Primary Information : Specify the Reason for Cancellation + 37 - Primary Information : Payment Method + 38 - Primary Information : Change for: + 39 - Primary Information : Prepared by + 40 - Current Battery Details : Serial No.: + 41 - Current Battery Details : DR No.: + 42 - Current Battery Details : Date of Replacement + 43 - Current Battery Details : Battery Brand + 44 - Current Battery Details : Type + 45 - Current Battery Details : Issued By: + 46 - Current Battery Details : Issued By Direct + 47 - Original Battery Details : Serial No. + 48 - Original Battery Details : OR No.: + 49 - Original Battery Details : Date of Purchase + 50 - Original Battery Details : Battery Brand: + 51 - Original Battery Details : Battery Type: + 52 - Original Battery Details : Purchased From: + 53 - Original Battery Details : Purchase from Direct + 54 - Original Battery Details : Current Warranty Expiration Date + 55 - Original Battery Details : Trade-In Battery + 56 - Dispatching : Agent Notes : Tier 2 + 57 - Dispatching : Notes (Customer Classification) + 58 - Dispatching : Pending + 59 - Dispatching : Pending - Awaiting Stocks + 60 - Dispatching : Date started from Awaiting Stock + 61 - Dispatching : 4TH Due + 62 - Dispatching : 8TH Due + 63 - Dispatching : 12TH Due + 64 - Dispatching : 14TH Due + 65 - Dispatching : Currently Assigned Enrollee + 66 - Dispatching : Non-HUB? + 67 - Dispatching : HUB Catered? + 68 - Dispatching : Thru Annex? + 69 - Dispatching : HUB List + 70 - Dispatching : Annex List + 71 - Dispatching : Exempted to 6% + 72 - Dispatching : Rider Name List + 73 - Dispatching : Rider Name + 74 - Dispatching : Rider Contact Information + 75 - DIspatching : Dispatch Time + 76 - Dispatching : Dispatch Date + 77 - Dispatching : Dispatched By + 78 - Dispatching : Time of Arrival + 79 - Dispatching : Time Job Completed + 80 - Dispatching : For Line Up? + 81 - DIspatching : Order + 82 - Vehicle Location : Address + 83 - Vehicle Location : Landmark + 84 - Customer Service Record : Purchase Date + 85 - Customer Service Record : Battery / Item + 86 - Customer Service Record : Battery / Item Warranty in Months + 87 - Customer Service Record : Warranty Inquiry (Expiration Date) + 88 - JO : Amount + 89 - JO : TAX + 90 - JO : Discount + 91 - JO : Final Amount + 92 - Line Details : Item + 93 - Line Details : Quantity + 94 - Line Details : Item Rate + 95 - Line Details : Price Level + 96 - Line Details : Item Base Price + 97 - Line Details : Price Level Amount Deductions + 98 - Line Details : Final Amount + 99 - Line Details : No Trade-In + 100 - Line Details : Reason for No Trade-In + 101 - Line Details : Battery Class + 102 - Line Details : Discount Items + 103 - Line Details : Discount Code + 104 - Line Details : Percentage + 105 - Line Details : Converted Rate + 106 - Line Details : Discount Amount + 107 - Line Details : Warranty Classification + 108 - Line Details : Warranty in Months + 109 - Line Details : Warranty Expiration Date + 110 - Line Details : Serial Number + 111 - Line Details : Invoice/DR Number + 112 - Line Details : Repalcement + 113 - Line Details : Employee / Card No. / Referred by + 114 - Line Details : Amount + 115 - Line Details : Gross Amount + 116 - Line Details : Gross Amount + 117 - Time Stamp : Date / Time (JO Open) + 118 - Time Stamp : Date / Time JO Saved + 119 - Time Stamp : Ticket Handle TIme (in mins) + 120 - Time Stamp : Idle Time + 121 - Time Stamp : Date and Time (Dispatched By) + 122 - Time Stamp : In-Transit Date and Time + 123 - TIme Stamp : Completion Date and TIme + 124 - TIme Stamp : Dispatch By to In-Transit Time (Time difference in Mins) + 125 - Time Stamp : In-Transit to Completed (Time difference in Mins) + 126 - Time Stamp : Raw Ticket Handle TIme (Decimal) + 127 - Time Stamp : Raw Idle Time (Decimal) + 128 - Account + 129 - Status + 130 - Tracking Numbers + 131 - Memo + 132 - Posting + 133 - Notes + 134 - Originally Assigned Enrollee + 135 - Remarks + 136 - Follow Up Transactions + 137 - CARD TYPE + 138 - CARD NO. + 139 - Ongoing Editing + 140 - Current User + 141 - Cancellation Date + 142 - Cancellation Time + 143 - Ticket Completion Date + 144 - Ticket Completion Time + 145 - Date Created + 146 - Time Created + 147 - PREVIOUS STAGE + 148 - DISPATCHED BY EDITED? + 149 - Previous Dispatched By + 150 - POST SERVICE + 151 - Pending (2) + 152 - COMPLETED MANUALLY + 153 - THRU HUB NOTE + 154 - CURRENTLY ASSIGNED ENROLLEE (free-form) + 155 - IN-TRANSIT ALLOWANCE + 156 - COPY FROM JO # + 157 - NO. OF POSSIBLE DUPLICATE + 158 - Call Status + 159 - DISTRIBUTOR OUTLETS + 160 - CURRENTLY ASSIGNED ENROLLEE (free-form) + 161 - HUB LIST + 162 - HUB LIST 2 + 163 - Enrollee + 164 - Currently Assigned Enrollee + 165 - Payment: + */ + + // attempt to open file + try + { + $fh = fopen($csv_file, "r"); + } + catch (Exception $e) + { + throw new Exception('The file "' . $csv_file . '" could be read.'); + } + + // get entity manager + $em = $this->em; + + $trans_types = []; + $service_types = []; + $no_sizes = []; + + // loop through rows + $row_num = 0; + while (($fields = fgetcsv($fh)) !== false) + { + $row_num++; + // $output->writeln("Parsing row " . $row_num . "..."); + + // skip taxes + if ($fields[14] == 'Bureau of Internal Revenue') + { + // $output->writeln('Skipping BIR line'); + continue; + } + + // ignore first 5 rows + if ($row_num <= 5) + continue; + + // check column count + if (count($fields) != 166) + { + echo "*** wrong field count on row $row_num\n"; + print_r($fields); + exit; + } + + // split battery into model and size + // echo "trying match - " . $fields[92] . "\n"; + $res = preg_match("/^(.+)(GOLD|EXCEL|ENDURO|\(Trade-In\))/", $fields[92], $matches); + if (!$res) + { + // echo "no match - " . $fields[92] . "\n"; + continue; + } + + + // check if we have the size + $found_size = $this->simplifyName($matches[1]); + if (!isset($this->bsize_hash[$found_size])) + { + // try legacy battery lookup + $legacy_size = LegacyBattery::translate($found_size); + if ($legacy_size == null) + { + // echo "no size - $found_size\n"; + if (isset($no_sizes[$found_size])) + $no_sizes[$found_size]++; + else + $no_sizes[$found_size] = 1; + continue; + } + + $found_size = $legacy_size; + } + + + // let's track purchases first + if ($fields[5] != 'PURCHASE') + continue; + + // consolidate transaction and service types + $trans_types[$fields[5]] = 1; + $service_types[$fields[7]] = $fields[5]; + + // clean plate numbers + $plate_num = Warranty::cleanPlateNumber($fields[14]); + if (!$plate_num) + { + $output->writeln('Invalid plate number - ' . $fields[14]); + continue; + } + + + /* + // plate + echo '14 - ' . $fields[14] . "\n"; + + // transaction + echo '5 - ' . $fields[5] . "\n"; + echo '7 - ' . $fields[7] . "\n"; + + // name + echo '22 - ' . $fields[22] . "\n"; + echo '20 - ' . $fields[20] . "\n"; + echo '21 - ' . $fields[21] . "\n"; + + // number + echo '23 - ' . $fields[23] . "\n"; + echo '24 - ' . $fields[24] . "\n"; + echo '25 - ' . $fields[25] . "\n"; + + // vehicle + echo '15 - ' . $fields[15] . "\n"; + echo '16 - ' . $fields[16] . "\n"; + echo '17 - ' . $fields[17] . "\n"; + echo '18 - ' . $fields[18] . "\n"; + + + // battery + echo '10 - ' . $fields[10] . "\n"; + echo '11 - ' . $fields[11] . "\n"; + echo '50 - ' . $fields[50] . "\n"; + echo '51 - ' . $fields[51] . "\n"; + echo '40 - ' . $fields[40] . "\n"; + echo '43 - ' . $fields[43] . "\n"; + echo '44 - ' . $fields[44] . "\n"; + echo '47 - ' . $fields[47] . "\n"; + echo '54 - ' . $fields[54] . "\n"; + + // customer service record + echo '84 - ' . $fields[84] . "\n"; + echo '85 - ' . $fields[85] . "\n"; + echo '86 - ' . $fields[86] . "\n"; + echo '87 - ' . $fields[87] . "\n"; + */ + // echo '92 - ' . $fields[92] . "\n"; + + /* + echo '110 - ' . $fields[110] . "\n"; + */ + } + + // print_r($trans_types); + // print_r($service_types); + print_r($no_sizes); + // print_r($b_models); + // print_r($batteries); + + // save to db + // print_r($batteries); + } + + protected function loadBatteryModels() + { + $this->bmodel_hash = []; + + $models = $this->em->getRepository(BatteryModel::class)->findAll(); + foreach ($models as $model) + { + // clean name + // $name = strtoupper(trim(str_replace(' ', '', $model->getName()))); + $name = $this->simplifyName($model->getName()); + + $this->bmodel_hash[$name] = $model->getID(); + } + } + + protected function loadBatterySizes() + { + $this->bsize_hash = []; + + $sizes = $this->em->getRepository(BatterySize::class)->findAll(); + foreach ($sizes as $size) + { + // clean name + // $name = strtoupper(trim(str_replace(' ', '', $size->getName()))); + $name = $this->simplifyName($size->getName()); + + $this->bsize_hash[$name] = $size->getID(); + } + } + + protected function simplifyName($text) + { + return strtoupper(trim(str_replace(' ', '', $text))); + } +} diff --git a/src/Ramcar/LegacyBattery.php b/src/Ramcar/LegacyBattery.php new file mode 100644 index 00000000..01705bac --- /dev/null +++ b/src/Ramcar/LegacyBattery.php @@ -0,0 +1,71 @@ + Date: Sun, 30 Dec 2018 00:27:52 +0800 Subject: [PATCH 4/6] Fix legacy import command to populate plate_number table via load data infile #168 --- src/Command/ImportLegacyJobOrderCommand.php | 278 +++++++++++++++++--- src/Entity/PlateNumber.php | 52 ++++ src/Ramcar/LegacyVehicle.php | 139 ++++++++++ src/Ramcar/LegacyVehicleManufacturer.php | 23 ++ 4 files changed, 459 insertions(+), 33 deletions(-) create mode 100644 src/Entity/PlateNumber.php create mode 100644 src/Ramcar/LegacyVehicle.php create mode 100644 src/Ramcar/LegacyVehicleManufacturer.php diff --git a/src/Command/ImportLegacyJobOrderCommand.php b/src/Command/ImportLegacyJobOrderCommand.php index 8838986a..34715623 100644 --- a/src/Command/ImportLegacyJobOrderCommand.php +++ b/src/Command/ImportLegacyJobOrderCommand.php @@ -12,8 +12,13 @@ use Doctrine\Common\Persistence\ObjectManager; use App\Entity\Warranty; use App\Entity\BatterySize; use App\Entity\BatteryModel; +use App\Entity\VehicleManufacturer; +use App\Entity\Vehicle; +use App\Entity\PlateNumber; use App\Ramcar\LegacyBattery; +use App\Ramcar\LegacyVehicleManufacturer; +use App\Ramcar\LegacyVehicle; class ImportLegacyJobOrderCommand extends Command @@ -21,6 +26,8 @@ class ImportLegacyJobOrderCommand extends Command protected $em; protected $bmodel_hash; protected $bsize_hash; + protected $vmfg_hash; + protected $vehicle_hash; public function __construct(ObjectManager $om) { @@ -28,6 +35,8 @@ class ImportLegacyJobOrderCommand extends Command $this->loadBatteryModels(); $this->loadBatterySizes(); + $this->loadVehicleManufacturers(); + $this->loadVehicles(); parent::__construct(); } @@ -232,7 +241,10 @@ class ImportLegacyJobOrderCommand extends Command $service_types = []; $no_sizes = []; + $outfile = fopen('/tmp/plate_numbers.csv', 'a'); + // loop through rows + $save_plates = []; $row_num = 0; while (($fields = fgetcsv($fh)) !== false) { @@ -258,40 +270,26 @@ class ImportLegacyJobOrderCommand extends Command exit; } - // split battery into model and size - // echo "trying match - " . $fields[92] . "\n"; - $res = preg_match("/^(.+)(GOLD|EXCEL|ENDURO|\(Trade-In\))/", $fields[92], $matches); - if (!$res) - { - // echo "no match - " . $fields[92] . "\n"; - continue; - } - - - // check if we have the size - $found_size = $this->simplifyName($matches[1]); - if (!isset($this->bsize_hash[$found_size])) - { - // try legacy battery lookup - $legacy_size = LegacyBattery::translate($found_size); - if ($legacy_size == null) - { - // echo "no size - $found_size\n"; - if (isset($no_sizes[$found_size])) - $no_sizes[$found_size]++; - else - $no_sizes[$found_size] = 1; - continue; - } - - $found_size = $legacy_size; - } - - // let's track purchases first if ($fields[5] != 'PURCHASE') continue; + // check if battery is found + $found_battery = $this->findBattery($fields[92], $batt_model, $batt_size); + if (!$found_battery) + { + $output->writeln('battery not found - ' . $fields[92]); + continue; + } + + // find matching vehicle + $found_vehicle = $this->findVehicle($fields[15], $fields[16], $fields[17], $vehicle); + if (!$found_vehicle) + { + $output->writeln('vehicle not found - ' . $fields[15] . ' - ' . $fields[16]); + continue; + } + // consolidate transaction and service types $trans_types[$fields[5]] = 1; $service_types[$fields[7]] = $fields[5]; @@ -304,6 +302,30 @@ class ImportLegacyJobOrderCommand extends Command continue; } + fwrite($outfile, $plate_num . ',' . $vehicle['id'] . "\n"); + + /* + // check if we marked it already + if (isset($save_plates[$plate_num])) + continue; + + // check if already there + $find_plate = $em->getRepository(PlateNumber::class)->find($plate_num); + if ($find_plate) + { + continue; + } + + // save to db + $o_plate = new PlateNumber(); + $o_plate->setID($plate_num) + ->setVehicle($vehicle['object']); + + $em->persist($o_plate); + + $save_plates[$plate_num] = true; + */ + /* // plate @@ -354,14 +376,20 @@ class ImportLegacyJobOrderCommand extends Command */ } + // $em->flush(); + // print_r($trans_types); // print_r($service_types); - print_r($no_sizes); + // print_r($no_sizes); // print_r($b_models); // print_r($batteries); // save to db // print_r($batteries); + // print_r($this->vehicle_hash); + // print_r($no_makes); + + fclose($outfile); } protected function loadBatteryModels() @@ -394,8 +422,192 @@ class ImportLegacyJobOrderCommand extends Command } } - protected function simplifyName($text) + protected function loadVehicleManufacturers() { - return strtoupper(trim(str_replace(' ', '', $text))); + $this->vmfg_hash = []; + + $mfgs = $this->em->getRepository(VehicleManufacturer::class)->findAll(); + foreach ($mfgs as $mfg) + { + $name = $this->simplifyName($mfg->getName(), false); + + $this->vmfg_hash[$name] = $mfg->getID(); + } + } + + protected function loadVehicles() + { + $this->vehicle_hash = []; + + $vs = $this->em->getRepository(Vehicle::class)->findAll(); + foreach ($vs as $v) + { + $make = $this->simplifyName($v->getMake(), false); + + $mfg_id = $v->getManufacturer()->getID(); + if (!isset($this->vehicle_hash[$mfg_id])) + $this->vehicle_hash[$mfg_id] = []; + + if (!isset($this->vehicle_hash[$mfg_id][$make])) + $this->vehicle_hash[$mfg_id][$make] = []; + + $this->vehicle_hash[$mfg_id][$make][] = [ + 'id' => $v->getID(), + 'year_from' => $v->getModelYearFrom(), + 'year_to' => $v->getModelYearTo(), + 'object' => $v, + ]; + } + } + + protected function simplifyName($text, $replace_spaces = true) + { + if ($replace_spaces) + $clean_text = strtoupper(trim(str_replace(' ', '', $text))); + else + $clean_text = strtoupper(trim($text)); + + return $clean_text; + } + + protected function findBattery($batt_field, &$batt_model, &$batt_size) + { + // split battery into model and size + // echo "trying match - " . $fields[92] . "\n"; + $res = preg_match("/^(.+)(GOLD|EXCEL|ENDURO|\(Trade-In\))/", $batt_field, $matches); + if (!$res) + { + // echo "no match - " . $fields[92] . "\n"; + return false; + } + $batt_model = $matches[2]; + + // TODO: what to do about (Trade-In) + + // check if we have the size + $found_size = $this->simplifyName($matches[1]); + if (!isset($this->bsize_hash[$found_size])) + { + // try legacy battery lookup + $legacy_size = LegacyBattery::translate($found_size); + if ($legacy_size == null) + { + // echo "no size - $found_size\n"; + if (isset($no_sizes[$found_size])) + $no_sizes[$found_size]++; + else + $no_sizes[$found_size] = 1; + return false; + } + + $found_size = $legacy_size; + } + $batt_size = $found_size; + + return true; + } + + protected function findVehicle($vmfg_field, $vmake_field, $vmodel_field, &$vehicle) + { + // debug vehicles with no matching makes + $no_makes = []; + + // vehicle manufacturers + $found_vmfg = $this->simplifyName($vmfg_field, false); + if (!isset($this->vmfg_hash[$found_vmfg])) + { + $legacy_vmfg = LegacyVehicleManufacturer::translate($found_vmfg); + if ($legacy_vmfg == null) + { + echo "vmfg not found - $vmfg_field\n"; + return false; + } + + $found_vmfg = $legacy_vmfg; + } + $vmfg_id = $this->vmfg_hash[$found_vmfg]; + + // vehicle make + $found_make = $this->simplifyName($vmake_field, false); + if (!isset($this->vehicle_hash[$vmfg_id][$found_make])) + { + $legacy_make = LegacyVehicle::translate($found_vmfg, $found_make); + if ($legacy_make == null) + { + $no_makes[$found_make] = $found_vmfg . ' - ' . $found_make; + echo "vmake not found - $vmfg_field - $vmake_field\n"; + return false; + } + + $found_make = $legacy_make; + + // need to do this again because translate could change vmfg + $vmfg_id = $this->vmfg_hash[$found_vmfg]; + } + $make_list = $this->vehicle_hash[$vmfg_id][$found_make]; + + // check if there's only one in the make list + if (count($make_list) == 1) + { + $vehicle = $make_list[0]; + return true; + } + + // see which model matches + $clean_model = trim(strtoupper($vmodel_field)); + + // no model specified, take first one + $model_length = strlen($clean_model); + if ($model_length == 0 || $clean_model == 'NONE') + { + $vehicle = $make_list[0]; + return true; + } + + // one year or range specified + // we only take the first + $cut_model = substr($clean_model, 0, 4); + foreach ($make_list as $make) + { + // no year + if ($make['year_from'] == 0 && $make['year_to'] == 0) + { + $vehicle = $make; + return true; + } + + // no year from + if ($make['year_from'] == 0) + { + if ($make['year_to'] >= $cut_model) + { + $vehicle = $make; + return true; + } + } + + // no year to + if ($make['year_to'] == 0) + { + if ($make['year_from'] <= $cut_model) + { + $vehicle = $make; + return true; + } + } + + // has year from and to + if ($make['year_from'] <= $cut_model && $make['year_to'] >= $cut_model) + { + $vehicle = $make; + return true; + } + } + + // echo "model search - $vmfg_id - $found_vmfg - $found_make - $vmodel_field\n"; + + // we get the first one, because we have no idea where it falls under + $vehicle = $make_list[0]; + return true; } } diff --git a/src/Entity/PlateNumber.php b/src/Entity/PlateNumber.php new file mode 100644 index 00000000..97047383 --- /dev/null +++ b/src/Entity/PlateNumber.php @@ -0,0 +1,52 @@ +id = $id; + return $this; + } + + public function getID() + { + return $this->id; + } + + public function setVehicle(Vehicle $vehicle) + { + $this->vehicle = $vehicle; + return $this; + } + + public function getVehicle() + { + return $this->vehicle; + } +} diff --git a/src/Ramcar/LegacyVehicle.php b/src/Ramcar/LegacyVehicle.php new file mode 100644 index 00000000..6e54e7ee --- /dev/null +++ b/src/Ramcar/LegacyVehicle.php @@ -0,0 +1,139 @@ + Date: Thu, 3 Jan 2019 05:51:33 +0800 Subject: [PATCH 5/6] Add warranty migration for legacy data #168 --- src/Command/ImportLegacyJobOrderCommand.php | 94 ++++++- src/Entity/LegacyJobOrder.php | 262 ++++++++++++++++++++ src/Entity/PlateNumber.php | 3 - src/Entity/Warranty.php | 6 +- src/Ramcar/WarrantyClass.php | 21 ++ 5 files changed, 375 insertions(+), 11 deletions(-) create mode 100644 src/Entity/LegacyJobOrder.php diff --git a/src/Command/ImportLegacyJobOrderCommand.php b/src/Command/ImportLegacyJobOrderCommand.php index 34715623..07a300cb 100644 --- a/src/Command/ImportLegacyJobOrderCommand.php +++ b/src/Command/ImportLegacyJobOrderCommand.php @@ -19,6 +19,10 @@ use App\Entity\PlateNumber; use App\Ramcar\LegacyBattery; use App\Ramcar\LegacyVehicleManufacturer; use App\Ramcar\LegacyVehicle; +use App\Ramcar\WarrantyClass; +use App\Ramcar\WarrantyStatus; + +use DateTime; class ImportLegacyJobOrderCommand extends Command @@ -241,7 +245,8 @@ class ImportLegacyJobOrderCommand extends Command $service_types = []; $no_sizes = []; - $outfile = fopen('/tmp/plate_numbers.csv', 'a'); + $plate_outfile = fopen('/tmp/plate_numbers.csv', 'a'); + $warr_outfile = fopen('/tmp/warranty.csv', 'a'); // loop through rows $save_plates = []; @@ -302,7 +307,79 @@ class ImportLegacyJobOrderCommand extends Command continue; } - fwrite($outfile, $plate_num . ',' . $vehicle['id'] . "\n"); + fwrite($plate_outfile, $plate_num . ',' . $vehicle['id'] . "\n"); + + if (isset($fields[107])) + { + echo 'warranty class - ' . $fields[107] . "\n"; + + + $warr_class = WarrantyClass::convertFromLegacy($fields[107]); + if ($warr_class) + { + $batt_model_id = $batt_model; + $batt_size_id = $batt_size; + + // model and size + $line = $batt_model_id . ',' . $batt_size_id . ','; + + echo 'wclass - ' . $warr_class . "\n"; + echo 'serial - ' . $fields[110] . "\n"; + echo 'expiry - ' . $fields[109] . "\n"; + + // serial + if (isset($fields[110]) && strlen(trim($fields[110])) > 0) + $line .= $fields[110] . ','; + else + $line .= '\N,'; + + // warranty class + $line .= $warr_class . ','; + + // plate number + $line .= $plate_num . ','; + + $date_today = new DateTime(); + + // status + // check if expired + if (isset($fields[109]) && strlen(trim($fields[109])) > 0) + { + $ex_date = DateTime::createFromFormat('m/d/Y', $fields[109]); + $ex_tstamp = $ex_date->getTimestamp(); + $today_tstamp = $date_today->getTimestamp(); + if ($today_tstamp > $ex_tstamp) + $status = WarrantyStatus::EXPIRED; + else + $status = WarrantyStatus::ACTIVE; + } + $line .= $status . ','; + + // date create + $line .= $date_today->format('Ymd') . ','; + + // date purchase + if (isset($fields[84]) && strlen(trim($fields[84])) > 0) + { + $pur_date = DateTime::createFromFormat('m/d/Y', $fields[84]); + $line .= $pur_date->format('Ymd') . ','; + } + else + $line .= '\N,'; + + + // date expire + if (isset($fields[109]) && strlen(trim($fields[109])) > 0) + $line .= $ex_date->format('Ymd') . ','; + else + $line .= '\N,'; + + // date claim + $line .= '\N'; + + fwrite($warr_outfile, $line . "\n"); + } + } /* // check if we marked it already @@ -389,7 +466,8 @@ class ImportLegacyJobOrderCommand extends Command // print_r($this->vehicle_hash); // print_r($no_makes); - fclose($outfile); + fclose($plate_outfile); + fclose($warr_outfile); } protected function loadBatteryModels() @@ -480,7 +558,12 @@ class ImportLegacyJobOrderCommand extends Command // echo "no match - " . $fields[92] . "\n"; return false; } - $batt_model = $matches[2]; + + if ($matches[2] == '(Trade-In)') + return false; + + $batt_model = $this->bmodel_hash[$matches[2]]; + // $batt_model = $matches[2]; // TODO: what to do about (Trade-In) @@ -502,7 +585,8 @@ class ImportLegacyJobOrderCommand extends Command $found_size = $legacy_size; } - $batt_size = $found_size; + $batt_size = $this->bsize_hash[$found_size]; + // $batt_size = $found_size; return true; } diff --git a/src/Entity/LegacyJobOrder.php b/src/Entity/LegacyJobOrder.php new file mode 100644 index 00000000..d9143352 --- /dev/null +++ b/src/Entity/LegacyJobOrder.php @@ -0,0 +1,262 @@ +id = $id; + return $this; + } + + public function getID() + { + return $this->id; + } +} diff --git a/src/Entity/PlateNumber.php b/src/Entity/PlateNumber.php index 97047383..fb543772 100644 --- a/src/Entity/PlateNumber.php +++ b/src/Entity/PlateNumber.php @@ -25,9 +25,6 @@ class PlateNumber */ protected $vehicle; - // the batteries under this plate number - protected $batteries; - public function setID($id) { $this->id = $id; diff --git a/src/Entity/Warranty.php b/src/Entity/Warranty.php index 6ea1f0cb..480e7251 100644 --- a/src/Entity/Warranty.php +++ b/src/Entity/Warranty.php @@ -29,7 +29,7 @@ class Warranty // serial number /** - * @ORM\Column(type="string", length=50) + * @ORM\Column(type="string", length=50, nullable=true) */ protected $serial; @@ -41,7 +41,7 @@ class Warranty // plate /** - * @ORM\Column(type="string", length=10) + * @ORM\Column(type="string", length=20) */ protected $plate_number; @@ -79,7 +79,7 @@ class Warranty // date expires /** - * @ORM\Column(type="date") + * @ORM\Column(type="date", nullable=true) */ protected $date_expire; diff --git a/src/Ramcar/WarrantyClass.php b/src/Ramcar/WarrantyClass.php index 992ee1c6..8c7b1be1 100644 --- a/src/Ramcar/WarrantyClass.php +++ b/src/Ramcar/WarrantyClass.php @@ -13,4 +13,25 @@ class WarrantyClass extends NameValue 'commercial' => 'Commercial', 'tnv' => 'TNV', ]; + + public static function convertFromLegacy($legacy_wclass) + { + switch($legacy_wclass) + { + case '1YEAR': + case '1YR': + case 'Old Private': + case 'PRIAVTE': + case 'PRIVATE': + return self::WTY_PRIVATE; + + case 'COMMERCIAL': + return self::WTY_COMMERCIAL; + + case 'GRAB': + return self::WTY_TNV; + } + + return false; + } } From bfa39f4640ce01ac6874f7f44cc5f638f241111b Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Wed, 9 Jan 2019 17:01:08 +0800 Subject: [PATCH 6/6] Add legacy job order and details migration commands #168 --- src/Command/ImportLegacyJobOrderCommand.php | 315 ++++++++++++++++++-- src/Entity/LegacyJobOrder.php | 186 +++++++++--- src/Entity/LegacyJobOrderRow.php | 72 +++++ src/Ramcar/LegacyOrigin.php | 41 +++ src/Ramcar/LegacyTransactionType.php | 37 +++ 5 files changed, 583 insertions(+), 68 deletions(-) create mode 100644 src/Entity/LegacyJobOrderRow.php create mode 100644 src/Ramcar/LegacyOrigin.php create mode 100644 src/Ramcar/LegacyTransactionType.php diff --git a/src/Command/ImportLegacyJobOrderCommand.php b/src/Command/ImportLegacyJobOrderCommand.php index 07a300cb..8161fbae 100644 --- a/src/Command/ImportLegacyJobOrderCommand.php +++ b/src/Command/ImportLegacyJobOrderCommand.php @@ -18,7 +18,10 @@ use App\Entity\PlateNumber; use App\Ramcar\LegacyBattery; use App\Ramcar\LegacyVehicleManufacturer; +use App\Ramcar\LegacyTransactionType; use App\Ramcar\LegacyVehicle; +use App\Ramcar\LegacyOrigin; + use App\Ramcar\WarrantyClass; use App\Ramcar\WarrantyStatus; @@ -32,6 +35,12 @@ class ImportLegacyJobOrderCommand extends Command protected $bsize_hash; protected $vmfg_hash; protected $vehicle_hash; + protected $jo_hash; + + protected $row_fields; + protected $data_fields; + protected $row_max_field_size; + protected $data_max_field_size; public function __construct(ObjectManager $om) { @@ -42,6 +51,9 @@ class ImportLegacyJobOrderCommand extends Command $this->loadVehicleManufacturers(); $this->loadVehicles(); + $this->jo_hash = []; + + parent::__construct(); } @@ -245,8 +257,13 @@ class ImportLegacyJobOrderCommand extends Command $service_types = []; $no_sizes = []; + // files $plate_outfile = fopen('/tmp/plate_numbers.csv', 'a'); $warr_outfile = fopen('/tmp/warranty.csv', 'a'); + $jo_outfile = fopen('/tmp/legacy_jo.csv', 'a'); + $jorow_outfile = fopen('/tmp/legacy_jo_row.csv', 'a'); + + $this->initializeMaxFieldCounters(); // loop through rows $save_plates = []; @@ -256,13 +273,6 @@ class ImportLegacyJobOrderCommand extends Command $row_num++; // $output->writeln("Parsing row " . $row_num . "..."); - // skip taxes - if ($fields[14] == 'Bureau of Internal Revenue') - { - // $output->writeln('Skipping BIR line'); - continue; - } - // ignore first 5 rows if ($row_num <= 5) continue; @@ -275,6 +285,28 @@ class ImportLegacyJobOrderCommand extends Command exit; } + $this->processLegacyTransaction($fields); + + // skip taxes + if ($fields[14] == 'Bureau of Internal Revenue') + { + // $output->writeln('Skipping BIR line'); + continue; + } + + // clean plate numbers + $id = $fields[0]; + $plate_num = Warranty::cleanPlateNumber($fields[14]); + if (!$plate_num) + { + // $output->writeln('Invalid plate number - ' . $fields[14]); + $this->jo_hash[$id]['data']['plate_number'] = null; + continue; + } + else + $this->jo_hash[$id]['data']['plate_number'] = $plate_num; + + // let's track purchases first if ($fields[5] != 'PURCHASE') continue; @@ -283,7 +315,7 @@ class ImportLegacyJobOrderCommand extends Command $found_battery = $this->findBattery($fields[92], $batt_model, $batt_size); if (!$found_battery) { - $output->writeln('battery not found - ' . $fields[92]); + // $output->writeln('battery not found - ' . $fields[92]); continue; } @@ -291,7 +323,7 @@ class ImportLegacyJobOrderCommand extends Command $found_vehicle = $this->findVehicle($fields[15], $fields[16], $fields[17], $vehicle); if (!$found_vehicle) { - $output->writeln('vehicle not found - ' . $fields[15] . ' - ' . $fields[16]); + // $output->writeln('vehicle not found - ' . $fields[15] . ' - ' . $fields[16]); continue; } @@ -299,19 +331,11 @@ class ImportLegacyJobOrderCommand extends Command $trans_types[$fields[5]] = 1; $service_types[$fields[7]] = $fields[5]; - // clean plate numbers - $plate_num = Warranty::cleanPlateNumber($fields[14]); - if (!$plate_num) - { - $output->writeln('Invalid plate number - ' . $fields[14]); - continue; - } - fwrite($plate_outfile, $plate_num . ',' . $vehicle['id'] . "\n"); if (isset($fields[107])) { - echo 'warranty class - ' . $fields[107] . "\n"; + // echo 'warranty class - ' . $fields[107] . "\n"; $warr_class = WarrantyClass::convertFromLegacy($fields[107]); @@ -323,9 +347,9 @@ class ImportLegacyJobOrderCommand extends Command // model and size $line = $batt_model_id . ',' . $batt_size_id . ','; - echo 'wclass - ' . $warr_class . "\n"; - echo 'serial - ' . $fields[110] . "\n"; - echo 'expiry - ' . $fields[109] . "\n"; + // echo 'wclass - ' . $warr_class . "\n"; + // echo 'serial - ' . $fields[110] . "\n"; + // echo 'expiry - ' . $fields[109] . "\n"; // serial if (isset($fields[110]) && strlen(trim($fields[110])) > 0) @@ -381,6 +405,7 @@ class ImportLegacyJobOrderCommand extends Command } } + /* // check if we marked it already if (isset($save_plates[$plate_num])) @@ -453,6 +478,8 @@ class ImportLegacyJobOrderCommand extends Command */ } + // print_r($this->jo_hash); + // $em->flush(); // print_r($trans_types); @@ -466,8 +493,250 @@ class ImportLegacyJobOrderCommand extends Command // print_r($this->vehicle_hash); // print_r($no_makes); + /* + print_r($this->data_max_field_size); + print_r($this->row_max_field_size); + */ + + // save job order + foreach ($this->jo_hash as $jo) + { + $id = $jo['data']['id']; + + $line = $this->exportJOData($jo['data']); + fwrite($jo_outfile, $line . "\n"); + + foreach ($jo['rows'] as $jo_row) + fputcsv($jorow_outfile, $jo_row); + } + + fclose($plate_outfile); fclose($warr_outfile); + fclose($jo_outfile); + fclose($jorow_outfile); + } + + protected function initializeMaxFieldCounters() + { + $this->data_fields = [ + 'trans_type', + 'origin', + + 'car_brand', + 'car_make', + 'car_model', + 'car_color', + + 'cust_name', + 'cust_first_name', + 'cust_middle_name', + 'cust_last_name', + 'cust_contact', + 'cust_mobile', + 'cust_landline', + + 'delivery_instructions', + 'agent_notes_1', + 'delivery_date', + 'delivery_time', + 'advance_order', + 'stage', + 'cancel_reason', + 'cancel_reason_specify', + 'payment_method', + + 'prepared_by', + + 'dispatch_time', + 'dispatch_date', + 'dispatched_by', + + 'address', + 'landmark', + 'date_purchase', + ]; + + $this->row_fields = [ + 'item', + 'qty', + 'price', + 'price_level', + 'status', + 'account', + 'enrollee', + ]; + + // initialize max field size counter + $this->data_max_field_size = [ + 'trans_type' => 0, + 'origin' => 0, + + 'car_brand' => 0, + 'car_make' => 0, + 'car_model' => 0, + 'car_color' => 0, + + 'cust_name' => 0, + 'cust_first_name' => 0, + 'cust_middle_name' => 0, + 'cust_last_name' => 0, + 'cust_contact' => 0, + 'cust_mobile' => 0, + 'cust_landline' => 0, + + 'delivery_instructions' => 0, + 'agent_notes_1' => 0, + 'delivery_date' => 0, + 'delivery_time' => 0, + 'advance_order' => 0, + 'stage' => 0, + 'cancel_reason' => 0, + 'cancel_reason_specify' => 0, + 'payment_method' => 0, + + 'prepared_by' => 0, + + 'dispatch_time' => 0, + 'dispatch_date' => 0, + 'dispatched_by' => 0, + + 'address' => 0, + 'landmark' => 0, + 'date_purchase' => 0, + ]; + + $this->row_max_field_size = [ + 'item' => 0, + 'qty' => 0, + 'price' => 0, + 'price_level' => 0, + 'status' => 0, + 'account' => 0, + 'enrollee' => 0, + ]; + + } + + protected function processLegacyTransaction($fields) + { + // echo "trans type - " . $fields[5] . "\n"; + // echo "origin - " . $fields[9] . "\n"; + // echo "stage - " . $fields[34] . "\n"; + // echo "payment method - " . $fields[37] . "\n"; + // echo "price level - " . $fields[95] . "\n"; + + $id = $fields[0]; + + $trans_type = LegacyTransactionType::translate($fields[5]); + $origin = LegacyOrigin::translate($fields[9]); + + // consolidate based on jo id + if (!isset($this->jo_hash[$id])) + { + $this->jo_hash[$id] = [ + // 'raw' => [], + 'data' => [], + 'rows' => [], + ]; + + $date_trans = DateTime::createFromFormat('m/d/Y', $fields[3]); + + // labelled data + $this->jo_hash[$id]['data'] = [ + 'id' => $id, + 'date_trans' => $date_trans->format('Ymd'), + 'trans_type' => $trans_type, + 'origin' => $fields[9], + + 'car_brand' => $fields[15], + 'car_make' => $fields[16], + 'car_model' => $fields[17], + 'car_color' => $fields[18], + + 'cust_name' => $fields[19], + 'cust_first_name' => $fields[20], + 'cust_middle_name' => $fields[21], + 'cust_last_name' => $fields[22], + 'cust_contact' => $fields[23], + 'cust_mobile' => $fields[24], + 'cust_landline' => $fields[25], + + 'delivery_instructions' => $fields[29], + 'agent_notes_1' => $fields[30], + 'delivery_date' => $fields[31], + 'delivery_time' => $fields[32], + 'advance_order' => $fields[33], + 'stage' => $fields[34], + 'cancel_reason' => $fields[35], + 'cancel_reason_specify' => $fields[36], + 'payment_method' => $fields[37], + + 'prepared_by' => $fields[39], + + 'dispatch_time' => $fields[75], + 'dispatch_date' => $fields[76], + 'dispatched_by' => $fields[77], + + 'address' => $fields[82], + 'landmark' => $fields[83], + 'date_purchase' => $fields[84], + ]; + + + // max field size + foreach ($this->data_fields as $data_field) + { + $len = strlen($this->jo_hash[$id]['data'][$data_field]); + // echo "$data_field - $len vs " . $this->data_max_field_size[$data_field] . "\n"; + + if ($len > $this->data_max_field_size[$data_field]) + $this->data_max_field_size[$data_field] = $len; + } + /* + // raw + for ($x = 0; $x < 88; $x++) + $this->jo_hash[$id]['raw'][$x] = $fields[$x]; + */ + } + + $row = []; + /* + for ($x = 88; $x <= 165; $x++) + $row[$x - 88] = $fields[$x]; + */ + $row = [ + 'id' => $id, + 'item' => $fields[92], + 'qty' => $fields[93], + 'price' => $fields[114], + 'price_level' => $fields[95], + 'status' => $fields[129], + 'account' => $fields[128], + 'enrollee' => $fields[134], + ]; + $this->jo_hash[$id]['rows'][] = $row; + + // max row field size + foreach ($this->row_fields as $row_field) + { + $len = strlen($row[$row_field]); + if ($len > $this->row_max_field_size[$row_field]) + $this->row_max_field_size[$row_field] = $len; + } + } + + protected function exportJOData($data) + { + $line_data = []; + + foreach ($data as $field => $value) + { + $enc_value = str_replace('\\', '\\\\', $value); + $line_data[] = str_replace('|', '\\|', $enc_value); + } + + return implode('|', $line_data); } protected function loadBatteryModels() @@ -603,7 +872,7 @@ class ImportLegacyJobOrderCommand extends Command $legacy_vmfg = LegacyVehicleManufacturer::translate($found_vmfg); if ($legacy_vmfg == null) { - echo "vmfg not found - $vmfg_field\n"; + // echo "vmfg not found - $vmfg_field\n"; return false; } @@ -619,7 +888,7 @@ class ImportLegacyJobOrderCommand extends Command if ($legacy_make == null) { $no_makes[$found_make] = $found_vmfg . ' - ' . $found_make; - echo "vmake not found - $vmfg_field - $vmake_field\n"; + // echo "vmake not found - $vmfg_field - $vmake_field\n"; return false; } diff --git a/src/Entity/LegacyJobOrder.php b/src/Entity/LegacyJobOrder.php index d9143352..345fc724 100644 --- a/src/Entity/LegacyJobOrder.php +++ b/src/Entity/LegacyJobOrder.php @@ -188,65 +188,161 @@ class LegacyJobOrder */ protected $id; - protected $data; + /** + * @ORM\Column(type="date") + */ + protected $trans_date; -/* - protected $type; - protected $trans_num; - protected $trans_date; - protected $jo_num; - protected $meh_trans_type; - protected $ref_jo_num; - protected $service_type; - protected $warr_status; - protected $trans_origin; - protected $exist_batt; - protected $exist_batt_type; - protected $reco_batt; - protected $alt_batt; - protected $car_plate_num; + /** + * @ORM\Column(type="string", length=10) + */ + protected $trans_type; + + /** + * @ORM\Column(type="string", length=30) + */ + protected $origin; + + /** + * @ORM\Column(type="string", length=20) + */ protected $car_brand; + + /** + * @ORM\Column(type="string", length=50) + */ protected $car_make; + + /** + * @ORM\Column(type="string", length=20) + */ protected $car_model; + + /** + * @ORM\Column(type="string", length=40) + */ protected $car_color; + + /** + * @ORM\Column(type="string", length=90) + */ protected $cust_name; + + /** + * @ORM\Column(type="string", length=35) + */ protected $cust_first_name; + + /** + * @ORM\Column(type="string", length=15) + */ protected $cust_middle_name; + + /** + * @ORM\Column(type="string", length=35) + */ protected $cust_last_name; - protected $cust_contact_num; - protected $cust_mobile_num; - protected $cust_landline_num; - protected $invoice_name; - protected $new_name; - protected $new_invoice_name; + + /** + * @ORM\Column(type="string", length=25) + */ + protected $cust_contact; + + /** + * @ORM\Column(type="string", length=10) + */ + protected $cust_mobile; + + /** + * @ORM\Column(type="string", length=25) + */ + protected $cust_landline; + + /** + * @ORM\Column(type="string", length=2000) + */ protected $delivery_instructions; - protected $agent_notes; - protected $del_date; - protected $del_time; + + /** + * @ORM\Column(type="string", length=4000) + */ + protected $agent_notes_1; + + /** + * @ORM\Column(type="string", length=10) + */ + protected $delivery_date; + + /** + * @ORM\Column(type="string", length=10) + */ + protected $delivery_time; + + /** + * @ORM\Column(type="string", length=3) + */ protected $advance_order; + + /** + * @ORM\Column(type="string", length=30) + */ protected $stage; + + /** + * @ORM\Column(type="string", length=40) + */ protected $cancel_reason; - protected $specify_reason; + + /** + * @ORM\Column(type="string", length=2000) + */ + protected $cancel_reason_specify; + + /** + * @ORM\Column(type="string", length=30) + */ protected $payment_method; - protected $change_for; - protected $perpared_by; - protected $curr_batt_serial; - protected $curr_batt_dr_num; - protected $curr_batt_date_replace; - protected $curr_batt_brand; - protected $curr_batt_type; - protected $curr_batt_issued_by; - protected $curr_batt_issued_direct; - protected $orig_batt_serial; - protected $orig_batt_or_num; - protected $orig_batt_date_purchase; - protected $orig_batt_brand; - protected $orig_batt_type; - protected $orig_batt_pur_from; - protected $orig_batt_pur_from_direct; - protected $orig_batt_warr_expire_date; - protected $orig_trade_in_batt; -*/ + + /** + * @ORM\Column(type="string", length=30) + */ + protected $prepared_by; + + /** + * @ORM\Column(type="string", length=10) + */ + protected $dispatch_time; + + /** + * @ORM\Column(type="string", length=10) + */ + protected $dispatch_date; + + /** + * @ORM\Column(type="string", length=30) + */ + protected $dispatched_by; + + /** + * @ORM\Column(type="string", length=200) + */ + protected $address; + + /** + * @ORM\Column(type="string", length=320) + */ + protected $landmark; + + /** + * @ORM\Column(type="string", length=10) + */ + protected $date_purchase; + + /** + * @ORM\Column(type="string", length=20) + */ + protected $plate_number; + public function setID($id) diff --git a/src/Entity/LegacyJobOrderRow.php b/src/Entity/LegacyJobOrderRow.php new file mode 100644 index 00000000..6927afb2 --- /dev/null +++ b/src/Entity/LegacyJobOrderRow.php @@ -0,0 +1,72 @@ +id = $id; + return $this; + } + + public function getID() + { + return $this->id; + } +} diff --git a/src/Ramcar/LegacyOrigin.php b/src/Ramcar/LegacyOrigin.php new file mode 100644 index 00000000..6fb9b90c --- /dev/null +++ b/src/Ramcar/LegacyOrigin.php @@ -0,0 +1,41 @@ + 'Direct', + 'facebook' => 'Facebook', + 'hotline' => 'Hotline', + 'online' => 'Online', + 'website' => 'Website', + ]; + + public static function translate($origin) + { + $clean_origin = strtolower(trim($origin)); + + switch ($clean_origin) + { + case 'direct': + return self::DIRECT; + case 'facebook': + return self::FACEBOOK; + case 'hotline': + return self::HOTLINE; + case 'online (24 hour window time)': + return self::ONLINE; + case 'website': + return self::WEBSITE; + } + + return false; + } +} diff --git a/src/Ramcar/LegacyTransactionType.php b/src/Ramcar/LegacyTransactionType.php new file mode 100644 index 00000000..1fc45ef2 --- /dev/null +++ b/src/Ramcar/LegacyTransactionType.php @@ -0,0 +1,37 @@ + 'Purchase', + 'post' => 'Post Service', + 'resq' => 'Res-q Service', + 'service' => 'Service', + ]; + + public static function translate($type) + { + $clean_type = strtolower(trim($type)); + + switch ($clean_type) + { + case 'post service': + return self::POST_SERVICE; + case 'purchase': + return self::PURCHASE; + case 'res-q services': + return self::RESQ_SERVICE; + case 'service': + return self::SERVICE; + } + + return false; + } +}