From 5c79ed09628411b95f443ece77e63277e9752172 Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期五, 19 四月 2024 18:34:29 +0800
Subject: [PATCH] 123

---
 force-app/main/default/lwc/lexNewQuoteEntry/lexNexQuoteEntryUtil.js |   76 +++++++++++++++++++++++++++++--------
 1 files changed, 59 insertions(+), 17 deletions(-)

diff --git a/force-app/main/default/lwc/lexNewQuoteEntry/lexNexQuoteEntryUtil.js b/force-app/main/default/lwc/lexNewQuoteEntry/lexNexQuoteEntryUtil.js
index ce43f83..8cdad3f 100644
--- a/force-app/main/default/lwc/lexNewQuoteEntry/lexNexQuoteEntryUtil.js
+++ b/force-app/main/default/lwc/lexNewQuoteEntry/lexNexQuoteEntryUtil.js
@@ -4,6 +4,7 @@
 export var DataStatus;
 export var newQuoteFlagex;
 export var MultiYearWarrantyTotalPriceExport;
+export var ExtendedWarrantyAmountTotalPriceExport;
 export var newQuoteFlagExp;
 export var productStatusUpdatedExp;
 export var quoExp;
@@ -606,6 +607,7 @@
     quo.Dealer_Final_Price_Page__c = quoin.Dealer_Final_Price_Page__c!=undefined&&quoin.Dealer_Final_Price_Page__c!=='' ?localParseFloat(quoin.Dealer_Final_Price_Page__c):null;
     quo.OCM_Agent1_Price_Page__c = quoin.OCM_Agent1_Price_Page__c!=undefined &&quoin.OCM_Agent1_Price_Page__c!==''? localParseFloat(quoin.OCM_Agent1_Price_Page__c):null;
     quo.MultiYearWarrantyTotalPrice__c = quoin.MultiYearWarrantyTotalPrice__c!=undefined? localParseFloat(quoin.MultiYearWarrantyTotalPrice__c):null;
+    quo.ExtendedWarrantyAmountTotalPrice__c = quoin.ExtendedWarrantyAmountTotalPrice__c!=undefined? localParseFloat(quoin.ExtendedWarrantyAmountTotalPrice__c):null;
     quo.Estimation_List_Price__c = quoin.Estimation_List_Price__c!=undefined? localParseFloat(quoin.Estimation_List_Price__c):null;
     quo.QuoteTotal_Page__c = quoin.QuoteTotal_Page__c !=undefined?localParseFloat(quoin.QuoteTotal_Page__c):null;
     quo.Agency1_Profit__c = quoin.Agency1_Profit__c !=undefined?localParseFloat(quoin.Agency1_Profit__c):null;
@@ -1275,6 +1277,7 @@
         contractmultiYearWarranty = quo.multiYearWarranty__c;
     }
     var MultiYearWarrantyTotalPrice__c = 0.00;
