private CustomerLedger MapToEntity(CustomerLedgerView inputObject) { Mapper mapper = new Mapper(); CustomerLedger outObject = mapper.Map <CustomerLedger>(inputObject); return(outObject); }
public async Task <IFluentCustomerLedger> CreateEntityByGeneralLedgerView(GeneralLedgerView ledgerView) { CustomerLedgerView customerLedgerView = applicationViewFactory.MapToCustomerLedgerView(ledgerView); //Get the AcctRecId AccountReceivable acctRec = await unitOfWork.accountReceivableRepository.GetAcctRecByDocNumber(ledgerView.DocNumber); if (acctRec != null) { customerLedgerView.AccountReceivableId = acctRec.AccountReceivableId; customerLedgerView.InvoiceId = acctRec.InvoiceId ?? 0; customerLedgerView.CustomerId = acctRec.CustomerId; customerLedgerView.GeneralLedgerId = ledgerView.GeneralLedgerId; CreateEntityByView(customerLedgerView); } return(this as IFluentCustomerLedger); }
public IFluentCustomerLedger CreateEntityByView(CustomerLedgerView view) { try { Task <CustomerLedger> queryTask = Task.Run(async() => await unitOfWork.customerLedgerRepository.FindEntityByGeneralLedgerId(view.GeneralLedgerId)); Task.WaitAll(queryTask); if (queryTask.Result == null) { CustomerLedger customerLedger = MapToEntity(view); //applicationViewFactory.MapCustomerLedgerEntity(ref customerLedger, view); AddCustomerLedger(customerLedger); return(this as IFluentCustomerLedger); } processStatus = CreateProcessStatus.AlreadyExists; return(this as IFluentCustomerLedger); } catch (Exception ex) { throw new Exception("CreateEntityFromView", ex); } }
public async Task TestAddUpdatDelete() { AddressBook addressBook = null; CustomerLedgerModule CustomerLedgerMod = new CustomerLedgerModule(); Customer customer = await CustomerLedgerMod.Customer.Query().GetEntityById(9); Invoice invoice = await CustomerLedgerMod.Invoice.Query().GetEntityById(18); AccountReceivable accountReceivable = await CustomerLedgerMod.AccountReceivable.Query().GetEntityById(12); ChartOfAccount chartOfAccount = await CustomerLedgerMod.ChartOfAccount.Query().GetEntityById(3); GeneralLedger generalLedger = await CustomerLedgerMod.GeneralLedger.Query().GetEntityById(12); if (customer != null) { addressBook = await CustomerLedgerMod.AddressBook.Query().GetEntityById(customer.AddressId); } CustomerLedgerView view = new CustomerLedgerView() { CustomerId = customer.CustomerId, CustomerName = addressBook?.Name, InvoiceId = invoice.InvoiceId, InvoiceDocument = invoice.InvoiceDocument, AccountReceivableId = accountReceivable.AccountReceivableId, Amount = generalLedger.Amount, GLDate = generalLedger.Gldate, AccountId = chartOfAccount.AccountId, Account = chartOfAccount.Account, AccountDescription = chartOfAccount.Description, GeneralLedgerId = generalLedger.GeneralLedgerId, DocNumber = generalLedger.DocNumber, Comment = generalLedger.Comment, AddressId = addressBook.AddressId, CreatedDate = generalLedger.CreatedDate, DocType = generalLedger.DocType, DebitAmount = generalLedger.DebitAmount, CreditAmount = generalLedger.CreditAmount, FiscalYear = 2019, FiscalPeriod = 7, CheckNumber = generalLedger.CheckNumber }; NextNumber nnNextNumber = await CustomerLedgerMod.CustomerLedger.Query().GetNextNumber(); view.CustomerLedgerNumber = nnNextNumber.NextNumberValue; CustomerLedger customerLedger = await CustomerLedgerMod.CustomerLedger.Query().MapToEntity(view); CustomerLedgerMod.CustomerLedger.AddCustomerLedger(customerLedger).Apply(); CustomerLedger newCustomerLedger = await CustomerLedgerMod.CustomerLedger.Query().GetEntityByNumber(view.CustomerLedgerNumber); Assert.NotNull(newCustomerLedger); newCustomerLedger.Comment = "payment in part update"; CustomerLedgerMod.CustomerLedger.UpdateCustomerLedger(newCustomerLedger).Apply(); CustomerLedgerView updateView = await CustomerLedgerMod.CustomerLedger.Query().GetViewById(newCustomerLedger.CustomerLedgerId); Assert.Same(updateView.Comment, "payment in part update"); CustomerLedgerMod.CustomerLedger.DeleteCustomerLedger(newCustomerLedger).Apply(); CustomerLedger lookupCustomerLedger = await CustomerLedgerMod.CustomerLedger.Query().GetEntityById(view.CustomerLedgerId); Assert.Null(lookupCustomerLedger); }