public static void _SA_Open(RECEIPT ReceiptRecord) { if (!ReceiptsJournal.repo.SelfInfo.Exists()) { ReceiptsJournal._SA_Invoke(); } ReceiptsJournal.repo.Adjust.Click(); // select date range DialogJournalSearch._SA_SelectLookupDateRange(); DialogJournalSearch.repo.Name.Select(ReceiptRecord.Customer.name); DialogJournalSearch.repo.Source.TextValue = ReceiptRecord.transNumber; DialogJournalSearch.repo.OK.Click(); }
public static void _SA_MatchDefaults(RECEIPT ReceiptRecord) { if (!Functions.GoodData(ReceiptRecord.transNumber)) // receipt number { ReceiptRecord.transNumber = Variables.globalSettings.CompanySettings.FormSettings.nextNumReceipt; } if (!Functions.GoodData(ReceiptRecord.depositRefNum)) // cusotmer deposit number { ReceiptRecord.depositRefNum = Variables.globalSettings.CompanySettings.FormSettings.nextNumCustomerDeposit; } if (!Functions.GoodData(ReceiptRecord.depositAmount)) { ReceiptRecord.depositAmount = "0.00"; } //GlobalSettings.CompanySettings.CurrencySettings.ForeignCurrencies.ExchangeRates.exchangeRate ReceiptRecord.Customer.currencyCode }
public static void _SA_printTransaction(string sFileName, RECEIPT ReceiptRecord) { if (Functions.GoodData(ReceiptRecord)) { ReceiptsJournal._SA_Open(ReceiptRecord); Trace.WriteLine("Receipt" + ReceiptRecord.transNumber + ""); } ReceiptsJournal.repo.Print.Click(); SimplyMessage._SA_HandleMessage(SimplyMessage.repo.Yes, SimplyMessage.sChqNumIsOutOfSequence, false, false); PrintToFileDialog.Print(sFileName); // Undo changes ReceiptsJournal.ClickUndoChanges(); }
public static void _SA_Create(RECEIPT ReceiptRecord, bool bSave, bool bEdit) { if (!Variables.bUseDataFiles) // if external data files are not used { ReceiptsJournal._SA_MatchDefaults(ReceiptRecord); } if (!ReceiptsJournal.repo.SelfInfo.Exists()) { ReceiptsJournal._SA_Invoke(); } ReceiptsJournal.repo.EnterDeposits.Click(); // ensure enter deposits is on so objects show in screen if (!bEdit) { ReceiptsJournal.repo.CustomerName.Select(ReceiptRecord.Customer.name); ReceiptsJournal.repo.Self.PressKeys("{Tab}"); // Must press tab, otherwise selecting the Paid By field may not work Ranorex.Report.Info(String.Format("Creating receipt {0} ", ReceiptRecord.transNumber)); } else { Ranorex.Report.Info(String.Format("Adjusting Receipt {0} ", ReceiptRecord.transNumber)); ReceiptsJournal._SA_Open(ReceiptRecord); // load transaction for adjustment } // Validate if Add on the fly is present if (AddOnTheFly.repo.QuickAddInfo.Exists()) { try { Functions.Verify(true, false, "Add on fly message appears"); } catch { Trace.WriteLine("Add on the fly message not found"); } AddOnTheFly.repo.QuickAdd.Click(); } if (Functions.GoodData(ReceiptRecord.paidBy)) { // Using the select is no working properly // it seems to trigger event for all items in list.. // ie. visa is last item, using select will complain PAD is not set up for customer ReceiptsJournal.repo.PaidBy.Select(ReceiptRecord.paidBy); } if (Functions.GoodData(ReceiptRecord.DepositAccount.acctNumber)) { ReceiptsJournal.repo.DepositTo.Select(ReceiptRecord.DepositAccount.acctNumber); } if (ReceiptsJournal.repo.ChequeNumberInfo.Exists()) { if (Functions.GoodData(ReceiptRecord.chequeNumber)) { ReceiptsJournal.repo.ChequeNumber.TextValue = ReceiptRecord.chequeNumber; } } if (Functions.GoodData(ReceiptRecord.transNumber)) { ReceiptsJournal.repo.ReceiptNumber.TextValue = ReceiptRecord.transNumber; } if (Functions.GoodData(ReceiptRecord.transDate)) { ReceiptsJournal.repo.ReceiptDate.TextValue = ReceiptRecord.transDate; } if (Functions.GoodData(ReceiptRecord.padNumber)) { ReceiptsJournal.repo.PadNumber.TextValue = ReceiptRecord.padNumber; } // handle the container if (ReceiptsJournal.repo.TransContainer.Enabled) // added checking here intentionally as the container is disabled if there are no invoices available for the customer selected { int iDepLine = 100; // initialize to big number bool bDepositsInList = false; ReceiptsJournal.repo.TransContainer.ClickFirstCell(); List <List <string> > lsContents = ReceiptsJournal.repo.TransContainer.GetContents(); for (int x = 0; x < lsContents.Count; x++) // search for deposits line { if (lsContents[x][1].Trim().ToUpper() == "DEPOSITS") { bDepositsInList = true; iDepLine = x; break; } } int iCurrentLine = 0; for (int y = 0; y < ReceiptRecord.GridRows.Count; y++) { //if (FunctionsLib.GoodData (ReceiptRecord.GridRows[y].Amount)) // this line return false when only invoice object exists and rest are null //{ bool bFound = false; int x; // to be used outside the loop so declares here for (x = 0; x < lsContents.Count; x++) { string sFindString; if (Functions.GoodData(ReceiptRecord.GridRows[y].Invoice.transNumber)) { sFindString = ReceiptRecord.GridRows[y].Invoice.transNumber; } else { sFindString = ReceiptRecord.GridRows[y].DepositReceipt.depositRefNum; if (!bDepositsInList) { break; // error, we don't see any deposits } } if (lsContents[x][1] == sFindString) { if (Functions.GoodData(ReceiptRecord.GridRows[y].DepositReceipt.depositRefNum)) // if deposit, be sure we found the deposit and not an invoice above it { if (x > iDepLine) { bFound = true; break; } //else try again, you found an invoice with same number } else { bFound = true; break; } } } if (bFound) { if (iCurrentLine == 0) // see if first time in container { ReceiptsJournal.repo.TransContainer.MoveRight(); // get to the discount field if (x > 0) // below the first row { ReceiptsJournal.repo.TransContainer.PressKeys("{Down " + Convert.ToString(x) + "}"); // get to the correct row } } else // else decide if we go up or down based on current location { if (x > iCurrentLine) { ReceiptsJournal.repo.TransContainer.PressKeys("{Down " + Convert.ToString(x) + "}"); // get to the correct row } if (x < iCurrentLine) { ReceiptsJournal.repo.TransContainer.PressKeys("{Up " + Convert.ToString(iCurrentLine - x) + "}"); // get to the correct row } } iCurrentLine = x; if (Functions.GoodData(ReceiptRecord.GridRows[y].discountTaken)) { ReceiptsJournal.repo.TransContainer.SetText(ReceiptRecord.GridRows[y].discountTaken); } ReceiptsJournal.repo.TransContainer.MoveRight(); // get to the amount field if (Functions.GoodData(ReceiptRecord.GridRows[y].Amount)) { ReceiptsJournal.repo.TransContainer.SetText(ReceiptRecord.GridRows[y].Amount); } if (x < (iDepLine - 2)) { ReceiptsJournal.repo.TransContainer.MoveRight(); } iCurrentLine++; } else { Functions.Verify(false, true, "Able to find Invoice/Depositin Receipt Grid"); } //} } } if (Functions.GoodData(ReceiptRecord.depositRefNum)) { ReceiptsJournal.repo.DepositReferenceNo.TextValue = ReceiptRecord.depositRefNum; } if (Functions.GoodData(ReceiptRecord.depositAmount)) { ReceiptsJournal.repo.DepositAmount.TextValue = ReceiptRecord.depositAmount; ReceiptsJournal.repo.DepositAmount.PressKeys("{Tab}"); } if (Functions.GoodData(ReceiptRecord.comment)) { ReceiptsJournal.repo.Comment.TextValue = ReceiptRecord.comment; } if (ReceiptsJournal.repo.ExchangeRate.Enabled) { if (Functions.GoodData(ReceiptRecord.exchangeRate)) { ReceiptsJournal.repo.ExchangeRate.TextValue = ReceiptRecord.exchangeRate; } } if (bSave) { ReceiptsJournal.repo.Post.Click(); } }
public static void _SA_Create(RECEIPT ReceiptRecord, bool bSave) { _SA_Create(ReceiptRecord, bSave, false); }
public static void _SA_Create(RECEIPT ReceiptRecord) { _SA_Create(ReceiptRecord, true, false); }
public static void _SA_Delete(RECEIPT ReceiptRecord) { ReceiptsJournal._SA_Open(ReceiptRecord); // load the receipt for deletion ReceiptsJournal.repo.Reverse.Click(); SimplyMessage._SA_HandleMessage(SimplyMessage.repo.Yes, SimplyMessage.sReverseReceiptMsg); }
public static RECEIPT _SA_Read(RECEIPT ReceiptRecord) // method will read all fields and store the data in a RECEIPT record { RECEIPT Rec = new RECEIPT(); if (Functions.GoodData(ReceiptRecord)) { ReceiptsJournal._SA_Open(ReceiptRecord); } Rec.paidBy = ReceiptsJournal.repo.PaidBy.SelectedItemText; if (ReceiptsJournal.repo.DepositToInfo.Exists()) { Rec.DepositAccount.acctNumber = ReceiptsJournal.repo.DepositTo.SelectedItemText; } if (ReceiptsJournal.repo.ChequeNumberInfo.Exists()) { { Rec.chequeNumber = ReceiptsJournal.repo.ChequeNumber.TextValue; } } Rec.Customer.name = ReceiptsJournal.repo.CustomerName.SelectedItemText; Rec.transDate = ReceiptsJournal.repo.ReceiptDate.TextValue; if (ReceiptsJournal.repo.ReceiptNumberInfo.Exists()) { Rec.transNumber = ReceiptsJournal.repo.ReceiptNumber.TextValue; } if (ReceiptsJournal.repo.PadNumberInfo.Exists()) { Rec.padNumber = ReceiptsJournal.repo.PadNumber.TextValue; } Rec.GridRows.Clear(); List <List <string> > lsContents = ReceiptsJournal.repo.TransContainer.GetContents(); // a blank row is added at the end of the list if (Functions.GoodData(lsContents)) { bool bDepositLineFound = false; for (int x = 0; x < lsContents.Count; x++) { RECEIPT_ROW RR = new RECEIPT_ROW(); string sRefNum = ConvertFunctions.BlankStringToNULL(lsContents[x][1]); if (Functions.GoodData(sRefNum)) // to avoid adding a blank row { if (sRefNum == "Deposits") { bDepositLineFound = true; } else { if (bDepositLineFound) // deposit row { RR.DepositReceipt.depositRefNum = sRefNum; } else // invoice row { RR.Invoice.transNumber = sRefNum; } RR.discountTaken = ConvertFunctions.BlankStringToNULL(lsContents[x][5]); RR.Amount = ConvertFunctions.BlankStringToNULL(lsContents[x][6]); } Rec.GridRows.Add(RR); } } } Rec.depositRefNum = ReceiptsJournal.repo.DepositReferenceNo.TextValue; Rec.depositAmount = ReceiptsJournal.repo.DepositAmount.TextValue; if (ReceiptsJournal.repo.ExchangeRateInfo.Exists()) { Rec.exchangeRate = ReceiptsJournal.repo.ExchangeRate.TextValue; } Rec.comment = ReceiptsJournal.repo.Comment.TextValue; return(Rec); }
/// <summary> /// Performs the playback of actions in this module. /// </summary> /// <remarks>You should not call this method directly, instead pass the module /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method /// that will in turn invoke this method.</remarks> void ITestModule.Run() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; // Create a customer CUSTOMER cus = new CUSTOMER(); cus.name = "cust" + StringFunctions.RandStr("X(8)"); //cus.name = "International Oil"; ReceivablesLedger._SA_Create(cus); ReceivablesLedger._SA_Close(); // Create an item ITEM item = new ITEM(); item.invOrServNumber = StringFunctions.RandStr("A(9)"); //item.invOrServNumber = "C1020"; item.ItemPrices.Add(new ITEM_PRICE("Canadian Dollars")); item.ItemPrices[0].priceList = "Regular"; item.ItemPrices[0].pricePerSellingUnit = Functions.RandCashAmount(); InventoryServicesLedger._SA_Create(item); InventoryServicesLedger._SA_Close(); // Create an Invoice SALES_INVOICE sale = new SALES_INVOICE(); sale.Customer = cus; sale.transNumber = StringFunctions.RandStr("9(8)"); ROW r = new ROW(); r.Item = item; r.quantityShipped = Functions.RandCashAmount(2); r.price = Functions.RandCashAmount(); sale.GridRows.Add(r); SalesJournal._SA_Create(sale); System.Threading.Thread.Sleep(2000); SalesJournal._SA_Close(); // // tmp // CUSTOMER cus = new CUSTOMER(); // cus.name = "custYXTngnQw"; // ITEM item = new ITEM(); // item.invOrServNumber = "aqlUMddep"; // SALES_INVOICE sale = new SALES_INVOICE(); // sale.Customer = cus; // sale.transNumber = "15883414"; // // Create an receipt RECEIPT receipt = new RECEIPT(); receipt.Customer = cus; RECEIPT_ROW row1 = new RECEIPT_ROW(); row1.Invoice = sale; receipt.GridRows.Add(row1); ReceiptsJournal._SA_Create(receipt); System.Threading.Thread.Sleep(1000); ReceiptsJournal._SA_Close(); }
public async Task <ActionResult <BaseResponse> > Post([FromForm] CustomerReceiptInfo data) { RECEIPT receipt = new RECEIPT(); var customer = await _context.CUSTOMERS.Where(cus => cus.phone == data.phone).FirstOrDefaultAsync(); if (customer != null && customer.isRemove == false) { // Không được phép thu tiền vượt quá số tiền khách đang nợ if (!Roles.GetOverDept) { if (data.customerPaid > customer.oldDept) { return(new BaseResponse { ErrorCode = Roles.Get_Over_Dept, Message = "Getting money is not over the money customer has been depted!" }); } else { double res = data.customerPaid - data.total; receipt.customerId = customer.id; receipt.dateCreated = data.dateCreated; receipt.total = data.total; receipt.customerPaid = data.customerPaid; customer.nowDept = res > 0 ? Math.Abs(res - customer.oldDept) : customer.oldDept + Math.Abs(res); _context.CUSTOMERS.Update(customer); _context.RECEIPTS.Add(receipt); await _context.SaveChangesAsync(); return(new BaseResponse { ErrorCode = Roles.Success, Message = "A receipt has just created!" }); } } else { double res = data.customerPaid - data.total; receipt.customerId = customer.id; receipt.dateCreated = data.dateCreated; receipt.total = data.total; receipt.customerPaid = data.customerPaid; customer.nowDept = res > 0 ? Math.Abs(res - customer.oldDept) : customer.oldDept + Math.Abs(res); _context.CUSTOMERS.Update(customer); _context.RECEIPTS.Add(receipt); await _context.SaveChangesAsync(); return(new BaseResponse { ErrorCode = Roles.Success, Message = "A receipt has just created!" }); } } // Khách hàng này chưa có trong csdl else { customer = new CUSTOMER(); customer.firstName = data.firstName; customer.lastName = data.lastName; customer.phone = data.phone; customer.email = data.email; customer.address = data.address; customer.username = null; customer.password = null; customer.imageName = null; customer.url = null; customer.oldDept = 0; customer.nowDept = 0; customer.isRemove = false; _context.CUSTOMERS.Add(customer); receipt.dateCreated = data.dateCreated; receipt.total = data.total; receipt.isRemove = false; _context.RECEIPTS.Add(receipt); await _context.SaveChangesAsync(); return(new BaseResponse { ErrorCode = Roles.Success, Message = "A receipt has just created!" }); } }
/// <summary> /// Performs the playback of actions in this module. /// </summary> /// <remarks>You should not call this method directly, instead pass the module /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method /// that will in turn invoke this method.</remarks> void ITestModule.Run() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; // Create a customer CUSTOMER cus = new CUSTOMER(); if (this.varCustomer == "") { cus.name = "cust" + StringFunctions.RandStr("X(8)"); ReceivablesLedger._SA_Create(cus); ReceivablesLedger._SA_Close(); } else { cus.name = this.varCustomer; } // Create an item to be used in invoice ITEM item = new ITEM(); item.ItemPrices.Add(new ITEM_PRICE("Canadian Dollars")); item.ItemPrices[0].priceList = "Regular"; item.ItemPrices[0].pricePerSellingUnit = Functions.RandCashAmount(); if (this.varItem == "") { item.invOrServNumber = StringFunctions.RandStr("A(9)"); InventoryServicesLedger._SA_Create(item); InventoryServicesLedger._SA_Close(); } else { item.invOrServNumber = this.varItem; } // Create an Invoice SALES_INVOICE sale = new SALES_INVOICE(); sale.Customer = cus; ROW r = new ROW(); r.Item = item; r.quantityShipped = Functions.RandCashAmount(2); r.price = Functions.RandCashAmount(); sale.GridRows.Add(r); if (this.varSInvoice == "") { SalesJournal._SA_Create(sale); System.Threading.Thread.Sleep(1000); SalesJournal._SA_Close(); } else { sale.transNumber = this.varSInvoice; } // Create a receipt RECEIPT receipt = new RECEIPT(); receipt.Customer = cus; RECEIPT_ROW receiptRow = new RECEIPT_ROW(); receiptRow.Invoice = sale; receipt.GridRows.Add(receiptRow); ReceiptsJournal._SA_Create(receipt); System.Threading.Thread.Sleep(1000); ReceiptsJournal._SA_Close(); }