Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. trigger ProductRevenue on ProductStore__c (after update) {
  2.  
  3. List<Revenue__C> newOpps = new List<Revenue__C>();
  4.  
  5. for (ProductStore__c prodobj : Trigger.new) {
  6.  
  7. Revenue__C revobj = new Revenue__c();
  8. if(prodobj.QuantitySold__c > 1)
  9. {
  10. revobj.Transaction__C = prodobj.QuantitySold__c + ' ' + prodobj.Name__c + 's' + ' ' + 'sold';
  11. }
  12.  
  13. else
  14. {
  15. revobj.Transaction__C = prodobj.QuantitySold__c + ' ' + prodobj.Name__c + ' ' + 'sold';
  16. }
  17.  
  18. revobj.Revenue__c = (prodobj.QuantitySold__c)*(prodobj.Price__C);
  19. revobj.DateTime__C = datetime.now();
  20. revobj.ProductType__C = prodobj.Name__c;
  21. revobj.QuantitySold__C = prodobj.QuantitySold__c;
  22.  
  23.  
  24.  
  25. newOpps.add(revobj);
  26.  
  27. }
  28. insert newOpps;
  29.  
  30. }
  31.  
  32. @isTest
  33. private class TestProductRevenue {
  34.  
  35. static testMethod void Testing()
  36.  
  37. {
  38.  
  39. List<ProductStore__c> newlist = new List<ProductStore__c>();
  40. ProductStore__c obj = new ProductStore__C ();
  41. obj = [SELECT ProductStore__c.QuantitySold__C FROM ProductStore__c WHERE ProductStore__c.Name = 'AC'];
  42. obj.QuantitySold__C = 2;
  43. newlist.add(obj);
  44.  
  45. Test.startTest();
  46. update newlist;
  47. Test.stopTest();
  48.  
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement