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 Update(RetentionType type) { this.Name = type.Name; this.Description = type.Description; this.RetentionToAccountGuid = type.RetentionToAccountGuid; this.IsActive = type.IsActive; this.Id = type.Id; this.Rate = type.Rate; this.RetentionDirection = type.RetentionDirection; }