public static DeductionPayment Create(Deduction deduction, MonetaryValue custom_payment = null) { var record = new DeductionPayment { _employee = deduction.GetEmployee(), _deduction = deduction, // PaidAmount = (custom_payment is null) ? deduction.AmortizedAmount : custom_payment.PreciseValue PaidAmount = custom_payment ?? deduction.AmortizedAmount }; // emit event EventBroker.getInstance().Emit(new EventDeductionPaymentCreated(record, deduction)); return(record); }
// TODO: use CQRS Query private void onCommandIncludeSalaryDeductionInReport(object sender, Command cmd) { if (cmd is CommandIncludeSalaryDeductionInReport) { var args = cmd as CommandIncludeSalaryDeductionInReport; if (args.PayrollReport.Equals(this._payroll_report)) { foreach (var deduction in this._salary.ActiveDeductions) { // because deduction can be whole even if the payroll is half // we include the MonthlyUnit for deduction payment in CQRS command var amount = deduction.AmortizedAmount.PreciseValue * (decimal)args.MonthlyUnit; var payment = DeductionPayment.Create(deduction, MonetaryValue.of(deduction.MonetaryCode, amount)); this._deduction_payments.Add(payment); this._gross_deduction += payment.PaidAmount.PreciseValue; EventBroker.getInstance().Emit(new EventDeductionPaymentIncludedInPayroll(this._payroll_report, payment)); } } } }
public EventExcludedDeductionPayment(DeductionPayment payment, Employee employee, PayrollReport report) { this.DeductionPayment = payment; this.Employee = employee; this.Report = report; }
public EventDeductionPaymentCreated(DeductionPayment payment, Deduction deduction) { this.Deduction = deduction; this.DeductionPayment = payment; }
public EventDeductionPaymentCreated(PayrollReport pr, Deduction d, DeductionPayment dp) { PayrollReport = pr; Deduction = d; DeductionPayment = dp; }
public EventDeductionPaymentIncludedInPayroll(PayrollReport report, DeductionPayment payment) { this.PayrollReport = report; this.DeductionPayment = payment; }