public async Task <bool> CreateIncome(GeneralLedgerView glView) { try { //ChartOfAccts coa = await unitOfWork.generalLedgerRepository.GetChartofAccount("1000", "1200", "300", ""); ChartOfAccount coa = await ChartOfAccounts.Query().GetEntity("1000", "1200", "300", ""); //Udc udcLedgerType = await unitOfWork.generalLedgerRepository.GetUdc("GENERALLEDGERTYPE", "AA"); Udc udcLedgerType = await UDC.Query().GetUdc("GENERALLEDGERTYPE", "AA"); Udc udcDocType = await UDC.Query().GetUdc("DOCTYPE", "PV"); //Udc udcDocType = await unitOfWork.generalLedgerRepository.GetUdc("DOCTYPE","PV"); //AddressBook addressBook = await unitOfWork.addressBookRepository.GetAddressBookByAddressId(addressId); AddressBook addressBook = await AddressBook.Query().GetEntityById(glView.AddressId); glView.DocType = udcDocType.KeyCode; glView.AccountId = coa.AccountId; glView.LedgerType = udcLedgerType.KeyCode; glView.CreatedDate = DateTime.Now; glView.AddressId = addressBook.AddressId; glView.FiscalPeriod = glView.GLDate.Month; glView.FiscalYear = glView.GLDate.Year; glView.DebitAmount = glView.Amount; glView.CreditAmount = 0; GeneralLedgerView glLookup = null; if (String.IsNullOrEmpty(glView.CheckNumber) == false) { glLookup = await GeneralLedger.Query().GetLedgerViewByExpression( e => e.AccountId == glView.AccountId && e.AddressId == glView.AddressId && e.Amount == glView.Amount && e.CheckNumber == glView.CheckNumber && e.DocType == glView.DocType && e.Gldate == glView.GLDate ); } if (glLookup == null) { //create income GeneralLedger.CreateGeneralLedgerByView(glView).Apply(); GeneralLedger.UpdateAccountBalances(glView); GeneralLedgerView glViewLookup = await GeneralLedger.Query().GetViewByDocNumber(glView.DocNumber, glView.DocType); return(glViewLookup != null); } else { glView.DocNumber = glLookup.DocNumber; } return(true); } catch (Exception ex) { throw new Exception("CreateCash", ex); } }
public async Task <InventoryView> SetViewDependencies(InventoryView view) { Task <ItemMaster> itemMasterTask = _unitOfWork.itemMasterRepository.GetEntityById(view.ItemId); Task <ChartOfAccount> accountTask = _unitOfWork.chartOfAccountRepository.GetEntityById(view.DistributionAccountId); Task.WaitAll(itemMasterTask, accountTask); ItemMaster itemMaster = await itemMasterTask; ChartOfAccount distributionAccount = await accountTask; FluentItemMaster fluentItemMaster = new FluentItemMaster(_unitOfWork); FluentChartOfAccount fluentChartOfAccount = new FluentChartOfAccount(_unitOfWork); if (itemMaster != null) { view.ItemMasterView = await fluentItemMaster.Query().MapToView(itemMaster); } if (distributionAccount != null) { view.DistributionAccountView = await fluentChartOfAccount.Query().MapToView(await accountTask); } return(view); }