public async Task TestCustomerCashPayment2() { int customerId = 2; UnitOfWork unitOfWork = new UnitOfWork(); GeneralLedgerView ledgerView = new GeneralLedgerView(); long?addressId = await unitOfWork.customerRepository.GetAddressIdByCustomerId(customerId); ChartOfAccts coa = await unitOfWork.chartOfAccountRepository.GetChartofAccount("1000", "1200", "101", ""); ledgerView.GeneralLedgerId = -1; ledgerView.DocNumber = 1; ledgerView.DocType = "PV"; ledgerView.Amount = 250M; ledgerView.LedgerType = "AA"; ledgerView.GLDate = DateTime.Parse("8/10/2018"); ledgerView.AccountId = coa.AccountId; ledgerView.CreatedDate = DateTime.Parse("8/10/2018"); ledgerView.AddressId = addressId ?? 0; ledgerView.Comment = "First installment payment for dashboard"; ledgerView.DebitAmount = 250; ledgerView.CreditAmount = 0; ledgerView.FiscalPeriod = 8; ledgerView.FiscalYear = 2018; ledgerView.CheckNumber = "112"; AccountsReceivableModule acctRecMod = new AccountsReceivableModule(); acctRecMod .CustomerCashPayment .GeneralLedger.CreateGeneralLedger(ledgerView).Apply(); acctRecMod .CustomerCashPayment .CustomerLedger .CreateCustomerLedger(ledgerView) .Apply(); acctRecMod .CustomerCashPayment .AccountsReceivable .UpdateAccountReceivable(ledgerView) .Apply(); acctRecMod .CustomerCashPayment .GeneralLedger .UpdateAccountBalances(ledgerView); //bool result = await acctRec.CustomerCashPayment(ledgerView); Assert.True(true); }
public async Task TestCustomerCashPayment() { int customerId = 9; UnitOfWork unitOfWork = new UnitOfWork(); GeneralLedgerView ledgerView = new GeneralLedgerView(); long?addressId = await unitOfWork.customerRepository.GetAddressIdByCustomerId(customerId); ChartOfAccts coa = await unitOfWork.chartOfAccountRepository.GetChartofAccount("1000", "1200", "101", ""); ledgerView.GeneralLedgerId = -1; ledgerView.DocNumber = 12; ledgerView.DocType = "PV"; ledgerView.Amount = 189.63M; ledgerView.LedgerType = "AA"; ledgerView.GLDate = DateTime.Parse("7/21/2018"); ledgerView.AccountId = coa.AccountId; ledgerView.CreatedDate = DateTime.Parse("7/21/2018"); ledgerView.AddressId = addressId ?? 0; ledgerView.Comment = "Payment in Part for 50% sharing of project income"; ledgerView.DebitAmount = 189.63M; ledgerView.CreditAmount = 0; ledgerView.FiscalPeriod = 7; ledgerView.FiscalYear = 2018; ledgerView.CheckNumber = "111"; AccountsReceivableModule acctRecMod = new AccountsReceivableModule(); acctRecMod .CustomerCashPayment .GeneralLedger .CreateGeneralLedger(ledgerView) .Apply(); acctRecMod .CustomerCashPayment .CustomerLedger .CreateCustomerLedger(ledgerView) .Apply(); acctRecMod .CustomerCashPayment .AccountsReceivable .UpdateAccountReceivable(ledgerView) .Apply(); acctRecMod .CustomerCashPayment .GeneralLedger .UpdateAccountBalances(ledgerView); Assert.True(true); }
public async Task TestCreateBudget() { UnitOfWork unitOfWork = new UnitOfWork(); BudgetModule budgetMod = new BudgetModule(); BudgetRangeView budgetRangeView = new BudgetRangeView(); //personal mortgage ChartOfAccts coa = await unitOfWork.chartOfAccountRepository.GetChartofAccount("1000", "1200", "502", "01"); budgetRangeView.StartDate = DateTime.Parse("1/1/2018");; budgetRangeView.EndDate = DateTime.Parse("12/31/2018");; budgetRangeView.Location = coa.Location; budgetRangeView.GenCode = coa.GenCode; budgetRangeView.SubCode = coa.SubCode; budgetRangeView.CompanyCode = coa.Company.CompanyCode; budgetRangeView.BusinessUnit = coa.BusUnit; budgetRangeView.ObjectNumber = coa.ObjectNumber; budgetRangeView.Subsidiary = coa.Subsidiary; budgetRangeView.AccountId = coa.AccountId; budgetRangeView.SupervisorCode = coa.SupCode; BudgetView budgetView = new BudgetView(); budgetMod.BudgetRange.CreateBudgetRange(budgetRangeView).Apply(); BudgetRangeView budgetRangeLookupView = budgetMod.BudgetRange.Query().GetBudgetRange(budgetRangeView.AccountId, budgetRangeView.StartDate, budgetRangeView.EndDate); budgetMod.Budget.MapRangeToBudgetView(ref budgetView, budgetRangeLookupView); BudgetActualsView budgetActualsView = budgetMod.Budget.Query().GetBudgetActualsView(budgetRangeLookupView); budgetView.BudgetAmount = 768 * 12; budgetView.BudgetHours = 0; budgetView.ProjectedAmount = 800 * 12; budgetView.ProjectedHours = 0; budgetView.ActualAmount = budgetActualsView.ActualAmount; budgetView.ActualHours = budgetActualsView.ActualHours; budgetMod.Budget.TransactBudget(budgetView).Apply(); Assert.True(true); }
public async Task TestPayAccountsPayable() { long customerId = 2; string poNumber = "PO-2"; UnitOfWork unitOfWork = new UnitOfWork(); GeneralLedgerView ledgerView = new GeneralLedgerView(); long?addressId = await unitOfWork.customerRepository.GetAddressIdByCustomerId(customerId); ChartOfAccts coa = await unitOfWork.chartOfAccountRepository.GetChartofAccount("1000", "1200", "210", ""); AcctPay acctPay = await unitOfWork.accountPayableRepository.GetAcctPayByPONumber(poNumber); SupplierInvoice supplierInvoice = await unitOfWork.supplierInvoiceRepository.GetSupplierInvoiceByPONumber(poNumber); if (coa == null || acctPay == null || supplierInvoice == null) { Assert.True(false); } //TODO create a process to match the ledger to the invoice and account receivable ledgerView.GeneralLedgerId = -1; ledgerView.SupplierId = 3; ledgerView.DocNumber = acctPay.DocNumber ?? 0; //doc number of the account payable ledgerView.AcctPayId = acctPay.AcctPayId; ledgerView.InvoiceId = supplierInvoice.SupplierInvoiceId; ledgerView.DocType = "PV"; ledgerView.Amount = 268M; ledgerView.LedgerType = "AA"; ledgerView.GLDate = DateTime.Parse("8/28/2018"); ledgerView.AccountId = coa.AccountId; ledgerView.CreatedDate = DateTime.Parse("8/28/2018"); ledgerView.AddressId = addressId ?? 0; ledgerView.Comment = "Payment for back to school"; ledgerView.DebitAmount = 0; ledgerView.CreditAmount = 268M; ledgerView.FiscalPeriod = 8; ledgerView.FiscalYear = 2018; ledgerView.CheckNumber = "113"; AccountsPayableModule acctPayablesMod = new AccountsPayableModule(); acctPayablesMod .Supplier .GeneralLedger.CreateGeneralLedger(ledgerView).Apply(); acctPayablesMod .Supplier .CreateSupplierLedger(ledgerView) .Apply(); acctPayablesMod .Supplier .UpdateAccountsPayable(ledgerView) .Apply(); acctPayablesMod .Supplier .GeneralLedger .UpdateAccountBalances(ledgerView); Assert.True(true); }
public async Task TestCreatePurchaseOrder() { UnitOfWork unitOfWork = new UnitOfWork(); ItemMaster itemMaster = new ItemMaster(); itemMaster.ItemNumber = "P2001Test"; itemMaster.Description = "Highlighter - 3 Color"; itemMaster.UnitOfMeasure = "Sets"; itemMaster.UnitPrice = 6M; bool result = await unitOfWork.itemMasterRepository.CreateItemMaster(itemMaster); if (result) { unitOfWork.CommitChanges(); } AddressBook addressBook = new AddressBook(); addressBook.CompanyName = "Sample Company Part Ltd"; addressBook.Name = ""; addressBook.FirstName = ""; addressBook.LastName = ""; LocationAddress locationAddress = new LocationAddress(); locationAddress.AddressLine1 = "204 Collins Street"; locationAddress.City = "Melbourne"; locationAddress.Zipcode = "3000"; locationAddress.Country = "Australia"; Emails email = new Emails(); email.Email = "*****@*****.**"; email.LoginEmail = true; email.Password = "******"; SupplierView supplierView = await unitOfWork.supplierRepository.CreateSupplierByAddressBook(addressBook, locationAddress, email); ChartOfAccts coa = await unitOfWork.supplierRepository.GetChartofAccount("1000", "1200", "240", ""); Company company = await unitOfWork.supplierRepository.GetCompany(); ItemMaster[] itemMasterLookup = new ItemMaster[5]; itemMasterLookup[0] = await unitOfWork.itemMasterRepository.GetObjectAsync(5); itemMasterLookup[1] = await unitOfWork.itemMasterRepository.GetObjectAsync(6); itemMasterLookup[2] = await unitOfWork.itemMasterRepository.GetObjectAsync(7); itemMasterLookup[3] = await unitOfWork.itemMasterRepository.GetObjectAsync(8); itemMasterLookup[4] = await unitOfWork.itemMasterRepository.GetObjectAsync(9); Udc udcAcctPayDocType = await unitOfWork.accountPayableRepository.GetUdc("AcctPayDocType", "STD"); string json = @"{ ""DocType"" : """ + udcAcctPayDocType.KeyCode + @""", ""PaymentTerms"" : ""Net 30"", ""GLDate"" : """ + DateTime.Parse("7/30/2018") + @""", ""AccountId"" :" + coa.AccountId + @", ""SupplierId"" :" + (supplierView.SupplierId ?? 0).ToString() + @", ""SupplierName"" :""" + supplierView.CompanyName + @""", ""Description"" :""Back to School Inventory"", ""PONumber"" :""PO-2"", ""TakenBy"" : ""David Nishimoto"", ""BuyerId"" :" + company.CompanyId + @", ""TaxCode1"" :""" + company.TaxCode1 + @""", ""TaxCode2"" :""" + company.TaxCode2 + @""", ""ShippedToName"" :""" + company.CompanyName + @""", ""ShippedToAddress1"" :""" + company.CompanyStreet + @""", ""ShippedToCity"" :""" + company.CompanyCity + @""", ""ShippedToState"" :""" + company.CompanyState + @""", ""ShippedToZipcode"" :""" + company.CompanyZipcode + @""", ""RequestedDate"" :""" + DateTime.Parse("7/24/2018") + @""", ""PromisedDeliveredDate"" :""" + DateTime.Parse("8/2/2018") + @""", ""TransactionDate"" :""" + DateTime.Parse("7/30/2018") + @""", ""PurchaseOrderDetailViews"":[ { ""ItemId"": 5, ""OrderDate"":""" + DateTime.Parse("7 / 30 / 2018") + @""", ""OrderedQuantity"": 5, ""UnitPrice"" : " + itemMasterLookup[0].UnitPrice + @", ""UnitOfMeasure"" : """ + itemMasterLookup[0].UnitOfMeasure + @""", ""Amount"" : " + itemMasterLookup[0].UnitPrice * 5 + @", ""Description"": """ + itemMasterLookup[0].Description + @""", ""ExpectedDeliveryDate"" :""" + DateTime.Parse("8/2/2018") + @""", ""ReceivedQuantity"":0, ""RemainingQuantity"":5 }, { ""ItemId"": 6, ""OrderDate"":""" + DateTime.Parse("7 / 30 / 2018") + @""", ""OrderedQuantity"": 4, ""UnitPrice"" : " + itemMasterLookup[1].UnitPrice + @", ""UnitOfMeasure"" : """ + itemMasterLookup[1].UnitOfMeasure + @""", ""Amount"" : " + itemMasterLookup[1].UnitPrice * 4 + @", ""Description"": """ + itemMasterLookup[1].Description + @""", ""ExpectedDeliveryDate"" :""" + DateTime.Parse("8/2/2018") + @""", ""ReceivedQuantity"":0, ""RemainingQuantity"":4 }, { ""ItemId"": 7, ""OrderDate"":""" + DateTime.Parse("7 / 30 / 2018") + @""", ""OrderedQuantity"": 10, ""UnitPrice"" : " + itemMasterLookup[2].UnitPrice + @", ""UnitOfMeasure"" : """ + itemMasterLookup[2].UnitOfMeasure + @""", ""Amount"" : " + itemMasterLookup[2].UnitPrice * 10 + @", ""Description"": """ + itemMasterLookup[2].Description + @""", ""ExpectedDeliveryDate"" :""" + DateTime.Parse("8/2/2018") + @""", ""ReceivedQuantity"":0, ""RemainingQuantity"":10 }, { ""ItemId"": 8, ""OrderDate"":""" + DateTime.Parse("7 / 30 / 2018") + @""", ""OrderedQuantity"": 15, ""UnitPrice"" : " + itemMasterLookup[3].UnitPrice + @", ""UnitOfMeasure"" : """ + itemMasterLookup[3].UnitOfMeasure + @""", ""Amount"" : " + itemMasterLookup[3].UnitPrice * 15 + @", ""Description"": """ + itemMasterLookup[3].Description + @""", ""ExpectedDeliveryDate"" :""" + DateTime.Parse("8/2/2018") + @""", ""ReceivedQuantity"":0, ""RemainingQuantity"":15 }, { ""ItemId"": 9, ""OrderDate"":""" + DateTime.Parse("7 / 30 / 2018") + @""", ""OrderedQuantity"": 10, ""UnitPrice"" : " + itemMasterLookup[4].UnitPrice + @", ""UnitOfMeasure"" : """ + itemMasterLookup[3].UnitOfMeasure + @""", ""Amount"" : " + itemMasterLookup[4].UnitPrice * 10 + @", ""Description"": """ + itemMasterLookup[4].Description + @""", ""ExpectedDeliveryDate"" :""" + DateTime.Parse("8/2/2018") + @""", ""ReceivedQuantity"":0, ""RemainingQuantity"":10 } ] }"; PurchaseOrderView purchaseOrderView = JsonConvert.DeserializeObject <PurchaseOrderView>(json); AccountsPayableModule apMod = new AccountsPayableModule(); //TODO Create the Purchase Order apMod .PurchaseOrder .CreatePurchaseOrder(purchaseOrderView) .Apply() .CreatePurchaseOrderDetails(purchaseOrderView) .Apply() .CreateAcctPayByPurchaseOrderNumber(purchaseOrderView) .Apply(); Assert.True(true); }
public async Task TestCreateIncomeRevenue() { int addressId = 1; decimal income = 2800M; long incomeDocumentNumber = 20; //manually extracted UnitOfWork unitOfWork = new UnitOfWork(); GeneralLedgerModule ledgerMod = new GeneralLedgerModule(); ChartOfAccts coa = await unitOfWork.generalLedgerRepository.GetChartofAccount("1000", "1200", "300", ""); Udc udcLedgerType = await unitOfWork.generalLedgerRepository.GetUdc("GENERALLEDGERTYPE", "AA"); Udc udcDocType = await unitOfWork.generalLedgerRepository.GetUdc("DOCTYPE", "PV"); AddressBook addressBook = await unitOfWork.addressBookRepository.GetAddressBookByAddressId(addressId); GeneralLedgerView glView = new GeneralLedgerView(); glView.DocNumber = incomeDocumentNumber; glView.DocType = udcDocType.KeyCode; glView.AccountId = coa.AccountId; glView.Amount = income; glView.LedgerType = udcLedgerType.KeyCode; glView.GLDate = DateTime.Parse("9/20/2018"); glView.CreatedDate = DateTime.Parse("9/20/2018"); glView.AddressId = addressBook.AddressId; glView.Comment = "Week end 8/31/2018"; glView.DebitAmount = income; glView.CreditAmount = 0; glView.FiscalPeriod = 9; glView.FiscalYear = 2018; ledgerMod.GeneralLedger.CreateGeneralLedger(glView).Apply(); ledgerMod.GeneralLedger.UpdateAccountBalances(glView); ChartOfAccts coa2 = await unitOfWork.generalLedgerRepository.GetChartofAccount("1000", "1200", "101", ""); long cashDocumentNumber = 21; GeneralLedgerView glView2 = new GeneralLedgerView(); glView2.DocNumber = cashDocumentNumber; glView2.DocType = udcDocType.KeyCode; glView2.AccountId = coa2.AccountId; glView2.Amount = income; glView2.LedgerType = udcLedgerType.KeyCode; glView2.GLDate = DateTime.Parse("9/20/2018"); glView2.CreatedDate = DateTime.Parse("9/20/2018"); glView2.AddressId = addressBook.AddressId; glView2.Comment = "Week end 8/31/2018"; glView2.DebitAmount = income; glView2.CreditAmount = 0; glView2.FiscalPeriod = 9; glView2.FiscalYear = 2018; ledgerMod.GeneralLedger.CreateGeneralLedger(glView2).Apply(); ledgerMod.GeneralLedger.UpdateAccountBalances(glView2); GeneralLedgerView glViewLookup = ledgerMod.GeneralLedger.Query().GetGeneralLedgerView(glView2.DocNumber, glView2.DocType); Assert.True(glViewLookup != null); }
public async Task TestCreatePersonalExpenseAndPayment() { //ToDo UnitOfWork unitOfWork = new UnitOfWork(); long addressId = 1; long expenseDocumentNumber = 19; decimal expense = 768M; ChartOfAccts coa = await unitOfWork.generalLedgerRepository.GetChartofAccount("1000", "1200", "502", "01"); Udc udcLedgerType = await unitOfWork.generalLedgerRepository.GetUdc("GENERALLEDGERTYPE", "AA"); Udc udcDocType = await unitOfWork.generalLedgerRepository.GetUdc("DOCTYPE", "PV"); AddressBook addressBook = await unitOfWork.addressBookRepository.GetAddressBookByAddressId(addressId); GeneralLedgerView glView = new GeneralLedgerView(); GeneralLedgerModule ledgerMod = new GeneralLedgerModule(); glView.DocNumber = expenseDocumentNumber; glView.DocType = udcDocType.KeyCode; glView.AccountId = coa.AccountId; glView.Amount = expense * -1; glView.LedgerType = udcLedgerType.KeyCode; glView.GLDate = DateTime.Parse("9/19/2018"); glView.CreatedDate = DateTime.Parse("9/19/2018"); glView.AddressId = addressBook.AddressId; glView.Comment = "Mortgage Payment"; glView.DebitAmount = 0; glView.CreditAmount = expense; glView.FiscalPeriod = 9; glView.FiscalYear = 2018; ledgerMod.GeneralLedger.CreateGeneralLedger(glView).Apply(); ledgerMod.GeneralLedger.UpdateAccountBalances(glView); GeneralLedgerView glViewLookup = ledgerMod.GeneralLedger.Query().GetGeneralLedgerView(glView.DocNumber, glView.DocType); ChartOfAccts coaCash = await unitOfWork.generalLedgerRepository.GetChartofAccount("1000", "1200", "101", ""); GeneralLedgerView glCashView = new GeneralLedgerView(); long cashDocumentNumber = 22; glCashView.DocNumber = cashDocumentNumber; glCashView.DocType = udcDocType.KeyCode; glCashView.AccountId = coaCash.AccountId; glCashView.Amount = expense * -1; glCashView.LedgerType = udcLedgerType.KeyCode; glCashView.GLDate = DateTime.Parse("9/20/2018"); glCashView.CreatedDate = DateTime.Parse("9/20/2018"); glCashView.AddressId = addressBook.AddressId; glCashView.Comment = "Mortgage Payment"; glCashView.DebitAmount = 0; glCashView.CreditAmount = expense; glCashView.FiscalPeriod = 9; glCashView.FiscalYear = 2018; ledgerMod.GeneralLedger.CreateGeneralLedger(glCashView).Apply(); ledgerMod.GeneralLedger.UpdateAccountBalances(glCashView); GeneralLedgerView glCashViewLookup = ledgerMod.GeneralLedger.Query().GetGeneralLedgerView(glCashView.DocNumber, glCashView.DocType); Assert.True(glCashViewLookup != null); }