OvertimeInterval.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using InABox.Core;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. namespace Comal.Classes
  6. {
  7. public enum OvertimeIntervalType
  8. {
  9. Interval,
  10. RemainingTime
  11. }
  12. [EntitySecurity(
  13. CanView = typeof(CanView<Overtime>),
  14. CanEdit = typeof(CanEdit<Overtime>),
  15. CanDelete = typeof(CanEdit<Overtime>)
  16. )]
  17. public class OvertimeInterval : Entity, IRemotable, IPersistent, IOneToMany<Overtime>, ILicense<TimeManagementLicense>, ISequenceable
  18. {
  19. [EntityRelationship(DeleteAction.Cascade)]
  20. public OvertimeLink Overtime { get; set; }
  21. [TextBoxEditor(Visible = Visible.Default)]
  22. [EditorSequence(1)]
  23. public string Description { get; set; }
  24. [EnumLookupEditor(typeof(OvertimeIntervalType), Visible = Visible.Default)]
  25. [EditorSequence(2)]
  26. public OvertimeIntervalType IntervalType { get; set; }
  27. [TimeOfDayEditor(Visible = Visible.Default)]
  28. [EditorSequence(3)]
  29. public TimeSpan Interval { get; set; }
  30. [TextBoxEditor(Visible = Visible.Default)]
  31. [EditorSequence(4)]
  32. public string PayrollID { get; set; }
  33. [CheckBoxEditor(Visible = Visible.Default)]
  34. [EditorSequence(5)]
  35. public bool IsPaid { get; set; }
  36. [DoubleEditor(Visible = Visible.Default)]
  37. [EditorSequence(6)]
  38. public double Multiplier { get; set; }
  39. [NullEditor]
  40. public long Sequence { get; set; }
  41. public OvertimeInterval()
  42. {
  43. Description = "";
  44. PayrollID = "";
  45. IsPaid = true;
  46. Multiplier = 1.0;
  47. IntervalType = OvertimeIntervalType.Interval;
  48. }
  49. public static OvertimeInterval NewInterval(TimeSpan duration, double multiplier = 1.0)
  50. {
  51. return new OvertimeInterval
  52. {
  53. Interval = duration,
  54. Multiplier = multiplier,
  55. IsPaid = true,
  56. IntervalType = OvertimeIntervalType.Interval
  57. };
  58. }
  59. public static OvertimeInterval NewUnpaidInterval(TimeSpan duration)
  60. {
  61. return new OvertimeInterval
  62. {
  63. Interval = duration,
  64. Multiplier = 0.0,
  65. IsPaid = false,
  66. IntervalType = OvertimeIntervalType.Interval
  67. };
  68. }
  69. public static OvertimeInterval NewRemaining(double multiplier = 1.0)
  70. {
  71. return new OvertimeInterval
  72. {
  73. Multiplier = multiplier,
  74. IsPaid = true,
  75. IntervalType = OvertimeIntervalType.RemainingTime
  76. };
  77. }
  78. }
  79. }