From 6947068a02499b9d1022f9efca5bcf1bdd3f1c70 Mon Sep 17 00:00:00 2001
From: Denny Chen <chenbangcai@prec-tech.com>
Date: 星期一, 28 二月 2022 10:45:11 +0800
Subject: [PATCH] Note test

---
 force-app/main/default/classes/SI_NewQuoteEntryController.cls |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/force-app/main/default/classes/SI_NewQuoteEntryController.cls b/force-app/main/default/classes/SI_NewQuoteEntryController.cls
index cc6d526..2ca8205 100644
--- a/force-app/main/default/classes/SI_NewQuoteEntryController.cls
+++ b/force-app/main/default/classes/SI_NewQuoteEntryController.cls
@@ -10,6 +10,10 @@
     public Boolean changedAfterBid { get; set; }                    // true 銇牬鍚堛�佺敾闈€伀 confirm 銉°儍銈汇兗銈搞亴琛ㄧず銇椼伨銇欍�俼uoId銈掓柊銇椼亜insert銆傚垽瀹氥伅js銇仹瀹熸柦
     //public Id qlistId { get; set; }
 
+    //lastbuy  2022/2/9 fy start
+    public Boolean filg { get; set; }
+    //lastbuy  2022/2/9 fy end
+
     public String excel_text { get; set; }
     public Integer select_index { get; set; }                       // excelImport灏傜敤銇с仚銇屻�乯s銇仸鍒跺尽銇欍倠銇撱仺銇仾銈嬨伄銇с�乀ODO katsu 鍓婇櫎浜堝畾
     public String Product_text { get; set; }
@@ -1014,6 +1018,7 @@
     }
     //娣诲姞琛�
   public void addMultipleRow() {
+      system.debug('11111111111111111===11111111111111');
     List<QELine> tmpQELine = new List<QELine>();
     //椤甸潰涓婄殑杈撳叆妗嗚拷鍔� (鍙兘鍦ㄦ湯灏捐拷鍔�)
     
@@ -1675,6 +1680,13 @@
                     StockFlg++;
                 }
             }
+            //20220215 fy lastbuy start
+            if(!ReservedProductVerification()){
+                errorflg = true;
+                errormessage =  '浜у搧鏁伴噺涓嶅彲瓒呰繃浜у搧棰勭暀鏁伴噺' ;
+                return null;
+            }
+              //20220215 fy lastbuy end
             system.debug('PassFlg:'+PassFlg);
             system.debug('StockFlg:'+StockFlg);
             if(PassFlg == 0&&oldListCheck[0].Old_Opportunity_ID__c==null){
@@ -2560,6 +2572,7 @@
         //Sap閫佷俊,Print銇悎銈忋仜銇�1锝�
         Integer i=1;
         if (activities.size()>0) {
+            system.debug('activities+++***+++'+activities);
             for (QELine s:activities) {
                 if (s.Asset_Model != null && s.Asset_Model != '') {
                     if (s.pageObject.PricebookEntryId != null) {
@@ -2757,7 +2770,36 @@
         }
         return true;
     }
-
+//lastbuy  2022/2/15 fy start
+public boolean ReservedProductVerification() {
+    filg=true;
+    Map<string,QuoteLineItem> quotlinitMap = new Map<string,QuoteLineItem>();
+    List<Id> lastProductFLGList = new List<Id>();
+    for(QELine qli : activities){
+      lastProductFLGList.add(qli.pageObject.PricebookEntry.Product2Id);
+      quotlinitMap.put(qli.pageObject.PricebookEntry.Product2Id,qli.pageObject);
+    }
+    if(lastProductFLGList!=null){
+        List<LastbuyProduct__c> LastbuyObjList=[select id,LastbuyQuantity__c,InquiryCode__c,ProductName__c,effectiveFLG__c from LastbuyProduct__c where InquiryCode__c= : oppId and ProductName__c in :lastProductFLGList and  effectiveFLG__c= true];
+        if(LastbuyObjList!=null){
+            for(LastbuyProduct__c lastbuypr :LastbuyObjList){
+              Decimal quoteLItemNum=0;
+              if(quotlinitMap.containsKey(lastbuypr.ProductName__c)){
+                  quoteLItemNum=quotlinitMap.get(lastbuypr.ProductName__c).Quantity__c;
+              }else{
+                  continue;
+              }
+              if(lastbuypr.LastbuyQuantity__c<quoteLItemNum){
+                filg=false;
+                break;
+              }
+            }
+        }
+    }
+    system.debug('filg====='+filg);
+    return filg;
+  }
+  //lastbuy  2022/2/15 fy end
     //opp銇敾闈€伄鍊ゃ倰瑷畾
     private void setOppFromOppInfo() {
         opp.Wholesale_Price__c = oppInfo.Wholesale_Price;

--
Gitblit v1.9.1