Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. protected void ExecutePostQuoteProductUpdate(LocalPluginContext localContext)
  2. {
  3. if (localContext == null)
  4. {
  5. throw new ArgumentNullException("localContext");
  6. }
  7.  
  8. IPluginExecutionContext context = localContext.PluginExecutionContext;
  9. IOrganizationService service = localContext.OrganizationService;
  10.  
  11. Guid quoteProductID = (Guid)((Entity)context.InputParameters["Target"]).Id;
  12. ColumnSet set = new ColumnSet();
  13. set.AllColumns = true;
  14.  
  15. var quote = service.Retrieve("quotedetail", quoteProductID, set);
  16. var priceperunit = quote.Attributes["priceperunit"];
  17. var teamleader = quote.Attributes["new_disc"];
  18. var manualdiscountamount = quote.Attributes["manualdiscountamount"];
  19. var volumediscountamount = quote.Attributes["volumediscountamount"];
  20. var VAT = (int)quote.Attributes["new_vat"];
  21.  
  22. var discountamount = (double)priceperunit * (double)teamleader / 100;
  23. var baseamount = (double)priceperunit - discountamount;
  24. var tax = baseamount * VAT / 100;
  25. var extendedamount = baseamount + tax;
  26. quote.Attributes["new_discountamount"] = discountamount;
  27. quote.Attributes["baseamount"] = baseamount;
  28. quote.Attributes["tax"] = tax;
  29. quote["description"] = priceperunit;
  30. quote.Attributes["extendedamount"] = extendedamount;
  31. service.Update(quote);
  32.  
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement