@isTest
|
private class ConsumableOrderDetail1TriggerTest {
|
static testMethod void testInsert() {
|
Consumable_order__c co = new Consumable_order__c();
|
co.Name = 'testorderSum';
|
insert co;
|
|
//插入明细1
|
Consumable_orderdetails__c cod1 = new Consumable_orderdetails__c();
|
cod1.Name = 'testorderdetail1';
|
cod1.Consumable_order__c = co.Id;
|
//cod1.Sum_of_money__c=10000;
|
cod1.Dealer_Custom_Price__c=1000;
|
cod1.Consumable_count__c=10;
|
//cod1.Invoice_Cost_RMB__c=1000;
|
//Invoice_Cost_RMB__c=Shipment_amount__c - RrturnPro_Cost_RMB__c - InvoicedProCost_RMB__c < 0 , 0, Shipment_amount__c - RrturnPro_Cost_RMB__c - InvoicedProCost_RMB__c
|
cod1.Invoiced_Procount__c=5;
|
cod1.InvoicedProCost_RMB__c=5000;
|
//cod1.Shipment_amount__c=8000;
|
//Shipment_Count__c * Delivery_List_RMB__c
|
cod1.Shipment_Count__c =8;
|
cod1.Delivery_List_RMB__c=1000;
|
//cod1.RrturnPro_Cost_RMB__c=2000;
|
//ReturnGoods_unitPrice__c * RrturnPro_count__c
|
//cod1.ReturnGoods_unitPrice__c=1000;
|
cod1.RrturnPro_count__c=2;
|
|
upsert cod1;
|
|
Consumable_order__c order1 = [select id,Total_amount__c,Total_num__c,InvoiceNotPro_total_amount__c,Total_Invoiced_Procount__c,InvoicedPro_total_amount__c,Shipment_total_amount__c, RrturnPro_total_count__c,RrturnPro_total_amount__c,Invoice_total_amount__c from Consumable_order__c where Id = :co.Id];
|
|
//System.assertEquals(10000,order1.Total_amount__c);
|
//System.assertEquals(10,order1.Total_num__c);
|
//System.assertEquals(1000,order1.InvoiceNotPro_total_amount__c);
|
//System.assertEquals(5,order1.Total_Invoiced_Procount__c);
|
//System.assertEquals(5000,order1.InvoicedPro_total_amount__c);
|
//System.assertEquals(8000,order1.Shipment_total_amount__c);
|
//System.assertEquals(2,order1.RrturnPro_total_count__c);
|
//System.assertEquals(2000,order1.RrturnPro_total_amount__c);
|
//System.assertEquals(5000,order1.Invoice_total_amount__c);
|
|
//插入明细2
|
Consumable_orderdetails__c cod2 = new Consumable_orderdetails__c();
|
cod2.Name = 'testorderdetail2';
|
cod2.Consumable_order__c = co.Id;
|
//cod1.Sum_of_money__c=10000;
|
cod2.Dealer_Custom_Price__c=1000;
|
cod2.Consumable_count__c=10;
|
//cod1.Invoice_Cost_RMB__c=1000;
|
//Invoice_Cost_RMB__c=Shipment_amount__c - RrturnPro_Cost_RMB__c - InvoicedProCost_RMB__c < 0 , 0, Shipment_amount__c - RrturnPro_Cost_RMB__c - InvoicedProCost_RMB__c
|
cod2.Invoiced_Procount__c=5;
|
cod2.InvoicedProCost_RMB__c=5000;
|
//cod1.Shipment_amount__c=8000;
|
//Shipment_Count__c * Delivery_List_RMB__c
|
cod2.Shipment_Count__c =8;
|
cod2.Delivery_List_RMB__c=1000;
|
//cod1.RrturnPro_Cost_RMB__c=2000;
|
//ReturnGoods_unitPrice__c * RrturnPro_count__c
|
//cod2.ReturnGoods_unitPrice__c=1000;
|
cod2.RrturnPro_count__c=2;
|
upsert cod2;
|
|
Consumable_order__c order2 = [select id,Total_amount__c,Total_num__c,InvoiceNotPro_total_amount__c,Total_Invoiced_Procount__c,InvoicedPro_total_amount__c,Shipment_total_amount__c, RrturnPro_total_count__c,RrturnPro_total_amount__c,Invoice_total_amount__c from Consumable_order__c where Id = :co.Id];
|
|
//System.assertEquals(20000,order2.Total_amount__c);
|
//System.assertEquals(20,order2.Total_num__c);
|
//System.assertEquals(2000,order2.InvoiceNotPro_total_amount__c);
|
//System.assertEquals(10,order2.Total_Invoiced_Procount__c);
|
//System.assertEquals(10000,order2.InvoicedPro_total_amount__c);
|
//System.assertEquals(16000,order2.Shipment_total_amount__c);
|
//System.assertEquals(4,order2.RrturnPro_total_count__c);
|
//System.assertEquals(4000,order2.RrturnPro_total_amount__c);
|
//System.assertEquals(10000,order2.Invoice_total_amount__c);
|
|
//变更明细2
|
Consumable_orderdetails__c cod3 = new Consumable_orderdetails__c();
|
cod3.Name = 'testorderdetail2';
|
cod3.Id=cod2.id;
|
//cod1.Sum_of_money__c=10000;
|
cod3.Dealer_Custom_Price__c=1000;
|
cod3.Consumable_count__c=20;
|
//cod1.Invoice_Cost_RMB__c=1000;
|
//Invoice_Cost_RMB__c=Shipment_amount__c - RrturnPro_Cost_RMB__c - InvoicedProCost_RMB__c < 0 , 0, Shipment_amount__c - RrturnPro_Cost_RMB__c - InvoicedProCost_RMB__c
|
cod3.Invoiced_Procount__c=5;
|
cod3.InvoicedProCost_RMB__c=5000;
|
//cod1.Shipment_amount__c=8000;
|
//Shipment_Count__c * Delivery_List_RMB__c
|
cod3.Shipment_Count__c =8;
|
cod3.Delivery_List_RMB__c=1000;
|
//cod1.RrturnPro_Cost_RMB__c=2000;
|
//ReturnGoods_unitPrice__c * RrturnPro_count__c
|
//cod3.ReturnGoods_unitPrice__c=1000;
|
cod3.RrturnPro_count__c=2;
|
upsert cod3;
|
|
Consumable_order__c order3 = [select id,Total_amount__c,Total_num__c,InvoiceNotPro_total_amount__c,Total_Invoiced_Procount__c,InvoicedPro_total_amount__c,Shipment_total_amount__c, RrturnPro_total_count__c,RrturnPro_total_amount__c,Invoice_total_amount__c from Consumable_order__c where Id = :co.Id];
|
|
//System.assertEquals(30000,order3.Total_amount__c);
|
//System.assertEquals(30,order3.Total_num__c);
|
//System.assertEquals(2000,order3.InvoiceNotPro_total_amount__c);
|
//System.assertEquals(10,order3.Total_Invoiced_Procount__c);
|
//System.assertEquals(10000,order3.InvoicedPro_total_amount__c);
|
//System.assertEquals(16000,order3.Shipment_total_amount__c);
|
//System.assertEquals(4,order3.RrturnPro_total_count__c);
|
//System.assertEquals(4000,order3.RrturnPro_total_amount__c);
|
//System.assertEquals(10000,order3.Invoice_total_amount__c);
|
|
//删除明细2
|
Consumable_orderdetails__c cod4 = new Consumable_orderdetails__c();
|
cod4.Id=cod2.Id;
|
delete cod4;
|
|
Consumable_order__c order4 = [select id,Total_amount__c,Total_num__c,InvoiceNotPro_total_amount__c,Total_Invoiced_Procount__c,InvoicedPro_total_amount__c,Shipment_total_amount__c, RrturnPro_total_count__c,RrturnPro_total_amount__c,Invoice_total_amount__c from Consumable_order__c where Id = :co.Id];
|
|
//System.assertEquals(10000,order1.Total_amount__c);
|
//System.assertEquals(10,order1.Total_num__c);
|
//System.assertEquals(1000,order1.InvoiceNotPro_total_amount__c);
|
//System.assertEquals(5,order1.Total_Invoiced_Procount__c);
|
//System.assertEquals(5000,order1.InvoicedPro_total_amount__c);
|
//System.assertEquals(8000,order1.Shipment_total_amount__c);
|
//System.assertEquals(2,order1.RrturnPro_total_count__c);
|
//System.assertEquals(2000,order1.RrturnPro_total_amount__c);
|
//System.assertEquals(5000,order1.Invoice_total_amount__c);
|
|
}
|
}
|