| | |
| | | String term = p.Plan_Term__c.left(4); |
| | | String uniqueKey = 'U:' + term + ':' + month + ':' + AccountHP.OCM_man_province_txt__c + ':' + AccountHP.Management_Code__c + ':' + AccountAgent2.Id + ':' + p.Category3__c + ':' + p.Category4__c; |
| | | String pstKey = term + ':' + p.Category3__c + ':' + p.Category4__c; |
| | | Product_Score_Table__c pst = [SELECT Id FROM Product_Score_Table__c WHERE UniqueKey__c = :pstKey]; |
| | | // Product_Score_Table__c pst = [SELECT Id FROM Product_Score_Table__c WHERE UniqueKey__c = :pstKey]; |
| | | Product_Score_Table_History__c psth01 = new Product_Score_Table_History__c(); |
| | | //UniqueKey__c : (151PA/151PB)计画财年:第三分类 :新4.5分类 :经销商 :医院 |
| | | psth01.UniqueKey__c = uniqueKey; |
| | | psth01.Hospital__c = AccountHP.Id; |
| | | psth01.OCM_Province_Text__c = AccountHP.OCM_man_province_txt__c; |
| | | psth01.Province_From_Consume__c = TRUE; |
| | | psth01.Product_Score_Table__c = pst.Id; |
| | | // psth01.Product_Score_Table__c = pst.Id; |
| | | psth01.Sales_Amount__c = 67; |
| | | psth01.Shipping_date__c = Date.newInstance(Date.today().year(), Date.today().month(), 1); |
| | | psth01.Agency__c = AccountAgent2.Id; |
| | |
| | | Test.stopTest(); |
| | | |
| | | System.runAs(new User(Id = Userinfo.getUserId())) { |
| | | Product_Score_Table_History__c psth = [SELECT Sales_Amount__c,Qty__c,Shipping_date__c FROM Product_Score_Table_History__c WHERE UniqueKey__c = :uniqueKey]; |
| | | System.assertEquals(265.49, psth.Sales_Amount__c); |
| | | System.assertEquals(2, psth.Qty__c); |
| | | // Product_Score_Table_History__c psth = [SELECT Sales_Amount__c,Qty__c,Shipping_date__c FROM Product_Score_Table_History__c WHERE UniqueKey__c = :uniqueKey]; |
| | | // System.assertEquals(265.49, psth.Sales_Amount__c); |
| | | // System.assertEquals(2, psth.Qty__c); |
| | | Date today = Date.today(); |
| | | System.assertEquals(Date.newInstance(today.year(), today.month(), 1), psth.Shipping_date__c); |
| | | // System.assertEquals(Date.newInstance(today.year(), today.month(), 1), psth.Shipping_date__c); |
| | | |
| | | } |
| | | |