+    var  ExtendedWarrantyAmountTotalPrice__c = 0.00;
     jzDataToBeproduct.forEach(jzdtbt=>{
         var GuranteeType =jzdtbt.pageObject.GuranteeType__c;
         // 淇濅慨绫诲瀷
@@ -1297,6 +1300,14 @@
         jzdtbt.pageObject.ServicePrice__c = 0;
         jzdtbt.warrantyType__c = '';
         var NoDiscountTotal = 0;
+        if(jzdtbt.exPrice != 0 && jzdtbt.exPrice != null && jzdtbt.exPrice != undefined ){
+            jzdtbt.exPriceCopy = jzdtbt.exPrice;
+        }
+        if(jzdtbt.Learning_Community != null && jzdtbt.Learning_Community != undefined && jzdtbt.Learning_Community != '0' && jzdtbt.Learning_Community != ''){
+            jzdtbt.Learning_CommunityCopy = jzdtbt.Learning_Community;
+        }
+        jzdtbt.exPrice = 0;
+        jzdtbt.Learning_Community = '0';
         if (GuranteeType == '鏈嶅姟') {
             multiYearWarranty = true;
             jzdtbt.warrantyType__c = '鏈嶅姟澶氬勾淇濅慨';
@@ -1304,20 +1315,26 @@
         } else if (GuranteeType == '甯傚満' && contractmultiYearWarranty == false) {
             multiYearWarranty = true;
             jzdtbt.pageObject.ServicePrice__c = ServicePrice;
+            jzdtbt.exPrice = jzdtbt.exPriceCopy;
+            jzdtbt.Learning_Community = jzdtbt.Learning_CommunityCopy;
             jzdtbt.warrantyType__c = '甯傚満澶氬勾淇濅慨';
             warrantyType = '甯傚満澶氬勾淇濅慨';
             var Quantity =jzdtbt.Quantity__c;
             MultiYearWarrantyTotalPrice__c = MultiYearWarrantyTotalPrice__c + localParseFloat(ServicePrice) * localParseFloat(Quantity);
+            ExtendedWarrantyAmountTotalPrice__c = ExtendedWarrantyAmountTotalPrice__c + localParseFloat(jzdtbt.exPrice) * localParseFloat(Quantity);
             NoDiscountTotal = localParseFloat(ServicePrice) * localParseFloat(Quantity);
         }
         else if (GuranteeType == '甯傚満' && contractmultiYearWarranty && CanNotCancelledGurantee) {
             multiYearWarranty = true;
             jzdtbt.pageObject.ServicePrice__c = ServicePrice;
+            // jzdtbt.exPrice = jzdtbt.exPriceCopy;
+            // jzdtbt.Learning_Community = jzdtbt.Learning_CommunityCopy;
             jzdtbt.warrantyType__c = '甯傚満澶氬勾淇濅慨';
             warrantyType = '甯傚満澶氬勾淇濅慨';
             // 鏁伴噺
             var Quantity = jzdtbt.Quantity__c;
             MultiYearWarrantyTotalPrice__c = MultiYearWarrantyTotalPrice__c + localParseFloat(ServicePrice) * localParseFloat(Quantity);
+            // ExtendedWarrantyAmountTotalPrice__c = ExtendedWarrantyAmountTotalPrice__c + localParseFloat(jzdtbt.exPrice) * localParseFloat(Quantity);
             NoDiscountTotal = localParseFloat(ServicePrice) * localParseFloat(Quantity);
         }
         else if (GuranteeType == '甯傚満') {
@@ -1345,12 +1362,18 @@
         var GuranteePrice = 0;
         // 璁℃彁骞撮檺
         var provistonPeriod = 0;
+        var exGuranteePrice = 0;
+        jzdtbt.multiYearWarrantyList.forEach(mu=>{
+            if(jzdtbt.Learning_Community == mu.AgeLimit__c + ''){
+                exGuranteePrice = mu.AmountWithheld__c;
+            }
+        });
         // 鏍规嵁浜у搧淇℃伅璁剧疆淇濅慨骞撮檺 鍜岃鎻愰噾棰�
         if (GuranteeType == '鏈嶅姟') {
             jzdtbt.pageObject.GuaranteePeriod__c = ProductEntend_gurantee_period | 0;
             jzdtbt.GuaranteePeriod__c = ProductEntend_gurantee_period | 0;
             GuranteePrice = ProductGuranteePrice__c;
-            jzdtbt.GuranteePrice = GuranteePrice;
+            jzdtbt.GuranteePrice = GuranteePrice + exGuranteePrice;
             provistonPeriod = ProductEntend_gurantee_period;
         } else if (GuranteeType == '甯傚満') {
             if (contractmultiYearWarranty == false) {
@@ -1363,7 +1386,7 @@
                 }
                 provistonPeriod = ProductEntend_gurantee_period;
                 GuranteePrice = ProductGuranteePrice__c;
-                jzdtbt.GuranteePrice = GuranteePrice;
+                jzdtbt.GuranteePrice = GuranteePrice + exGuranteePrice;
             }else if (contractmultiYearWarranty && CanNotCancelledGurantee) {
                 if (localParseFloat(ProductEntend_gurantee_period) >= localParseFloat(AllGurantee_Period)) {
                     jzdtbt.pageObject.GuaranteePeriod__c = ProductEntend_gurantee_period | 0;
@@ -1374,22 +1397,23 @@
                 }
                 provistonPeriod = ProductEntend_gurantee_period;
                 GuranteePrice = ProductGuranteePrice__c;
-                jzdtbt.GuranteePrice = GuranteePrice;
+                jzdtbt.GuranteePrice = GuranteePrice + exGuranteePrice;
             }
             else {
                 jzdtbt.pageObject.GuaranteePeriod__c =  1;
                 jzdtbt.GuaranteePeriod__c = 1;
-                jzdtbt.GuranteePrice = GuranteePrice;
+                jzdtbt.GuranteePrice = GuranteePrice + exGuranteePrice;
             }
         } else {
             jzdtbt.pageObject.GuaranteePeriod__c = AllGurantee_Period;
             jzdtbt.GuaranteePeriod__c = AllGurantee_Period;
-            jzdtbt.GuranteePrice = GuranteePrice;
+            jzdtbt.GuranteePrice = GuranteePrice + exGuranteePrice;
         }
         jzdtbt.pageObject.provistonPeriod__c = provistonPeriod | 0;
 
     });
     MultiYearWarrantyTotalPriceExport = MultiYearWarrantyTotalPrice__c;
