public void UnPostLedger(LiabilityPayment LiabilityPayment) { Console.WriteLine("> Un Posting,"); organization.LedgersDal.RemoveTransaction(LiabilityPayment.Id); LiabilityPayment.PostStatus = LedgerPostStatus.ReadyToPost; erpNodeDBContext.SaveChanges(); }
public LiabilityPayment Save(LiabilityPayment payment) { var existPayment = erpNodeDBContext.LiabilityPayments.Find(payment.Id); if (existPayment == null && payment.LiabilityAccountId != null) { existPayment = organization.LiabilityPayments.CreateNew((Guid)payment.LiabilityAccountId, payment.Amount); erpNodeDBContext.SaveChanges(); return(payment); } else if (existPayment != null) { if (existPayment.PostStatus == LedgerPostStatus.Posted) { return(existPayment); } existPayment.TransactionDate = payment.TransactionDate; existPayment.LiabilityAccountId = payment.LiabilityAccountId; existPayment.Amount = payment.Amount; existPayment.BankFeeAmount = 0; erpNodeDBContext.SaveChanges(); return(existPayment); } return(null); }
public bool PostLedger(LiabilityPayment tr, bool SaveImmediately = true) { if (tr.PostStatus == LedgerPostStatus.Posted) { return(false); } if (tr.LiabilityAccount == null) { return(false); } var trLedger = new Models.Accounting.LedgerGroup() { Id = tr.Id, TransactionDate = tr.TransactionDate, TransactionName = tr.Name, TransactionNo = tr.No, TransactionType = transactionType }; //Dr. trLedger.AddDebit(tr.LiabilityAccount, tr.Amount); //Cr. tr.PaymentRetentions.ToList().ForEach(pr => trLedger.AddCredit(pr.RetentionType.RetentionToAccount, pr.RetentionAmount)); tr.PaymentFromAccounts.ToList().ForEach(payFrom => trLedger.AddCredit(payFrom.AccountItem, payFrom.PayAmount)); trLedger.AddCredit(tr.AssetAccount, tr.AmountLiabilityPayFromPrimaryAcc); if (tr.BankFeeAmount > 0) { trLedger.AddDebit(organization.SystemAccounts.BankFee, tr.BankFeeAmount); trLedger.AddCredit(tr.AssetAccount, tr.BankFeeAmount); } if (trLedger.FinalValidate()) { erpNodeDBContext.LedgerGroups.Add(trLedger); tr.PostStatus = LedgerPostStatus.Posted; } else { return(false); } if (SaveImmediately) { erpNodeDBContext.SaveChanges(); } return(true); }
public LiabilityPayment Create(Profile profile) { var payment = new LiabilityPayment() { TransactionDate = DateTime.Today, }; erpNodeDBContext.LiabilityPayments.Add(payment); return(payment); }
public bool Remove(LiabilityPayment payment) { if (payment.PostStatus != LedgerPostStatus.Posted) { erpNodeDBContext.LiabilityPayments.Remove(payment); erpNodeDBContext.SaveChanges(); return(true); } else { throw new Exception("Posted Transaction"); } }
public LiabilityPayment Copy(LiabilityPayment originalLiabilityPayment, DateTime trDate) { var cloneLiabilityPayment = this.erpNodeDBContext.LiabilityPayments .AsNoTracking() .FirstOrDefault(x => x.Id == originalLiabilityPayment.Id); cloneLiabilityPayment.Id = Guid.NewGuid(); cloneLiabilityPayment.TransactionDate = trDate; cloneLiabilityPayment.No = organization.LiabilityPayments.NextNumber; cloneLiabilityPayment.PostStatus = LedgerPostStatus.ReadyToPost; this.erpNodeDBContext.LiabilityPayments.Add(cloneLiabilityPayment); this.erpNodeDBContext.SaveChanges(); return(cloneLiabilityPayment); }
public LiabilityPayment CreateNew(Guid liabilityAccountId, decimal liabilityAmount = 0) { var LiabilityPayment = new LiabilityPayment() { Id = Guid.NewGuid(), LiabilityAccountId = liabilityAccountId, TransactionDate = DateTime.Today, Amount = liabilityAmount, AssetAccount = organization.SystemAccounts.Cash, TransactionType = TransactionTypes.LiabilityPayment, }; erpNodeDBContext.LiabilityPayments.Add(LiabilityPayment); erpNodeDBContext.SaveChanges(); return(LiabilityPayment); }