Denny Chen
2022-02-28 6947068a02499b9d1022f9efca5bcf1bdd3f1c70
force-app/main/default/classes/SI_NewQuoteEntryController.cls
@@ -10,6 +10,10 @@
    public Boolean changedAfterBid { get; set; }                    // true の場合、画面に confirm メッセージが表示します。quoIdを新しい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専用ですが、jsにて制御することになるので、TODO 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;