+    ExtendedWarrantyAmountTotalPriceExport= ExtendedWarrantyAmountTotalPrice__c;
     return jzDataToBeproduct;
 }
 export function initQuoteLineItemcheck(quoteLineItem,productStatusUpdated){
@@ -1525,7 +1549,9 @@
     //no discount price 鍚堣
     var noDiscountPriceTotal = hidden_MultiYearWarrantyTotalPrice;
     noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
-    TotalPrice = TotalPrice - noDiscountPriceTotal;
+    var exPriceTotal = quo.ExtendedWarrantyAmountTotalPrice__c;
+    exPriceTotal = localParseFloat(exPriceTotal);
+    TotalPrice = TotalPrice - noDiscountPriceTotal - exPriceTotal;
     jzDataToBeproduct.forEach(jzdtbt=>{
         s = jzdtbt.Quantity__c;
         s = localParseInt(s);
@@ -1601,6 +1627,8 @@
     x = localParseFloat(x);
     var y = quo.hidden_Estimation_List;
     y = localParseFloat(y);
+    var z = quo.ExtendedWarrantyAmountTotalPrice__c;
+    z = localParseFloat(z);
     var noDiscountPriceTotal = hidden_MultiYearWarrantyTotalPrice;
     noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
     var thirdPartyEstimation_List_Price = 0;
@@ -1621,11 +1649,11 @@
         }
     });
     thirdPartyEstimation_List_Price = localParseFloat(thirdPartyEstimation_List_Price);
-    quo.Quote_Adjust_Amount_Page__c = toNumComma(x - noDiscountPriceTotal - y);
+    quo.Quote_Adjust_Amount_Page__c = toNumComma(x - noDiscountPriceTotal - y - z);
     if (y - thirdPartyEstimation_List_Price == 0) {
         quo.Quote_Adjust_Calculate__c = toNumComma(0);
     } else {
-        quo.Quote_Adjust_Calculate__c = toNumComma((x - noDiscountPriceTotal - y) / (y - thirdPartyEstimation_List_Price) * 100);
+        quo.Quote_Adjust_Calculate__c = toNumComma((x - noDiscountPriceTotal - y - z) / (y - thirdPartyEstimation_List_Price) * 100);
     }
     quoExp = quo;
     return jzDataToBeproduct;
@@ -1665,7 +1693,9 @@
                 //no discount price 鍚堣
                 var noDiscountPriceTotal = hidden_MultiYearWarrantyTotalPrice;
                 noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
-                var t = (y - noDiscountPriceTotal - thirdPartyEstimation_List_Price) / (Estimation_List_Price - thirdPartyEstimation_List_Price) * 100;
+                var exPriceTotal = quo.ExtendedWarrantyAmountTotalPrice__c;
+                exPriceTotal = localParseFloat(exPriceTotal);
+                var t = (y - noDiscountPriceTotal - exPriceTotal - thirdPartyEstimation_List_Price) / (Estimation_List_Price - thirdPartyEstimation_List_Price) * 100;
                 quo.AgencyDiscount__c = toNumComma(t);
                 // j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(t));
             }
@@ -1793,6 +1823,8 @@
     //no discount price 鍚堣
     var noDiscountPriceTotal = hidden_MultiYearWarrantyTotalPrice;
     noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal);
+    var exPriceTotal = quo.ExtendedWarrantyAmountTotalPrice__c;
+    exPriceTotal = localParseFloat(exPriceTotal);
     jzDataToBeproduct.forEach(jzdtbt=>{
         s = jzdtbt.Quantity__c;
         s = localParseInt(s);
@@ -1834,7 +1866,7 @@
                 VenderName = '';
             }
             if (VenderName == 'OSH' || VenderName == '') {
-                yy = localParseFloat(x * (z - noDiscountPriceTotal) / y);
+                yy = localParseFloat(x * (z - noDiscountPriceTotal - exPriceTotal) / y);
                 jzdtbt.pageObject.Subtotal__c = toNum(yy + s * noDiscountPrice);
                 // jzdtbt.Subtotal__c = toNumComma(yy + s * noDiscountPrice);
                 jzdtbt.Subtotal__c = yy + s * noDiscountPrice;
@@ -1846,7 +1878,7 @@
             zz = zz + yy;
         }
     });
-    quo.QuoteTotal_Page__c = toNumComma(zz + noDiscountPriceTotal);
+    quo.QuoteTotal_Page__c = toNumComma(zz + noDiscountPriceTotal + exPriceTotal);
     quoExp = quo;
     return jzDataToBeproduct;
 }
@@ -1976,6 +2008,7 @@
         quo.OCM_Agent1_Price_Page__c = '';
     }
     quo.MultiYearWarrantyTotalPrice__c = toNumComma(quo.MultiYearWarrantyTotalPrice__c);
