高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
@isTest
private class RepairQuoteTriggerTest {
 
    private static Repair__c rpr { get; set; }
    private static Repair_Quotation__c rq { get; set; }
 
    private static void init() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科'];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科'];
        if (rectDpt.size() == 0) {
            return;
        }
        // テストデータ
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM104TestCompany';
        upsert company;
        Account section = [Select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where ParentId = :company.Id and RecordTypeId = :rectSct[0].Id];
 
        Account depart = new Account();
        depart.RecordTypeId        = rectDpt[0].Id;
        depart.Name                = '*';
        depart.Department_Name__c  = 'NFM104TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        upsert depart;
 
        company = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :company.Id];
        depart = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :depart.Id];
 
        Product2 prd1 = new Product2();
        prd1.ProductCode_Ext__c     = 'NFM104Prd1';
        prd1.ProductCode            = 'NFM104Prd1';
        prd1.Repair_Product_Code__c = 'NFM104Prd1_RP';
        prd1.Name                   = 'NFM104Prd1';
        prd1.Manual_Entry__c        = false;
        insert prd1;
 
        Asset ast = new Asset();
        ast.Name                             = 'NFM104Ast1';
        ast.AccountId                        = depart.Id;
        ast.Department_Class__c              = section.Id;
        ast.Hospital__c                      = company.Id;
        ast.Product2Id                       = prd1.Id;
        ast.SerialNumber                     = 'NFM104SerialNumber';
        ast.Guarantee_period_for_products__c = Date.today();
        ast.InstallDate                      = Date.today();
        insert ast;
 
        Profile p = [select Id from Profile where id =:System.Label.ProfileId_SystemAdmin];
 
        User us = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', Work_Location__c = '北京', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = p.id);
        us.Job_Category__c = '销售服务';
        insert us;
 
        rpr = new Repair__c();
        rpr.SAPRepairNo__c   = 'NFM104Rpr1';
        rpr.Account__c             = depart.Id;
        rpr.Department_Class__c    = section.Id;
        rpr.Hospital__c            = company.Id;
        rpr.Delivered_Product__c   = ast.Id;
        rpr.SalesOfficeCode_selection__c = '北京';
        rpr.Status__c              = '1.受理完毕';
        rpr.Incharge_Staff__c = us.Id;
        rpr.Repair_Detail__c = 'test';
        rpr.On_site_repair__c = '直送SORC修理';
        insert rpr;
 
        rq = new Repair_Quotation__c();
        rq.Name              = 'testNFM104';
        rq.Repair__c       = rpr.Id;
        rq.Repair_quotation_status__c = '减价申请填写完毕';
        rq.Request_amount_after_discount__c = 5000;
        rq.Background_Description__c = '测试';
        rq.Discount_reason__c = '减价申请';
 
    }
    
    @isTest 
    static void test_isInsert() {
        init();
        insert rq;
    }
    
    @isTest 
    static void test_isUpdate() {
        init();
        rq.Repair_quotation_status__c = '';
        rq.Discount_request_approval_date__c = Date.today() - 100;
        rq.Approvering_Date__c = Date.today() - 100;
        insert rq;
 
        rq.Repair_quotation_status__c = '减价申请填写完毕';
        rq.Discount_request_approval_date__c = Date.today();
        rq.Approvering_Date__c = Date.today();
        update rq;
    }
    //20200106 add start
    @isTest 
    static void test_isUpdate1() {
        init();
        rq.CutPriceStatus_Service__c='草案中'; 
        rq.CutPrice_Reason_Service__c='99';
        rq.Expect_CutPrice__c = 800;
        rq.Background_Description__c = 'ceshi';
        insert rq;
        rq.CutPriceStatus_Service__c='已提交';
        rq.ServiceCutPriceApplyDate__c =  Date.today();
        
        update rq;
        Boolean jl = String.isBlank(rq.ServiceManager__c);
        Boolean bz = String.isBlank(rq.BuchangApprovalServiceManager__c);
        Boolean zj = String.isBlank(rq.ZongjianApprovalServiceManager__c);
        System.assertEquals( true,jl);
        System.assertEquals( true,bz);
        System.assertEquals( true,zj);
 
    }
    //20200106 add end
 
    
}