Guest User

Untitled

a guest
Dec 13th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using PX.SM;
  5. using PX.Data;
  6. using PX.Objects.IN;
  7. using RealEstate.DAC.Extensions;
  8.  
  9. namespace RealEstate.Graphs.CO
  10. {
  11. // Page : RE201001
  12. public class PropertyMaint : InventoryItemMaint
  13. {
  14. protected new virtual void InventoryItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
  15. {
  16. base.InventoryItem_RowSelected(cache, e);
  17. InventoryItem item = (InventoryItem)e.Row;
  18. var itemExt = item.GetExtension<InventoryItemExtension>();
  19. PropertyComputation prop = new PropertyComputation(item);
  20. itemExt.UsrRETotalSellingPrice = prop.TotalSellingPrice;
  21. itemExt.UsrRELotSellingPrice = prop.LotSellingPrice;
  22. itemExt.UsrREContractPriceTotal = prop.TotalContractPrice;
  23. }
  24. }
  25.  
  26. public class PropertyComputation
  27. {
  28. private readonly InventoryItem _item;
  29. private readonly InventoryItemExtension _ext;
  30.  
  31. public decimal TotalSellingPrice;
  32. public decimal LotSellingPrice;
  33. public decimal TotalContractPrice;
  34.  
  35. public PropertyComputation(InventoryItem item)
  36. {
  37. _item = item;
  38.  
  39. _ext = item.GetExtension<InventoryItemExtension>();
  40.  
  41. LotSellingPrice = GetLotSellingPrice(_ext);
  42.  
  43. TotalSellingPrice = GetSellingPriceTotal(_ext);
  44.  
  45. TotalContractPrice = GetTotalContractPrice(_ext);
  46. }
  47.  
  48. protected decimal GetLotSellingPrice(InventoryItemExtension ext)
  49. {
  50. return (ext.UsrRELandAreaTotal ?? 0) * (ext.UsrREPricePerSqAmt ?? 0);
  51. }
  52.  
  53. protected decimal GetSellingPriceTotal(InventoryItemExtension ext)
  54. {
  55. return GetLotSellingPrice(ext) + (ext.UsrREHouseSellingPrice ?? 0) + (ext.UsrREEngineeredFillCost ?? 0);
  56. }
  57.  
  58. protected decimal GetTotalContractPrice(InventoryItemExtension ext)
  59. {
  60. decimal totalSellingPrice = GetSellingPriceTotal(ext);
  61. decimal vat = totalSellingPrice * 0.12M;
  62. decimal registrationFee = ext.UsrRERegistrationAmt ?? 0;
  63. decimal moveInFee = ext.UsrREMoveInAmt ?? 0;
  64. decimal redeemableCommission = ext.UsrRERedeemableCommissionAmt ?? 0;
  65. decimal increaseCommission = 0;
  66. decimal misc = ext.UsrREMiscAmt ?? 0;
  67.  
  68. return totalSellingPrice + vat + registrationFee + moveInFee + redeemableCommission + misc + increaseCommission;
  69. }
  70. }
  71.  
  72. }
Add Comment
Please, Sign In to add comment