+    quo.ExtendedWarrantyAmountTotalPrice__c = toNumComma(quo.ExtendedWarrantyAmountTotalPrice__c);
     quo.Agency1_Profit__c = toNumComma(quo.Agency1_Profit__c);
     quo.Agency2_Profit__c = toNumComma(quo.Agency2_Profit__c);
     //棰勬祴閲戦淇敼 fy
@@ -2202,7 +2235,7 @@
         dataMap.set(key,value);
     });
     jzDataToBeproduct.forEach(jzdtbt=>{
-        var x, y, z, c;
+        var x, y, z, c ,e;
         if(dataMap.has(jzdtbt.lineNo)){
             var datavaue = dataMap.get(jzdtbt.lineNo);
             if(datavaue.Quantity__c){
@@ -2221,13 +2254,15 @@
                         jzdtbt.exPrice = item.MultiOneYearWarrantyPrice__c;
                     }
                 });
-                if(jzdtbt.exPrice == null || jzdtbt.exPrice == '' || jzdtbt.exPrice == undefined){
+                if(jzdtbt.exPrice == null || jzdtbt.exPrice == '' || jzdtbt.exPrice == undefined || jzdtbt.Learning_Community == '0'){
                     jzdtbt.exPrice = 0;
                 }
             }
+            console.log("saf");
             x = localParseInt(jzdtbt.Quantity__c);
             y = localParseFloat(jzdtbt.UnitPrice_Page__c);
             c = localParseFloat(jzdtbt.Cost_c);
+            e = localParseFloat(jzdtbt.exPrice);
             z = x * y;
             // jzdtbt.Subtotal__c = toNumComma(z)
             jzdtbt.Subtotal__c = z
@@ -2327,7 +2362,9 @@
         x = localParseFloat(x);
         y = y + localParseFloat(x);
     });
-    quo.QuoteTotal_Page__c = toNumComma(y);
+    var e = quo.ExtendedWarrantyAmountTotalPrice__c;
+    e = localParseFloat(e);
+    quo.QuoteTotal_Page__c = toNumComma(y + e);
     var z = quo.Estimation_List_Price__c;
     var id = quoId;
     // if(!id){
@@ -2337,13 +2374,15 @@
             mp = localParseFloat(mp);
             var num = quo.Quote_Adjust_Calculate__c;
             num = localParseFloat(num);
+            var ex = quo.ExtendedWarrantyAmountTotalPrice__c;
+            ex = localParseFloat(ex);
             quo.Quote_Adjust_Calculate__c = toNumComma(num);
             num = (100 + num) / 100;
             z=localParseFloat(z);
             var rh = oppInfo.rate_hospital;
             var ra = oppInfo.rate_agency1;
             quo.Dealer_Final_Price_Page__c = toNumComma(z*rh);
-            quo.OCM_Agent1_Price_Page__c = Saleslet ? toNumComma(z*num*ra+mp) : '';
+            quo.OCM_Agent1_Price_Page__c = Saleslet ? toNumComma(z*num*ra+mp+ex) : '';
         }
     // }
     quoExp = quo;
@@ -2643,7 +2682,8 @@
             //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� start 
             item.IFEndoRapidFlag = jzdtbt.IFEndoRapidFlag;
             //DB202312560765 you 鍚︽湁EndoRapid璧勮川妫�鏌� end
-            if(jzdtbt.PricebookEntry.Product2.ProductCategory__c == 'SP涓绘満'){
+            var qwe = jzdtbt.PricebookEntry ? jzdtbt.PricebookEntry.Product2.ProductCategory__c : jzdtbt.pageObject.PricebookEntry.Product2.ProductCategory__c;
+            if(qwe == 'SP涓绘満'){
                 item.SPAssistantFlag = true;
                 flag = true;
             }
@@ -2658,7 +2698,9 @@
 export function  Agent1comput(quo,Saleslet,oppInfo){
     var z = quo.Estimation_List_Price__c;
     var mp =quo.MultiYearWarrantyTotalPrice__c;
+    var ex = quo.ExtendedWarrantyAmountTotalPrice__c;
     mp = localParseFloat(mp);
+    ex = localParseFloat(ex);
     var num = quo.Quote_Adjust_Calculate__c;
     num = localParseFloat(num);
     quo.Quote_Adjust_Calculate__c = toNumComma(num);
@@ -2667,6 +2709,6 @@
     var rh = oppInfo.rate_hospital;
     var ra = oppInfo.rate_agency1;
     quo.Dealer_Final_Price_Page__c = toNumComma(z*rh);
-    quo.OCM_Agent1_Price_Page__c = Saleslet ? toNumComma(z*num*ra+mp):'';
+    quo.OCM_Agent1_Price_Page__c = Saleslet ? toNumComma(z*num*ra+mp+ex):'';
     return quo;
 }
\ No newline at end of file

--
Gitblit v1.9.1