From c8e2c02be192deaa377da02b8b4702d852d39f9b Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 2 Apr 2024 01:11:32 -0400 Subject: [PATCH 1/2] Add a separate service fee for motolite users for jumpstart. #798 --- src/InvoiceRule/Jumpstart.php | 59 ++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/src/InvoiceRule/Jumpstart.php b/src/InvoiceRule/Jumpstart.php index d2e89b0a..141e648e 100644 --- a/src/InvoiceRule/Jumpstart.php +++ b/src/InvoiceRule/Jumpstart.php @@ -68,18 +68,8 @@ class Jumpstart implements InvoiceRuleInterface public function getServiceTypeFee($source, CustomerVehicle $cv) { - // check the source of JO - // (1) if from app, service fee is 0 if motolite user. jumpstart fee for app if non-motolite user. - // (2) any other source, jumpstart fees are charged whether motolite user or not - if ($source == TransactionOrigin::MOBILE_APP) - { - if ($cv->hasMotoliteBattery()) - $code = 'motolite_user_service_fee'; - else - $code = 'jumpstart_fee_mobile_app'; - } - else - $code = 'jumpstart_fee'; + // get the service fee code, depending on the JO source and if customer vehicle has a motolite battery + $code = $this->getServiceFeeCode($cv, $source); $fee = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]); @@ -110,20 +100,10 @@ class Jumpstart implements InvoiceRuleInterface if ($item_type == null) return null; - // find the service offering - // check the source of JO - // (1) if from app, service fee is 0 if motolite user. jumpstart fee for app if non-motolite user. - // (2) any other source, jumpstart fees are charged whether motolite user or not - if ($source == TransactionOrigin::MOBILE_APP) - { - if ($cv->hasMotoliteBattery()) - $code = 'motolite_user_service_fee'; - else - $code = 'jumpstart_fee_mobile_app'; - } - else - $code = 'jumpstart_fee'; + // get the service fee code, depending on the JO source and if customer vehicle has a motolite battery + $code = $this->getServiceFeeCode($cv, $source); + // find the service offering $service = $this->em->getRepository(ServiceOffering::class)->findOneBy(['code' => $code]); // check if service is null. If null, return null @@ -144,4 +124,33 @@ class Jumpstart implements InvoiceRuleInterface return $title; } + + protected function getServiceFeeCode(CustomerVehicle $cv, $source) + { + // check the source of JO + // (1) if from app, service fee is 0 if motolite user. jumpstart fee for app if non-motolite user. + // (2) any other source, jumpstart fees are charged whether motolite user or not. Service fees for non-motolite + // and motolite users are now different (used to be the same) + if ($source == TransactionOrigin::MOBILE_APP) + { + if ($cv->hasMotoliteBattery()) + $code = 'motolite_user_service_fee'; + else + $code = 'jumpstart_fee_mobile_app'; + } + else + { + error_log('hotline'); + if ($cv->hasMotoliteBattery()) + { + error_log('has motolite battery'); + $code = 'motolite_user_jumpstart_fee'; + } + else + $code = 'jumpstart_fee'; + } + + return $code; + + } } -- 2.43.5 From 6a804c11dfd27a259bc746e1d7112fc55e993e3c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 2 Apr 2024 01:21:23 -0400 Subject: [PATCH 2/2] Add sql file to update service offering table. #798 --- .../updated_jumpstart_service_offering.sql | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 utils/service_offering/updated_jumpstart_service_offering.sql diff --git a/utils/service_offering/updated_jumpstart_service_offering.sql b/utils/service_offering/updated_jumpstart_service_offering.sql new file mode 100644 index 00000000..88805a02 --- /dev/null +++ b/utils/service_offering/updated_jumpstart_service_offering.sql @@ -0,0 +1,54 @@ +-- MySQL dump 10.19 Distrib 10.3.39-MariaDB, for Linux (x86_64) +-- +-- Host: localhost Database: resq +-- ------------------------------------------------------ +-- Server version 10.3.39-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `service_offering` +-- + +DROP TABLE IF EXISTS `service_offering`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `service_offering` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(80) NOT NULL, + `code` varchar(80) NOT NULL, + `fee` decimal(9,2) NOT NULL, + PRIMARY KEY (`id`), + KEY `service_offering_idx` (`code`) +) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `service_offering` +-- + +LOCK TABLES `service_offering` WRITE; +/*!40000 ALTER TABLE `service_offering` DISABLE KEYS */; +INSERT INTO `service_offering` VALUES (1,'Tax','tax',0.12),(2,'Motolite User Service Fee','motolite_user_service_fee',0.00),(3,'Battery Replacement Warranty Fee','battery_replacement_warranty_fee',0.00),(4,'Fuel Service Fee','fuel_service_fee',300.00),(5,'Fuel Gas Fee','fuel_gas_fee',340.00),(6,'Fuel Diesel Fee','fuel_diesel_fee',320.00),(7,'Jumpstart Fee','jumpstart_fee',300.00),(8,'Jumpstart Fee Mobile App','jumpstart_fee_mobile_app',300.00),(9,'Jumpstart Warranty Fee','jumpstart_warranty_fee',300.00),(10,'Overheat Fee','overheat_fee',300.00),(11,'Coolant Fee','coolant_fee',1600.00),(12,'Post Recharged Fee','post_recharged_fee',300.00),(13,'Post Replacement Fee','post_replacement_fee',0.00),(14,'Tire Repair Fee','tire_repair_fee',300.00),(17,'Motolite User Jumpstart Warranty Fee','motolite_user_jumpstart_warranty_fee',200.00),(18,'Motolite User Jumpstart Fee','motolite_user_jumpstart_fee',200.00); +/*!40000 ALTER TABLE `service_offering` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2024-04-02 1:17:40 -- 2.43.5