QuoteCostSheetItem.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using InABox.Core;
  2. namespace Comal.Classes
  3. {
  4. [UserTracking(typeof(Quote))]
  5. public class QuoteCostSheetItem : Entity, IRemotable, IPersistent, IQuoteCostSheetItem, IOneToMany<QuoteCostSheet>, ITaxable, ILicense<QuotesManagementLicense>
  6. {
  7. [NullEditor]
  8. [EntityRelationship(DeleteAction.Cascade)]
  9. public QuoteCostSheetLink CostSheet { get; set; }
  10. [EntityRelationship(DeleteAction.SetNull)]
  11. [EditorSequence(1)]
  12. public ProductLink Product { get; set; }
  13. [TextBoxEditor]
  14. [EditorSequence(2)]
  15. public string Description { get; set; }
  16. [DoubleEditor]
  17. [EditorSequence(3)]
  18. public double Qty { get; set; }
  19. [DoubleEditor]
  20. [EditorSequence(4)]
  21. public double Cost { get; set; }
  22. [EditorSequence(6)]
  23. public TaxCodeLink TaxCode { get; set; }
  24. [EnumLookupEditor(typeof(QuoteCostSheetItemLineType))]
  25. public QuoteCostSheetItemLineType Type { get; set; }
  26. [NullEditor]
  27. public long Sequence { get; set; }
  28. [DoubleEditor(Editable = Editable.Disabled, Summary = Summary.Sum)]
  29. [EditorSequence(5)]
  30. public double ExTax { get; set; }
  31. [NullEditor]
  32. public double TaxRate { get; set; }
  33. [DoubleEditor(Editable = Editable.Disabled, Summary = Summary.Sum)]
  34. [EditorSequence(7)]
  35. public double Tax { get; set; }
  36. [DoubleEditor(Editable = Editable.Disabled, Summary = Summary.Sum)]
  37. [EditorSequence(8)]
  38. public double IncTax { get; set; }
  39. protected override void Init()
  40. {
  41. base.Init();
  42. CostSheet = new QuoteCostSheetLink();
  43. Product = new ProductLink(this);
  44. LinkProperty<ProductLink, QuoteCostSheetItem>(x => x.Name, x => x.Description);
  45. LinkProperty<ProductLink, QuoteCostSheetItem>(x => x.NettCost, x => x.Cost);
  46. LinkProperty<ProductLink, QuoteCostSheetItem>(x => x.TaxCode.ID, x => x.TaxCode.ID);
  47. TaxCode = new TaxCodeLink(this);
  48. LinkProperty<TaxCodeLink, QuoteCostSheetItem>(x => x.Rate, x => x.TaxRate);
  49. }
  50. protected override void DoPropertyChanged(string name, object before, object after)
  51. {
  52. base.DoPropertyChanged(name, before, after);
  53. if (name.Equals("Qty"))
  54. ExTax = (double)after * Cost;
  55. else if (name.Equals("Cost"))
  56. ExTax = (double)after * Qty;
  57. }
  58. }
  59. }