JobScopeActivity.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using InABox.Core;
  3. namespace Comal.Classes
  4. {
  5. public class JobScopeActivity : Entity, IRemotable, IPersistent, IOneToMany<Job>, IOneToMany<JobScope>, ILicense<ProjectManagementLicense>
  6. {
  7. [NullEditor]
  8. [EntityRelationship(DeleteAction.Cascade)]
  9. public JobLink Job { get; set; }
  10. [NullEditor]
  11. [EntityRelationship(DeleteAction.Cascade)]
  12. public JobScopeLink Scope { get; set; }
  13. [EditorSequence(1)]
  14. [EntityRelationship(DeleteAction.SetNull)]
  15. public AssignmentActivityLink Activity { get; set; }
  16. [EditorSequence(2)]
  17. [DurationEditor(Summary = Summary.Sum)]
  18. public TimeSpan Hours { get; set; }
  19. [EditorSequence(3)]
  20. public double Rate { get; set; }
  21. [EditorSequence(4)]
  22. [CurrencyEditor(Summary = Summary.Sum, Editable = Editable.Disabled)]
  23. public double Cost { get; set; }
  24. [EditorSequence(5)]
  25. public double Markup { get; set; }
  26. [EditorSequence(6)]
  27. [CurrencyEditor(Summary = Summary.Sum, Editable = Editable.Disabled)]
  28. public double Sell { get; set; }
  29. protected override void DoPropertyChanged(string name, object? before, object? after)
  30. {
  31. base.DoPropertyChanged(name, before, after);
  32. if (name.Equals(nameof(Hours)))
  33. {
  34. Cost = Rate * ((TimeSpan?)after ?? TimeSpan.Zero).TotalHours;
  35. Sell = Cost * ((100.0F + Markup)/100.0F);
  36. }
  37. else if (name.Equals(nameof(Rate)))
  38. {
  39. Cost = Hours.TotalHours * ((double?)after ?? 0.0F);
  40. Sell = Cost * ((100.0F + Markup)/100.0F);
  41. }
  42. else if (name.Equals(nameof(Markup)))
  43. Sell = Cost * ((100.0F + ((double?)after ?? 0.0F))/100.0F);
  44. }
  45. }
  46. }