public async Task <IFluentAccountReceivable> UpdateAccountReceivableByInvoiceView(InvoiceView invoiceView) { try { Invoice invoice = await unitOfWork.invoiceRepository.GetEntityByInvoiceDocument(invoiceView.InvoiceDocument); Decimal?totalInvoiceAmount = await unitOfWork.invoiceRepository.GetInvoicedAmountByPurchaseOrderId(invoiceView.PurchaseOrderId); if (invoice != null) { long?invoiceId = invoice.InvoiceId; AccountReceivable acctRecLookup = await unitOfWork.accountReceivableRepository.GetEntityByPurchaseOrderId(invoice.PurchaseOrderId); if (acctRecLookup != null) { //decimal ? totalInvoiceAmount = listInvoiceTasks.Result.Sum<Invoice>(e => e.Amount); acctRecLookup.OpenAmount = acctRecLookup.Amount - totalInvoiceAmount; acctRecLookup.DebitAmount = 0; acctRecLookup.CreditAmount = totalInvoiceAmount; UpdateAccountReceivable(acctRecLookup); return(this as IFluentAccountReceivable); } } processStatus = CreateProcessStatus.AlreadyExists; return(this as IFluentAccountReceivable); } catch (Exception ex) { throw new Exception(GetMyMethodName(), ex); } }
public static void BatchAccountReceivable(DataTable dt, Oper oper) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); foreach (DataRow dr in dt.Rows) { AccountReceivable ar = new AccountReceivable(dr); //newOper.cndCreateDate = dtSysTime; string strCount = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select count(*) from tbAccountReceivable where cnnCustID = " + ar.cnnCustID).ToString(); if (Convert.ToInt32(strCount) > 0) { throw new Exception(ar.cnvcCustName + "已存在"); } EntityMapping.Create(ar, trans); BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = dtSysTime; busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans); busiLog.cnvcComments = ar.cnvcCustName; busiLog.cnvcFuncCode = " 批量添加应收"; busiLog.cnvcOperID = oper.cnvcOperID; busiLog.cnvcIPAddress = ""; EntityMapping.Create(busiLog, trans); } trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
public async Task TestAddUpdatDelete() { AddressBook addressBook = null; AccountReceivableInterestModule AccountReceivableInterestMod = new AccountReceivableInterestModule(); Customer customer = await AccountReceivableInterestMod.Customer.Query().GetEntityById(3); AccountReceivable accountReceivable = await AccountReceivableInterestMod.AccountReceivable.Query().GetEntityById(12); if (customer != null) { addressBook = await AccountReceivableInterestMod.AddressBook.Query().GetEntityById(customer.AddressId); } AccountReceivableInterestView view = new AccountReceivableInterestView() { Amount = 1M, InterestRate = .035M, InterestFromDate = DateTime.Parse("11/1/2019"), InterestToDate = DateTime.Parse("12/7/2019"), DocNumber = 12, PaymentTerms = "Monthly", PaymentDueDate = DateTime.Parse("12/31/2019"), CustomerId = customer.CustomerId, CustomerName = addressBook?.Name, AccountReceivableId = accountReceivable.AccountReceivableId, AcctRecDocType = accountReceivable.AcctRecDocType }; NextNumber nnNextNumber = await AccountReceivableInterestMod.AccountReceivableInterest.Query().GetNextNumber(); view.AccountReceivableInterestNumber = nnNextNumber.NextNumberValue; AccountReceivableInterest accountReceivableInterest = await AccountReceivableInterestMod.AccountReceivableInterest.Query().MapToEntity(view); AccountReceivableInterestMod.AccountReceivableInterest.AddAccountReceivableInterest(accountReceivableInterest).Apply(); AccountReceivableInterest newAccountReceivableInterest = await AccountReceivableInterestMod.AccountReceivableInterest.Query().GetEntityByNumber(view.AccountReceivableInterestNumber); Assert.NotNull(newAccountReceivableInterest); newAccountReceivableInterest.PaymentTerms = "Weekly"; AccountReceivableInterestMod.AccountReceivableInterest.UpdateAccountReceivableInterest(newAccountReceivableInterest).Apply(); AccountReceivableInterestView updateView = await AccountReceivableInterestMod.AccountReceivableInterest.Query().GetViewById(newAccountReceivableInterest.AcctRecInterestId); Assert.Same(updateView.PaymentTerms, "Weekly"); AccountReceivableInterestMod.AccountReceivableInterest.DeleteAccountReceivableInterest(newAccountReceivableInterest).Apply(); AccountReceivableInterest lookupAccountReceivableInterest = await AccountReceivableInterestMod.AccountReceivableInterest.Query().GetEntityById(view.AcctRecInterestId); Assert.Null(lookupAccountReceivableInterest); }
public async Task <bool> PostInvoiceAndDetailToAcctRec(InvoiceView invoiceView) { try { Invoice invoiceNew = await Invoice.Query().MapToEntity(invoiceView); Invoice .AddInvoice(invoiceNew) .Apply(); Invoice invoiceLookup = await Invoice.Query().GetEntityByInvoiceDocument(invoiceView.InvoiceDocument); invoiceView.InvoiceId = invoiceLookup.InvoiceId; //Assign the InvoiceId for (int i = 0; i < invoiceView.InvoiceDetailViews.Count; i++) { invoiceView.InvoiceDetailViews[i].InvoiceId = invoiceLookup.InvoiceId; InvoiceDetail invoiceDetail = await InvoiceDetail.Query().MapToEntity(invoiceView.InvoiceDetailViews[i]); InvoiceDetail.AddInvoiceDetail(invoiceDetail); } InvoiceDetail.Apply(); await AccountReceivable .UpdateAccountReceivableByInvoiceView(invoiceView); AccountReceivable.Apply(); await GeneralLedger .CreateGeneralLedgerByInvoiceView(invoiceView); GeneralLedger.Apply(); AccountReceivable acctRecLookup = await AccountReceivable.Query().GetEntityByPurchaseOrderId(invoiceView.PurchaseOrderId); GeneralLedger.UpdateLedgerBalances(acctRecLookup.DocNumber ?? 0, "OV"); await CustomerLedger .CreateCustomerLedgerByInvoiceView(invoiceView); CustomerLedger.Apply(); return(true); } catch (Exception ex) { throw new Exception("PostInvoiceAndDetailToAcctRec", ex); } }
public async Task <IFluentGeneralLedger> CreateGeneralLedgerByInvoiceView(InvoiceView invoiceView) { try { AccountReceivable acctRec = await unitOfWork.accountReceivableRepository.GetEntityByPurchaseOrderId(invoiceView.PurchaseOrderId); if (acctRec != null) { GeneralLedger generalLedgerLookup = await unitOfWork.generalLedgerRepository.FindEntityByDocNumber(acctRec.DocNumber); if (generalLedgerLookup == null) { long addressId = await unitOfWork.addressBookRepository.GetAddressIdByCustomerId(acctRec.CustomerId); //Revenue Account ChartOfAccount chartOfAcct = await unitOfWork.chartOfAccountRepository.GetChartofAccount("1000", "1200", "250", ""); GeneralLedger ledger = new GeneralLedger(); ledger.DocNumber = acctRec.DocNumber ?? 0; ledger.DocType = "OV"; ledger.Amount = acctRec.Amount ?? 0; ledger.LedgerType = "AA"; ledger.Gldate = DateTime.Now.Date; ledger.FiscalPeriod = DateTime.Now.Date.Month; ledger.FiscalYear = DateTime.Now.Date.Year; ledger.AccountId = chartOfAcct.AccountId; ledger.CreatedDate = DateTime.Now.Date; ledger.AddressId = addressId; ledger.Comment = acctRec.Remark; ledger.DebitAmount = 0.0M; ledger.CreditAmount = acctRec.Amount ?? 0; ledger.GeneralLedgerNumber = (await unitOfWork.nextNumberRepository.GetNextNumber(TypeOfGeneralLedger.GeneralLedgerNumber.ToString())).NextNumberValue; AddGeneralLedger(ledger); return(this as IFluentGeneralLedger); } processStatus = CreateProcessStatus.AlreadyExists; return(this as IFluentGeneralLedger); } processStatus = CreateProcessStatus.Failed; return(this as IFluentGeneralLedger); } catch (Exception ex) { throw new Exception(GetMyMethodName(), ex); } }
public async Task TestAddUpdatDelete() { AddressBook addressBook = null; AccountReceivableFeeModule AccountReceivableFeeMod = new AccountReceivableFeeModule(); Customer customer = await AccountReceivableFeeMod.Customer.Query().GetEntityById(3); if (customer != null) { addressBook = await AccountReceivableFeeMod.AddressBook.Query().GetEntityById(customer.AddressId); } AccountReceivable accountReceivable = await AccountReceivableFeeMod.AccountReceivable.Query().GetEntityById(12); AccountReceivableFeeView view = new AccountReceivableFeeView() { FeeAmount = 25M, PaymentDueDate = DateTime.Parse("12/7/2019"), CustomerId = customer.CustomerId, CustomerName = addressBook?.Name, DocNumber = 12, AcctRecDocType = "INV", AccountReceivableId = accountReceivable.AccountReceivableId }; NextNumber nnNextNumber = await AccountReceivableFeeMod.AccountReceivableFee.Query().GetNextNumber(); view.AccountReceivableFeeNumber = nnNextNumber.NextNumberValue; AccountReceivableFee accountReceivableFee = await AccountReceivableFeeMod.AccountReceivableFee.Query().MapToEntity(view); AccountReceivableFeeMod.AccountReceivableFee.AddAccountReceivableFee(accountReceivableFee).Apply(); AccountReceivableFee newAccountReceivableFee = await AccountReceivableFeeMod.AccountReceivableFee.Query().GetEntityByNumber(view.AccountReceivableFeeNumber); Assert.NotNull(newAccountReceivableFee); newAccountReceivableFee.AcctRecDocType = "INV2"; AccountReceivableFeeMod.AccountReceivableFee.UpdateAccountReceivableFee(newAccountReceivableFee).Apply(); AccountReceivableFeeView updateView = await AccountReceivableFeeMod.AccountReceivableFee.Query().GetViewById(newAccountReceivableFee.AccountReceivableFeeId); Assert.Same(updateView.AcctRecDocType, "INV2"); AccountReceivableFeeMod.AccountReceivableFee.DeleteAccountReceivableFee(newAccountReceivableFee).Apply(); AccountReceivableFee lookupAccountReceivableFee = await AccountReceivableFeeMod.AccountReceivableFee.Query().GetEntityById(view.AccountReceivableFeeId); Assert.Null(lookupAccountReceivableFee); }
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 static void UpdateAccountReceivable(AccountReceivable ar, Oper oper) { using (SqlConnection conn = ConnectionPool.BorrowConnection()) { //conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { string strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString(); DateTime dtSysTime = DateTime.Parse(strSysTime); //newOper.cndCreateDate = dtSysTime; EntityMapping.Update(ar, trans); BusiLog busiLog = new BusiLog(); busiLog.cndOperDate = dtSysTime; busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans); busiLog.cnvcComments = ar.cnvcCustName; busiLog.cnvcFuncCode = " 修改应收"; busiLog.cnvcOperID = oper.cnvcOperID; busiLog.cnvcIPAddress = ""; EntityMapping.Create(busiLog, trans); trans.Commit(); } catch (SqlException sex) { trans.Rollback(); LogAdapter.WriteDatabaseException(sex); throw sex; } catch (Exception ex) { trans.Rollback(); LogAdapter.WriteFeaturesException(ex); throw ex; } finally { ConnectionPool.ReturnConnection(conn); } } }
private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 this.RegisterStartupScript("hide", "<script lanaguage=javascript>ShowHide('1','none');</script>"); if (!this.IsPostBack) { if (Request["cnnCustID"] == null) { Popup("无效链接"); return; } BindDDL(); string strCustID = Request["cnnCustID"].ToString(); DataTable dt = Helper.Query("select * from tbAccountReceivable where cnnCustID = " + strCustID); AccountReceivable ar = new AccountReceivable(dt); txtCustID.Text = ar.cnnCustID.ToString(); txtCustName.Text = ar.cnvcCustName; ListItem li1 = ddlTradeType1.Items.FindByValue(ar.cnvcTradeType1); if (li1 != null) { li1.Selected = true; } ListItem li2 = ddlTradeType2.Items.FindByValue(ar.cnvcTradeType2); if (li2 != null) { li2.Selected = true; } ListItem liCustLevel = ddlCustLevel.Items.FindByValue(ar.cnvcCustLevel); if (liCustLevel != null) { liCustLevel.Selected = true; } txtContractNo.Text = ar.cnvcContractNo; txtProjectName.Text = ar.cnvcProjectName; txtAcctID.Text = ar.cnnAcctID.ToString(); txtAcctName.Text = ar.cnvcAcctName; txtSvcTypeName.Text = ar.cnvcSvcTypeName; txtFee.Text = ar.cnnFee.ToString(); } }
private void btnOK_Click(object sender, System.EventArgs e) { try { if (this.JudgeIsNull(txtCustID.Text, "客户")) { return; } if (this.JudgeIsNull(txtCustName.Text, "客户名称")) { return; } if (!this.JudgeIsNum(txtFee.Text, "收入")) { return; } DataTable dt = Helper.Query("select * from tbAccountReceivable where cnnCustID = " + txtCustID.Text); AccountReceivable ar = new AccountReceivable(dt); ar.cnnAcctID = Convert.ToDecimal(txtAcctID.Text); //ar.cnnCustID = Convert.ToDecimal(txtCustID.Text); ar.cnnFee = Convert.ToDecimal(txtFee.Text); ar.cnvcAcctName = txtAcctName.Text; ar.cnvcContractNo = txtContractNo.Text; ar.cnvcCustLevel = ddlCustLevel.SelectedValue; ar.cnvcCustName = txtCustName.Text; ar.cnvcProjectName = txtProjectName.Text; ar.cnvcSvcTypeName = txtSvcTypeName.Text; ar.cnvcTradeType1 = ddlTradeType1.SelectedValue; ar.cnvcTradeType2 = ddlTradeType2.SelectedValue; SalesManageFacade.UpdateAccountReceivable(ar, oper); Popup("成功修改应收"); } catch (Exception ex) { Popup(ex.Message); } }
private void btnCancel_Click(object sender, System.EventArgs e) { try { BindDDL(); DataTable dt = Helper.Query("select * from tbAccountReceivable where cnnCustID = " + txtCustID.Text); AccountReceivable ar = new AccountReceivable(dt); txtCustID.Text = ar.cnnCustID.ToString(); txtCustName.Text = ar.cnvcCustName; ListItem li1 = ddlTradeType1.Items.FindByValue(ar.cnvcTradeType1); if (li1 != null) { li1.Selected = true; } ListItem li2 = ddlTradeType2.Items.FindByValue(ar.cnvcTradeType2); if (li2 != null) { li2.Selected = true; } ListItem liCustLevel = ddlCustLevel.Items.FindByValue(ar.cnvcCustLevel); if (liCustLevel != null) { liCustLevel.Selected = true; } txtContractNo.Text = ar.cnvcContractNo; txtProjectName.Text = ar.cnvcProjectName; txtAcctID.Text = ar.cnnAcctID.ToString(); txtAcctName.Text = ar.cnvcAcctName; txtSvcTypeName.Text = ar.cnvcSvcTypeName; txtFee.Text = ar.cnnFee.ToString(); } catch (Exception ex) { Popup(ex.Message); } }
public BaseApiResponse InsertOrUpdateAccountReceivable(AccountReceivable model) { var response = new BaseApiResponse(); try { SqlParameter[] param = { new SqlParameter("ArID", (object)model.ArID ?? (object)DBNull.Value) , new SqlParameter("CheckType", (object)model.CheckType ?? (object)DBNull.Value) , new SqlParameter("FirmName", (object)model.FirmName ?? (object)DBNull.Value) , new SqlParameter("CheckNumber", (object)model.CheckNumber ?? (object)DBNull.Value) , new SqlParameter("CheckAmount", (object)model.CheckAmount ?? (object)DBNull.Value) , new SqlParameter("Note", (object)model.Note ?? (object)DBNull.Value) , new SqlParameter("CreatedBy", (object)model.UserAccessId ?? (object)DBNull.Value) }; var result = _repository.ExecuteSQL <int>("InsertOrUpdateAccountReceivable", param).FirstOrDefault(); if (result > 0) { response.Success = true; response.ArID = result; } else { response.Success = false; response.Message.Add("Check Amount Should be less than or equal to total Invoice."); } } catch (Exception ex) { response.Message.Add(ex.Message); } return(response); }
public async Task TestPostInvoiceAndDetailToAcctRec() { try { //NextNumber nextNumber = await unitOfWork.invoiceRepository.Get("InvoiceNumber"); InvoiceModule invoiceModule = new InvoiceModule(); AccountReceivableModule acctRecMod = new AccountReceivableModule(); Customer customer = await acctRecMod.Customer.Query().GetEntityById(9); AddressBook addressBookCustomer = await acctRecMod.AddressBook.Query().GetEntityById(customer?.AddressId); ChartOfAccount chartOfAccount = await acctRecMod.ChartOfAccount.Query().GetEntity("1000", "1200", "101", ""); PurchaseOrder purchaseOrder = await acctRecMod.PurchaseOrder.Query().GetEntityById(20); Udc udcReceivable = await acctRecMod.Udc.Query().GetEntityById(66); TaxRatesByCode taxRatesByCode = await invoiceModule.TaxRatesByCode.Query().GetEntityById(1); AccountReceivableView newAccountReceivableView = new AccountReceivableView { Amount = 1500M, OpenAmount = 1500M, DiscountDueDate = DateTime.Parse("1/21/2020"), Gldate = DateTime.Parse("1/21/2020"), CreateDate = DateTime.Parse("1/21/2020"), DocNumber = (await acctRecMod.AccountReceivable.Query().GetDocNumber()).NextNumberValue, Remark = " partial payment", PaymentTerms = "Net 30", CustomerId = customer.CustomerId, CustomerName = addressBookCustomer?.Name, PurchaseOrderId = purchaseOrder.PurchaseOrderId, Description = "Fixed Asset Project", AcctRecDocTypeXrefId = udcReceivable.XrefId, DocType = udcReceivable.KeyCode, AccountId = chartOfAccount.AccountId, AccountReceivableNumber = (await acctRecMod.AccountReceivable.Query().GetNextNumber()).NextNumberValue }; AccountReceivable accountReceivable = await acctRecMod.AccountReceivable.Query().MapToEntity(newAccountReceivableView); acctRecMod.AccountReceivable.AddAccountReceivable(accountReceivable).Apply(); InvoiceView invoiceView = new InvoiceView(); invoiceView.InvoiceDocument = accountReceivable.DocNumber.ToString(); invoiceView.InvoiceDate = DateTime.Parse("8/10/2018"); invoiceView.PurchaseOrderId = purchaseOrder.PurchaseOrderId; invoiceView.Amount = 1500.0M; invoiceView.CustomerId = customer.CustomerId; invoiceView.Description = "VNW Fixed Asset project"; invoiceView.PaymentTerms = "Net 30"; invoiceView.TaxAmount = 0; invoiceView.CompanyId = 1; invoiceView.TaxRatesByCodeId = taxRatesByCode.TaxRatesByCodeId; invoiceView.TaxCode = taxRatesByCode.TaxCode; invoiceView.InvoiceNumber = (await invoiceModule.Invoice.Query().GetNextNumber()).NextNumberValue; IList <PurchaseOrderDetail> listPurchaseOrderDetail = await acctRecMod.PurchaseOrderDetail.Query().GetEntitiesByPurchaseOrderId(purchaseOrder.PurchaseOrderId); IList <InvoiceDetailView> listInvoiceDetailView = new List <InvoiceDetailView>(); //invoiceDetailView.InvoiceId = invoice.InvoiceId; foreach (var item in listPurchaseOrderDetail) { listInvoiceDetailView.Add( new InvoiceDetailView() { UnitOfMeasure = item.UnitOfMeasure, Quantity = (int)item.OrderedQuantity, PurchaseOrderId = item.PurchaseOrderId, PurchaseOrderDetailId = item.PurchaseOrderDetailId, UnitPrice = item.UnitPrice, Amount = item.Amount, DiscountPercent = 0, DiscountAmount = 0, ItemId = item.ItemId, InvoiceDetailNumber = (await invoiceModule.InvoiceDetail.Query().GetNextNumber()).NextNumberValue }); } invoiceView.InvoiceDetailViews = listInvoiceDetailView; bool result = await invoiceModule.PostInvoiceAndDetailToAcctRec(invoiceView); Assert.True(result); } catch (Exception ex) { throw new Exception("TestPostInvoiceAndDetailToAcctRec", ex); } }
async Task TestCreateAccountReceivableFromPO() { AddressBook addressBook = null; AddressBook buyerAddressBook = null; PurchaseOrderModule PurchaseOrderMod = new PurchaseOrderModule(); ChartOfAccount account = await PurchaseOrderMod.ChartOfAccount.Query().GetEntityById(17); Supplier supplier = await PurchaseOrderMod.Supplier.Query().GetEntityById(3); if (supplier != null) { addressBook = await PurchaseOrderMod.AddressBook.Query().GetEntityById(supplier.AddressId); } Contract contract = await PurchaseOrderMod.Contract.Query().GetEntityById(1); Poquote poquote = await PurchaseOrderMod.POQuote.Query().GetEntityById(2); Buyer buyer = await PurchaseOrderMod.Buyer.Query().GetEntityById(1); if (buyer != null) { buyerAddressBook = await PurchaseOrderMod.AddressBook.Query().GetEntityById(buyer.AddressId); } TaxRatesByCode taxRatesByCode = await PurchaseOrderMod.TaxRatesByCode.Query().GetEntityById(1); PurchaseOrderView view = new PurchaseOrderView() { DocType = "STD", PaymentTerms = "Net 30", Amount = 286.11M, AmountPaid = 0, Remark = "PO Remark", Gldate = DateTime.Parse("11/29/2019"), AccountId = account.AccountId, Location = account.Location, BusUnit = account.BusUnit, Subsidiary = account.Subsidiary, SubSub = account.SubSub, Account = account.Account, AccountDescription = account.Description, SupplierId = supplier.SupplierId, CustomerId = contract?.CustomerId, SupplierName = addressBook.Name, ContractId = contract?.ContractId, PoquoteId = poquote?.PoquoteId, QuoteAmount = poquote?.QuoteAmount, Description = "PO Description", Ponumber = "PO-123", TakenBy = "David Nishimoto", ShippedToName = " shipped name", ShippedToAddress1 = "shipped to address1", ShippedToAddress2 = "shipped to address2", ShippedToCity = "shipped city", ShippedToState = "ID", ShippedToZipcode = "83709", BuyerId = buyer.BuyerId, BuyerName = buyerAddressBook?.Name, RequestedDate = DateTime.Parse("11/29/2019"), PromisedDeliveredDate = DateTime.Parse("11/29/2019"), Tax = 0M, TransactionDate = DateTime.Parse("11/29/2019"), TaxCode1 = taxRatesByCode.TaxCode, TaxCode2 = "", TaxRate = taxRatesByCode.TaxRate ?? 0, PurchaseOrderNumber = (await PurchaseOrderMod.PurchaseOrder.Query().GetNextNumber()).NextNumberValue }; PurchaseOrder purchaseOrder = await PurchaseOrderMod.PurchaseOrder.Query().MapToEntity(view); PurchaseOrderMod.PurchaseOrder.AddPurchaseOrder(purchaseOrder).Apply(); Udc udcAccountReceivableType = await PurchaseOrderMod.Udc.Query().GetEntityById(66); ChartOfAccount coaAccountReceivable = await PurchaseOrderMod.ChartOfAccount.Query().GetEntityById(4); AccountReceivable accountReceivable = await PurchaseOrderMod.AccountReceivable.Query().MapEntityFromPurchaseOrder(purchaseOrder, udcAccountReceivableType, coaAccountReceivable); PurchaseOrderMod.AccountReceivable.AddAccountReceivable(accountReceivable).Apply(); }
public async Task TestAddUpdatDelete() { AccountReceivableDetailModule AccountReceivableDetailMod = new AccountReceivableDetailModule(); Invoice invoice = await AccountReceivableDetailMod.Invoice.Query().GetEntityById(18); Customer customer = await AccountReceivableDetailMod.Customer.Query().GetEntityById(9); AddressBook addressBookCustomer = await AccountReceivableDetailMod.AddressBook.Query().GetEntityById(customer?.AddressId); PurchaseOrder purchaseOrder = await AccountReceivableDetailMod.PurchaseOrder.Query().GetEntityById(20); Udc udc = await AccountReceivableDetailMod.Udc.Query().GetEntityById(66); ChartOfAccount chartOfAccount = await AccountReceivableDetailMod.ChartOfAccount.Query().GetEntityById(3); AccountReceivableView acctRecView = new AccountReceivableView() { DiscountDueDate = DateTime.Parse("2/8/2020"), Gldate = DateTime.Parse("7/16/2018"), InvoiceId = invoice.InvoiceId, CreateDate = DateTime.Parse("7/16/2018"), DocNumber = (await AccountReceivableDetailMod.AccountReceivable.Query().GetDocNumber()).NextNumberValue, Remark = "VNW Fixed Asset project", PaymentTerms = "Net 30", CustomerId = customer?.CustomerId ?? 0, PurchaseOrderId = purchaseOrder?.PurchaseOrderId ?? 0, Description = "Fixed Asset Project", AcctRecDocTypeXrefId = udc.XrefId, AccountId = chartOfAccount.AccountId, Amount = 1500M, DebitAmount = 189.6300M, CreditAmount = 1500, OpenAmount = 1335.37M, DiscountPercent = 0, DiscountAmount = 0, AcctRecDocType = "INV", InterestPaid = 0, LateFee = 25.0000M, AccountReceivableNumber = (await AccountReceivableDetailMod.AccountReceivable.Query().GetNextNumber()).NextNumberValue, CustomerPurchaseOrder = "PO-321", Tax = 0, InvoiceDocument = invoice.InvoiceDocument, CustomerName = addressBookCustomer?.Name, DocType = udc.KeyCode }; AccountReceivable newAccountReceivable = await AccountReceivableDetailMod.AccountReceivable.Query().MapToEntity(acctRecView); AccountReceivableDetailMod.AccountReceivable.AddAccountReceivable(newAccountReceivable).Apply(); AccountReceivable lookupAccountReceivable = await AccountReceivableDetailMod.AccountReceivable.Query().GetEntityByNumber(newAccountReceivable.AccountReceivableNumber); InvoiceDetail invoiceDetail = await AccountReceivableDetailMod.InvoiceDetail.Query().GetEntityById(6); PurchaseOrderDetail purchaseOrderDetail = await AccountReceivableDetailMod.PurchaseOrderDetail.Query().GetEntityById(33); ItemMaster itemMaster = await AccountReceivableDetailMod.ItemMaster.Query().GetEntityById(4); AccountReceivableDetailView acctRecDetailView = new AccountReceivableDetailView() { InvoiceId = invoice.InvoiceId, InvoiceDetailId = invoiceDetail.InvoiceDetailId, AccountReceivableId = lookupAccountReceivable.AccountReceivableId, UnitPrice = invoiceDetail.UnitPrice, Quantity = invoiceDetail.Quantity, UnitOfMeasure = invoiceDetail.UnitOfMeasure, Amount = invoiceDetail.Amount, AmountReceived = 189.6300M, PurchaseOrderDetailId = purchaseOrderDetail.PurchaseOrderDetailId, ItemId = itemMaster.ItemId, AccountReceivableDetailNumber = (await AccountReceivableDetailMod.AccountReceivableDetail.Query().GetNextNumber()).NextNumberValue, PurchaseOrderId = purchaseOrder.PurchaseOrderId, CustomerId = customer.CustomerId, QuantityDelivered = invoiceDetail.Quantity, Comment = "possible write off", TypeOfPayment = "Partial" }; AccountReceivableDetail accountReceivableDetail = await AccountReceivableDetailMod.AccountReceivableDetail.Query().MapToEntity(acctRecDetailView); AccountReceivableDetailMod.AccountReceivableDetail.AddAccountReceivableDetail(accountReceivableDetail).Apply(); AccountReceivableDetail newAccountReceivableDetail = await AccountReceivableDetailMod.AccountReceivableDetail.Query().GetEntityByNumber(acctRecDetailView.AccountReceivableDetailNumber); Assert.NotNull(newAccountReceivableDetail); newAccountReceivableDetail.Comment = "AccountReceivableDetail Test Update"; AccountReceivableDetailMod.AccountReceivableDetail.UpdateAccountReceivableDetail(newAccountReceivableDetail).Apply(); AccountReceivableDetailView updateView = await AccountReceivableDetailMod.AccountReceivableDetail.Query().GetViewById(newAccountReceivableDetail.AccountReceivableDetailId); Assert.Same(updateView.Comment, "AccountReceivableDetail Test Update"); AccountReceivableDetailMod.AccountReceivableDetail.DeleteAccountReceivableDetail(newAccountReceivableDetail).Apply(); AccountReceivableDetail lookupAccountReceivableDetail = await AccountReceivableDetailMod.AccountReceivableDetail.Query().GetEntityById(acctRecDetailView.AccountReceivableDetailId); Assert.Null(lookupAccountReceivableDetail); AccountReceivableDetailMod.AccountReceivable.DeleteAccountReceivable(lookupAccountReceivable).Apply(); AccountReceivable lookupAccountReceivable2 = await AccountReceivableDetailMod.AccountReceivable.Query().GetEntityByNumber(newAccountReceivable.AccountReceivableNumber); Assert.Null(lookupAccountReceivable2); }
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); }
public IFluentAccountReceivable AddAccountReceivable(AccountReceivable newObject) { unitOfWork.accountReceivableRepository.AddObject(newObject); this.processStatus = CreateProcessStatus.Insert; return(this as IFluentAccountReceivable); }
public IFluentAccountReceivable DeleteAccountReceivable(AccountReceivable deleteObject) { unitOfWork.accountReceivableRepository.DeleteObject(deleteObject); this.processStatus = CreateProcessStatus.Delete; return(this as IFluentAccountReceivable); }