public bool AddPaymentRetention(RetentionType retentionType, decimal?amount = null) { if (retentionType == null) { return(false); } if (this.PaymentRetentions == null) { this.PaymentRetentions = new HashSet <PaymentRetention>(); } var paymentRetention = this.PaymentRetentions .Where(p => p.RetentionTypeId == retentionType.Id) .FirstOrDefault(); if (paymentRetention != null) { throw new Exception("Account aleardy exist"); } paymentRetention = new PaymentRetention() { Id = Guid.NewGuid(), RetentionType = retentionType, RetentionTypeId = retentionType.Id, RetentionAmount = amount ?? (this.TotalCommercialAmount * (retentionType.Rate ?? 0) / 100), }; this.PaymentRetentions.Add(paymentRetention); this.UpdateBalance(); return(true); }
public void RemovePaymentRetention(PaymentRetention paymentRetention) { if (paymentRetention == null) { return; } this.PaymentRetentions.Remove(paymentRetention); this.UpdateBalance(); }