JobScopeCostCentre.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using InABox.Core;
  2. namespace Comal.Classes
  3. {
  4. public class JobScopeCostCentre : Entity, IRemotable, IPersistent, IOneToMany<Job>, IOneToMany<JobScope>, ILicense<ProjectManagementLicense>
  5. {
  6. [NullEditor]
  7. [EntityRelationship(DeleteAction.Cascade)]
  8. public JobLink Job { get; set; }
  9. [NullEditor]
  10. [EntityRelationship(DeleteAction.Cascade)]
  11. public JobScopeLink Scope { get; set; }
  12. [EditorSequence(1)]
  13. [EntityRelationship(DeleteAction.SetNull)]
  14. public CostCentreLink CostCentre { get; set; }
  15. [EditorSequence(2)]
  16. [CurrencyEditor(Summary = Summary.Sum)]
  17. public double Cost { get; set; }
  18. [EditorSequence(3)]
  19. public double Markup { get; set; }
  20. [EditorSequence(4)]
  21. [CurrencyEditor(Summary = Summary.Sum, Editable = Editable.Disabled)]
  22. public double Sell { get; set; }
  23. protected override void DoPropertyChanged(string name, object? before, object? after)
  24. {
  25. base.DoPropertyChanged(name, before, after);
  26. if (name.Equals(nameof(Cost)))
  27. Sell = ((double?)after ?? 0.0F) * ((100.0F + Markup) / 100.0F);
  28. else if (name.Equals(nameof(Markup)))
  29. Sell = Cost * ((100.0F + ((double?)after ?? 0.0F)) / 100.0F);
  30. }
  31. }
  32. }