public static void _SA_CreatePayment_Other(PAYMENT_OTHER PaymentRecord, bool bSave, bool bEdit, bool bRecur) { bool bCheckGlobalProject = false; if (!PaymentsJournal.repo.SelfInfo.Exists()) { PaymentsJournal._SA_Invoke(); } string source; // to be used in print statements if (Functions.GoodData(PaymentRecord.chequeNumber)) // paid by cheque { source = PaymentRecord.chequeNumber; } else { source = PaymentRecord.source; } if (!bEdit) { if (!bRecur) { Ranorex.Report.Info(String.Format("Creating Other Payment {0} ", source)); } //else is recurring entry and the message will be printed later. } else { Ranorex.Report.Info(String.Format("Adjusting Other Payment {0} ", source)); } PaymentsJournal.repo.Transaction.Select("Make Other Payment"); Common_HeaderSetup(PaymentRecord, bEdit); if (Functions.GoodData(PaymentRecord.reference)) { PaymentsJournal.repo.Reference.TextValue = PaymentRecord.reference; } PaymentsJournal.repo.TransContainer.ClickFirstCell(); PaymentsJournal.repo.TransContainer.PressKeys("{Tab}"); // go to the Description field first PaymentsJournal.repo.TransContainer.PressKeys("{LShiftKey down}{Tab}{LShiftKey up}"); // then come back to the Account field to activate the cell for (int x = 0; x < PaymentRecord.GridRows.Count; x++) { if (Functions.GoodData(PaymentRecord.GridRows[x])) { if (Functions.GoodData(PaymentRecord.GridRows[x].account.acctNumber)) { PaymentsJournal.repo.TransContainer.SetText(PaymentRecord.GridRows[x].account.acctNumber); PaymentsJournal.repo.TransContainer.MoveRight(); // tab to the Description field } else // pick a random account { PaymentsJournal.repo.TransContainer.PressKeys("<Enter>"); // press enter to bring up the select GL account window PaymentRecord.GridRows[x].account.acctNumber = SelectAccountDialog.repo.AccountName.RandPick(true); // the focus is set to descirption field automatically so no need to tab again } if (Functions.GoodData(PaymentRecord.GridRows[x].description)) { PaymentsJournal.repo.TransContainer.SetText(PaymentRecord.GridRows[x].description); } PaymentsJournal.repo.TransContainer.MoveRight(); PaymentsJournal.repo.TransContainer.SetText(PaymentRecord.GridRows[x].amount); PaymentsJournal.repo.TransContainer.MoveRight(); if (Functions.GoodData(PaymentRecord.GridRows[x].taxCode.code)) { PaymentsJournal.repo.TransContainer.SetText(PaymentRecord.GridRows[x].taxCode.code); } if (PaymentRecord.GridRows[x].Projects.Count != 0) // enter project allocation if provided { // get global settings if haven't alreayd if (!bCheckGlobalProject) { Settings._SA_Get_AllProjectSettings(); // PaymentsJournal.repo.Window.SetActive(); bCheckGlobalProject = true; } PaymentsJournal.repo.AllocateToProjects.Click(); if (ProjectAllocationDialog.repo.SelfInfo.Exists()) { ProjectAllocationDialog._SA_EnterProjectAllocationDetails(PaymentRecord.GridRows[x].Projects); } } PaymentsJournal.repo.TransContainer.PressKeys("{Tab}"); // move to the next row } } // Recurring entry not ready // if (bRecur && !bSave) // store recurring // { // Trace.WriteLine("Storing the recurring entry " + PaymentRecord.recurringName + ", " + PaymentRecord.recurringFrequency + ""); // PaymentsJournal.repo.PressKeys("{Ctrl+t}"); // StoreRecurringDialog.Instance._SA_DoStoreRecurring(PaymentRecord.recurringName, PaymentRecord.recurringFrequency); // // discard the transaction // PaymentsJournal.ClickUndoChanges(); // } if (bSave) { PaymentsJournal.repo.Post.Click(); } }
public static void _SA_Create(PURCHASE TransRecord, bool bSave, bool bEdit, bool bRecur, bool bOneTime) { string sType = "Invoice"; // the type string to be used in the output message if (!Variables.bUseDataFiles) { PurchasesJournal._SA_MatchDefaults(TransRecord); } if (!PurchasesJournal.repo.SelfInfo.Exists()) { PurchasesJournal._SA_Invoke(); } // convert from previous switch statements if (TransRecord.GetType() == typeof(PURCHASE_QUOTE)) { sType = "Quote"; if (PurchasesJournal.repo.TransTypeDropDown.Enabled || (PurchasesJournal.repo.TransTypeDropDown.SelectedItemText != "Quote")) { PurchasesJournal.repo.TransTypeDropDown.Select(sQuote); } } else if (TransRecord.GetType() == typeof(PURCHASE_ORDER)) { sType = "Order"; if (PurchasesJournal.repo.TransTypeDropDown.Enabled || (PurchasesJournal.repo.TransTypeDropDown.SelectedItemText != "Order")) { PurchasesJournal.repo.TransTypeDropDown.Select(sOrder); } } else if (TransRecord.GetType() == typeof(PURCHASE_INVOICE)) { if (PurchasesJournal.repo.TransTypeDropDown.Enabled || (PurchasesJournal.repo.TransTypeDropDown.SelectedItemText != "Invoice")) { PurchasesJournal.repo.TransTypeDropDown.Select(sInvoice); } } // print statements if (!bEdit) { if (!bRecur) { Ranorex.Report.Info(String.Format("Creating Purchase {0} {1} ", sType, TransRecord.transNumber)); } } else { Ranorex.Report.Info(String.Format("Adjusting Purchase {0} {1} ", sType, TransRecord.transNumber)); PurchasesJournal._SA_Open(TransRecord); // load the transaction for adjustment } // set vendor if ((!bEdit) || TransRecord.GetType() == typeof(PURCHASE_INVOICE)) // entering new or adjusting invoice { if (TransRecord.Vendor.name != PurchasesJournal.repo.VendorNameText.TextValue) { PurchasesJournal.repo.VendorName.Select(TransRecord.Vendor.name); //PurchasesJournal.repo.VendorName.PressKeys("{Tab}"); // Must press tab, otherwise selecting the Paid By field may not work } } // Validate if Add on the fly is present if (AddOnTheFly.repo.SelfInfo.Exists()) { //try //{ // Functions.Verify(true, true, "Add on fly message appears"); //} //catch //{ // Functions.ExceptPrint(); //} if (bOneTime) { AddOnTheFly.repo.Continue.Select(); } else { AddOnTheFly.repo.QuickAdd.Select(); } AddOnTheFly.repo.OK.Click(); } if (TransRecord.GetType() == typeof(PURCHASE_INVOICE)) // set invoice number { if (Functions.GoodData(TransRecord.transNumber)) { PurchasesJournal.repo.InvoiceNumber.TextValue = TransRecord.transNumber; PurchasesJournal.repo.InvoiceNumber.PressKeys("{Tab}"); } else { Ranorex.Report.Info("Invoice number is missing"); Functions.Verify(false, true, "Invoice Number"); } if (Functions.GoodData(((PURCHASE_INVOICE)TransRecord).quoteOrderTransNumber) && (((PURCHASE_INVOICE)TransRecord).quoteOrderTransNumber != "")) { PurchasesJournal.repo.OrderQuoteNo.Select((TransRecord as PURCHASE_INVOICE).quoteOrderTransNumber); // Tab out // PurchasesJournal.repo.Self.PressKeys("{tab}"); // do later //SimplyMessage._SA_HandleMessage(SimplyMessage.YES_LOC, SimplyMessage._MSG_PLACEHOLDERTOFIXEXISTINGMETHODCALLS_LOC); } } else // set order/quote number { if (Functions.GoodData(TransRecord.transNumber)) { PurchasesJournal.repo.OrderQuoteNoText.TextValue = TransRecord.transNumber; } } if (TransRecord.GetType() != typeof(PURCHASE_QUOTE)) // Set Paid by and ChequeNumbers { if (Functions.GoodData(((PURCHASE_COMMON_ORDER_INVOICE)TransRecord).paymentMethod)) { if (((PURCHASE_COMMON_ORDER_INVOICE)TransRecord).paymentMethod != "") { PurchasesJournal.repo.PaidBy.Select((TransRecord as PURCHASE_COMMON_ORDER_INVOICE).paymentMethod); } } if (PurchasesJournal.repo.PaidFromInfo.Exists()) { if (Functions.GoodData(((PURCHASE_COMMON_ORDER_INVOICE)TransRecord).PaidFromAccount.acctNumber)) { PurchasesJournal.repo.PaidFrom.Select((TransRecord as PURCHASE_COMMON_ORDER_INVOICE).PaidFromAccount.acctNumber); } } if (PurchasesJournal.repo.ChequeNumberInfo.Exists()) { if (Functions.GoodData(((PURCHASE_COMMON_ORDER_INVOICE)TransRecord).chequeNumber)) { PurchasesJournal.repo.ChequeNumber.TextValue = ((PURCHASE_COMMON_ORDER_INVOICE)TransRecord).chequeNumber; } } } if (TransRecord.GetType() == typeof(PURCHASE_INVOICE)) { if (Functions.GoodData(((PURCHASE_INVOICE)TransRecord).directDepositNumber) && PurchasesJournal.repo.DirectDepositNumInfo.Exists()) { PurchasesJournal.repo.DirectDepositNum.TextValue = ((PURCHASE_INVOICE)TransRecord).directDepositNumber; } } if (TransRecord.GetType() != typeof(PURCHASE_INVOICE)) // Set shipping date { if (Functions.GoodData(TransRecord.shipDate)) { PurchasesJournal.repo.ShipDate.TextValue = TransRecord.shipDate; // PurchasesJournal.repo.ShipDate.PressKeys("{Tab}"); } } if (Functions.GoodData(TransRecord.transDate)) { // PurchasesJournal.repo.InvoiceDate.SetFocus(); // get focus back after loading quote/order for conversion. otherwise, the following line won't work PurchasesJournal.repo.InvoiceDate.TextValue = TransRecord.transDate; // PurchasesJournal.repo.InvoiceDate.PressKeys("{Tab}"); } if (Functions.GoodData(TransRecord.exchangeRate) && PurchasesJournal.repo.ExchangeRateInfo.Exists()) { PurchasesJournal.repo.ExchangeRate.TextValue = TransRecord.exchangeRate; // PurchasesJournal.Instance.ExchangeRate.PressKeys("{Tab}"); } if (Functions.GoodData(TransRecord.shipToLocation) && (TransRecord.shipToLocation != "") && (PurchasesJournal.repo.StoreItemsAtInfo.Exists()) && PurchasesJournal.repo.StoreItemsAt.Enabled) { PurchasesJournal.repo.StoreItemsAt.Select(TransRecord.shipToLocation); } // prepare the container PURCH_TABLE PT = new PURCH_TABLE(); InitializeTable(PT); // if (bEdit) // Maximize window if needed // { // PurchasesJournal.repo.Self.Maximize(); // this is required other wise the selectitme is going to the wrong row // } int nLine = 1; //for (nLine = 0; nLine < TransRecord.GridRows.Count; nLine++) // populate the container foreach (ROW currentRow in TransRecord.GridRows) { if (TransRecord.GridRows.Count == 0 && bEdit) // remove rest of row(s) during adjustment { // RemoveRow(nLine, PT.iItem); } else // enter all the fields as usual { if (Functions.GoodData(currentRow.Item.invOrServNumber)) { // since when converting quotes/orders to invoices, the item number field is disabled for editing // we have to go to the quantity cell first then back to the item number cell as well as check if the item number cell is enabled if (TransRecord.GetType() == typeof(PURCHASE_INVOICE)) { // For adjustment, the cursor starts on the second row, and no need to re-enter the inventory number if (bEdit) { PurchasesJournal.repo.TransContainer.PressKeys("{Up}"); } else { // Click on quantity cell first PurchasesJournal.repo.TransContainer.SelectCell("Quantity", nLine); PurchasesJournal.repo.TransContainer.PressKeys("{LShiftKey down}{Tab}{LShiftKey up}"); PurchasesJournal.repo.TransContainer.PressKeys("{Delete}"); // Check if item number is enabled if (PurchasesJournal.repo.ContainTextInfo.Exists()) { PurchasesJournal.repo.TransContainer.SelectCell("ItemNumber", nLine, currentRow.Item.invOrServNumber); PurchasesJournal.repo.TransContainer.PressKeys("{Tab}"); } } } else // go to item number cell and enter directly { // to be changed PurchasesJournal.repo.TransContainer.SelectCell("ItemNumber", nLine, currentRow.Item.invOrServNumber); } } if (TransRecord.GetType() == typeof(PURCHASE_INVOICE)) { if (Functions.GoodData(currentRow.quantityReceived)) { PurchasesJournal.repo.TransContainer.SelectCell("Quantity", nLine, currentRow.quantityReceived); } // Disabled for now. For serialnumberdetails, there is a generic list created by the system // enter serial number details if any if (Functions.GoodData(((PURCHASE_INVOICE)TransRecord).SerialNumberDetails)) { bool bFoundItem = false; int iItmCnt; // to be used outside the loop for (iItmCnt = 0; iItmCnt < ((PURCHASE_INVOICE)TransRecord).SerialNumberDetails.Count; iItmCnt++) { if (((PURCHASE_INVOICE)TransRecord).SerialNumberDetails[iItmCnt].Item.invOrServNumber == currentRow.Item.invOrServNumber) { bFoundItem = true; } } if (bFoundItem) { PurchasesJournal.repo.TransContainer.SelectCell("Quantity", nLine); PurchasesJournal.repo.TransContainer.PressKeys("{Enter}"); // Serial number dialog not done // if (s_desktop.Exists(EditSerialNumberDotNet.EDITSERIALNUMBERDOTNET_LOC)) // { // // //EditSerialNumberDotNet.repo.SerialContainer.SelectItem(0,0); // click in the first cell NC- commented out. seems redundant with the first line in the loop // for (int iLine = 0; iLine < ((PURCHASE_INVOICE)TransRecord).SerialNumberDetails[iItmCnt].SerialNumbersToUse.Count; iLine++) // { // EditSerialNumberDotNet.repo.SerialContainer.SelectItem(0, iLine); // EditSerialNumberDotNet.repo.SerialContainer.PressKeys(((PURCHASE_INVOICE)TransRecord).SerialNumberDetails[iItmCnt].SerialNumbersToUse[iLine]); // } // } // EditSerialNumberDotNet.repo.OK.Click(); } } } if (TransRecord.GetType() != typeof(PURCHASE_INVOICE)) // only if not invoice type since it's disabled for invoices { if (Functions.GoodData(currentRow.quantityOrdered) && currentRow.quantityOrdered != "0") { // have to tab into field otherwise if we select directly, it will type with existing text PurchasesJournal.repo.TransContainer.SelectCell("Quantity", nLine); PurchasesJournal.repo.TransContainer.PressKeys("{Tab}"); PurchasesJournal.repo.TransContainer.PressKeys(currentRow.quantityOrdered); // Enter order } } if (TransRecord.GetType() == typeof(PURCHASE_QUOTE)) { if (Functions.GoodData(currentRow.quantityBackordered)) { PurchasesJournal.repo.TransContainer.SelectCell("BackOrder", nLine); PurchasesJournal.repo.TransContainer.PressKeys(currentRow.quantityBackordered); // Enter back order } } if (Functions.GoodData(currentRow.unit)) { PurchasesJournal.repo.TransContainer.SelectCell("Unit", nLine); PurchasesJournal.repo.TransContainer.PressKeys(currentRow.unit); // Enter unit PurchasesJournal.repo.TransContainer.PressKeys("{Tab}"); } if (Functions.GoodData(currentRow.description)) { //PurchasesJournal.repo.TransContainer.SelectItem(PT.iDescription, nLine); //// we have to check if the description line has a value, if it does we have to do a delete in the field so that it doesn't append //// however, if the fields is blank, it won't work properly, so only do if not blank //// we have to use the xpath for the specific datagrid item in the container. And it's using part of the locator so that we don't have two places to //// to maintain if the container tag changes it //if(PurchasesJournal.repo.TransContainer.DataGridItem(String.Format("{0}({1}:{2})'", PurchasesJournal.TRANSCONTAINER_LOC.Replace("//DataGrid[", "").Replace("']", ""), PT.iDescription, nLine)).Text !="") //{ // PurchasesJournal.Instance.TransContainer.PressKeys("<Ctrl+Shift+Home>"); // have to delete description is duplicated // PurchasesJournal.Instance.TransContainer.TypeKeys("<Delete>"); //} PurchasesJournal.repo.TransContainer.SelectCell("Unit", nLine); PurchasesJournal.repo.TransContainer.PressKeys("{Tab}"); PurchasesJournal.repo.TransContainer.PressKeys(currentRow.description); // Enter description } if (Functions.GoodData(currentRow.price)) { PurchasesJournal.repo.TransContainer.SelectCell("Price", nLine); PurchasesJournal.repo.Self.PressKeys(currentRow.price); // NC - commented out the following debugging code. add back if necessary // added debugging code as the result of frequent failures in tests. //string sCurrVal; // value retrieved from the current cell //int n = 1; //while (n <= 2) //{ // pEnterCellValue(PurchasesJournal.Instance.TransContainer,nLine, PT.iPrice, TransRecord.GridRows[nLine].price); // Enter price // PurchasesJournal.Instance.TransContainer.TypeKeys("<Tab>"); // PurchasesJournal.Instance.TransContainer.TypeKeys("<Shift-Tab>"); // sCurrVal = Functions.NoComma(PurchasesJournal.Instance.TransContainer.GetCellValue({nLine, PT.iPrice})); // if (Convert.ToDouble(sCurrVal) == Convert.ToDouble(TransRecord.GridRows[nLine].price)) // { // break; // } // n++; //} // verify for debugging //Functions.VerifyFunction(Convert.ToDouble(sCurrVal),Convert.ToDouble(TransRecord.GridRows[nLine].price), "Price is set correctly in line " + nLine + ""); } if (Functions.GoodData(currentRow.amount)) { if (currentRow.amount.Length <= 12) // the amounts field only can type in 12 characters, let it calc if longer { PurchasesJournal.repo.TransContainer.SelectCell("Amount", nLine); PurchasesJournal.repo.TransContainer.PressKeys(currentRow.amount); // Enter amount } else if (TransRecord.GetType() == typeof(PURCHASE_INVOICE)) { if (((currentRow.quantityReceived == "0") || (currentRow.quantityReceived == null)) || ((currentRow.price == "0") || (currentRow.price == null))) { Ranorex.Report.Info("Cannot type an amount of more than 999,999,999.99."); Functions.Verify(false, true, "Amount"); } } } if (Functions.GoodData(currentRow.TaxCode.code) || Functions.GoodData(currentRow.TaxCode.description)) { // actually selecting the tax amount then tabbing back because selecint tax code column directly will bring up the selection window. //PurchasesJournal.repo.TransContainer.SelectItem(PT.iTax + 1, nLine); //PurchasesJournal.Instance.TransContainer.TypeKeys("<Shift+Tab>"); PurchasesJournal.repo.TransContainer.SelectCell("Price", nLine); // tab forward from Price, can type in Taxcode without bringing up the selection window PurchasesJournal.repo.TransContainer.PressKeys("{Tab}"); if (currentRow.TaxCode.description != Variables.sNoTax) // enter the specific tax code { PurchasesJournal.repo.TransContainer.PressKeys(currentRow.TaxCode.code); } else // set to No Tax by deleting the current tax code from the cell { PurchasesJournal.repo.Self.PressKeys("{Delete}"); } // NC - commented out the following debugging code. add back if necessary // verify. debugging code as the result of frequent failures in tests //PurchasesJournal.Instance.Window.TypeKeys("<Tab>"); //PurchasesJournal.Instance.Window.TypeKeys("<Shift-Tab>"); // have to tab out then back for the value entered to be applied //// if no tax, then the field is blank //if(TransRecord.GridRows[nLine].TaxCode.description == sNoTax) //{ // Functions.VerifyFunction(PurchasesJournal.Instance.TransContainer.GetCellValue({nLine, PT.iTax}), "", "Tax code is set correctly in line " + nLine + ""); // no tax returns as blank string //} //else //{ // VerifyFunction(PurchasesJournal.Instance.TransContainer.GetCellValue({nLine, PT.iTax}), NullToBlankString(TransRecord.GridRows[nLine].TaxCode.code), "Tax code is set correctly in line " + nLine + ""); // no tax returns as blank string //} } // only enter if there is no inventory selected if (!Functions.GoodData(currentRow.Item.invOrServNumber)) { if (Functions.GoodData(currentRow.Account.acctNumber)) // enter to the specific account { if (currentRow.Account.acctNumber != "") { PurchasesJournal.repo.TransContainer.SelectCell("Account", nLine); PurchasesJournal.repo.TransContainer.PressKeys(currentRow.Account.acctNumber); // Enter account number PurchasesJournal.repo.TransContainer.PressKeys("{Tab}"); } } else // just pick a random account { PurchasesJournal.repo.TransContainer.SelectCell("Account", nLine); PurchasesJournal.repo.TransContainer.PressKeys("{Enter}"); // SelectGLAccount not ready // // the account field maybe disabled if there's predefined account for the item selected so have to do the check here // if (s_desktop.Exists(SelectGLAccount.SELECTGLACCOUNT_LOC, 1000)) // { // string acctNumber; // SelectGLAccount.repo.PickARandomAccount(out acctNumber); // currentRow.Account.acctNumber = acctNumber; // remember the account selected // PurchasesJournal.repo.TransContainer.PressKeys("<Tab>"); // } } } if (currentRow.Projects.Count != 0) { // Enter project allocation // Process project allocation details if applicable PurchasesJournal.repo.TransContainer.SelectCell("Account", nLine); PurchasesJournal.repo.Self.PressKeys("{Ctrl Shift}a"); if (ProjectAllocationDialog.repo.SelfInfo.Exists()) { ProjectAllocationDialog._SA_EnterProjectAllocationDetails(currentRow.Projects); } } } } // remove extra rows at the end if (bEdit) { //nLine++; //PurchasesJournal.Instance.TransContainer.SelectItem(PT.iItem, nLine); NC - no longer needed // DataGridItem not ready // while (PurchasesJournal.repo.TransContainer.DataGridItem(GetDataGridItemLocator(TRANSCONTAINER_LOC, PT.iItem, nLine)).Text != "") // { // // RemoveRow(nLine, PT.iItem); // // //PurchasesJournal.Instance.SpecialTableField.TypeKeys("<Down>"); // //nLine++; // } } if (TransRecord.GetType() == typeof(PURCHASE_ORDER)) // set prepayment fields if specified { if (Functions.GoodData(((PURCHASE_ORDER)TransRecord).prepayRefNumber)) { PurchasesJournal.repo.PrepayRefNumber.TextValue = (TransRecord as PURCHASE_ORDER).prepayRefNumber; PurchasesJournal.repo.PrepayRefNumber.PressKeys("{Tab}"); } if (Functions.GoodData(((PURCHASE_ORDER)TransRecord).prepaymentAmount)) { PurchasesJournal.repo.PrepaymentAmount.TextValue = (TransRecord as PURCHASE_ORDER).prepaymentAmount; PurchasesJournal.repo.PrepaymentAmount.PressKeys("{Tab}"); } } if (Functions.GoodData(TransRecord.freightAmount)) { PurchasesJournal.repo.FreightAmount.TextValue = TransRecord.freightAmount; PurchasesJournal.repo.FreightAmount.PressKeys("{Tab}"); } if (Functions.GoodData(TransRecord.FreightTaxCode.code)) { PurchasesJournal.repo.FreightCode.TextValue = TransRecord.FreightTaxCode.code; } else if (TransRecord.FreightTaxCode.description == Variables.sNoTax) { // PurchasesJournal.repo.FreightCode.Focus(); // might not be needed in ranorex PurchasesJournal.repo.FreightCode.PressKeys("{Delete}"); PurchasesJournal.repo.FreightCode.PressKeys("{Tab}"); } if (PurchasesJournal.repo.TermsPercentInfo.Exists()) { if (Functions.GoodData(TransRecord.termsPercent)) { PurchasesJournal.repo.TermsPercent.TextValue = TransRecord.termsPercent; PurchasesJournal.repo.TermsPercent.PressKeys("{Tab}"); } if (Functions.GoodData(TransRecord.termsDays)) { PurchasesJournal.repo.TermsDay.TextValue = TransRecord.termsDays; PurchasesJournal.repo.TermsDay.PressKeys("{Tab}"); } if (Functions.GoodData(TransRecord.termsNetDays)) { PurchasesJournal.repo.TermsNetDays.TextValue = TransRecord.termsNetDays; PurchasesJournal.repo.TermsNetDays.PressKeys("{Tab}"); } } if (PurchasesJournal.repo.EarlyDiscountInfo.Exists()) { if (Functions.GoodData(((PURCHASE_INVOICE)TransRecord).earlyPaymentDiscountPercent)) { PurchasesJournal.repo.EarlyDiscount.TextValue = ((PURCHASE_INVOICE)TransRecord).earlyPaymentDiscountPercent; PurchasesJournal.repo.EarlyDiscount.PressKeys("{Tab}"); } } if (Functions.GoodData(TransRecord.shippedBy) || Functions.GoodData(TransRecord.trackingNumber)) { PurchasesJournal.repo.TrackShipments.Click(); if (Functions.GoodData(TransRecord.shippedBy)) { TrackShipments.repo.Shipper.Select(TransRecord.shippedBy); } if (Functions.GoodData(TransRecord.trackingNumber)) { TrackShipments.repo.TrackingNumber.TextValue = TransRecord.trackingNumber; } TrackShipments.repo.OK.Click(); } PurchasesJournal.repo.Self.Restore(); if (bRecur && !bSave) { // Recurring entry dialog not ready // Trace.WriteLine("Storing the recurring entry " + TransRecord.recurringName + ", " + TransRecord.recurringFrequency + ""); // PurchasesJournal.repo.RecurringEntry.Click(); // StoreRecurringDialogDotNet.repo._SA_DoStoreRecurring(TransRecord.recurringName, TransRecord.recurringFrequency); // // // discard the transaction // if (Functions.GetProgramName().ToLower() != "fastposting.cs") // { // PurchasesJournal.repo.ClickUndoChanges(true); // wait on the message // } // else // { // PurchasesJournal.repo.ClickUndoChanges(false); // } } if (bSave) { PurchasesJournal.repo.Post.Click(); // use data file not ready // if (Variables.bUseDataFiles) // only handle the messages when using external data (i.e. audit) // { // while (!(PurchasesJournal.repo.Window.Enabled)) // { // SimplyMessage.repo._SA_HandleMessage(SimplyMessage.YES_LOC, SimplyMessage._MSG_AREYOUSUREYOUWANTTOREMOVEORREVERSE_LOC, false, true); // SimplyMessage.repo._SA_HandleMessage(SimplyMessage.OK_LOC, SimplyMessage._MSG_ORDERHASBEENFILLEDANDREMOVED_LOC, false, true); // SimplyMessage.repo._SA_HandleMessage(SimplyMessage.NO_LOC, SimplyMessage._MSG_THEINVOICENUMBERYOUENTEREDISGREATER_LOC, false, true); // SimplyMessage.repo._SA_HandleMessage(SimplyMessage.YES_LOC, SimplyMessage._MSG_YOUAREABOUTTOCHANGETHEQUOTEINTOANORDER_LOC, false, true); // SimplyMessage.repo._SA_HandleMessage(SimplyMessage.YES_LOC, SimplyMessage._MSG_THERECURRINGTRANSACTIONHASBEENCHANGED_LOC, false, true); // } // } } }
public static void _SA_Create(GENERAL_JOURNAL GJRecord, bool bSave, bool bEdit, bool bRecur) { bool bCheckGlobalProject = false; if (!GeneralJournal.repo.SelfInfo.Exists()) { GeneralJournal._SA_Invoke(); } if (bEdit) { if (GeneralJournal.repo.Source.TextValue != GJRecord.source) // load the journal entry for editing { GeneralJournal._SA_Open(GJRecord); } Ranorex.Report.Info("Adjusting General Journal " + GJRecord.source + ""); } else if (!(bRecur)) { Ranorex.Report.Info("Creating General Journal " + GJRecord.source + ""); } if (Functions.GoodData(GJRecord.source)) { GeneralJournal.repo.Source.TextValue = GJRecord.source; } if (Functions.GoodData(GJRecord.journalDate)) { GeneralJournal.repo.JournalDate.TextValue = GJRecord.journalDate; } if (Functions.GoodData(GJRecord.comment)) { GeneralJournal.repo.Comment.TextValue = GJRecord.comment; } if (Functions.GoodData(GJRecord.currCode)) { if (GeneralJournal.repo.CurrencyCodeInfo.Exists()) { GeneralJournal.repo.CurrencyCode.Select(GJRecord.currCode); if ((bEdit && Variables.bUseDataFiles)) { // dw SimplyMessage.repo._SA_HandleMessage(SimplyMessage.YES_LOC, SimplyMessage._MSG_YOUHAVESELECTEDADIFFERENTFOREIGNCURRENCY_LOC, false, true); } } } if (Functions.GoodData(GJRecord.exchRate)) { if (GeneralJournal.repo.ExchangeRateInfo.Exists() && Functions.GoodData(GJRecord.exchRate)) { GeneralJournal.repo.ExchangeRate.TextValue = GJRecord.exchRate; } } // click to first cell GeneralJournal.repo.DetailsContainer.ClickFirstCell(); //int x; if (bEdit) { //clear all the existing lines in the grid int x = 0; while (GeneralJournal.repo.DetailsContainer.GetContents().Count != 0) { if (x > 100) { Functions.Verify(false, true, "able to clear all details of table on edit"); break; } GeneralJournal.repo.DetailsContainer.PressKeys("<Alt+e>"); // to remove line GeneralJournal.repo.DetailsContainer.PressKeys("r"); x++; } } if (Functions.GoodData(GJRecord.GridRows)) { double nTotalDebit = 0; // total debit amount double nTotalCredit = 0; // total credit amount //int iDelay = 2; // sleep 2 sec for (int x = 0; x < GJRecord.GridRows.Count; x++) { // enter account GeneralJournal.repo.DetailsContainer.PressKeys(GJRecord.GridRows[x].Account.acctNumber + "{Tab}"); // enter Debit/Crecit amount if (x == 0) { if (Functions.GoodData(GJRecord.GridRows[x].debitAmt) && GJRecord.GridRows[x].debitAmt != "0") { GeneralJournal.repo.DetailsContainer.PressKeys(GJRecord.GridRows[x].debitAmt); nTotalDebit += Convert.ToDouble(GJRecord.GridRows[x].debitAmt); GeneralJournal.repo.DetailsContainer.MoveRight(); } else { GeneralJournal.repo.DetailsContainer.MoveRight(); if (Functions.GoodData(GJRecord.GridRows[x].creditAmt)) { GeneralJournal.repo.DetailsContainer.SetText(GJRecord.GridRows[x].creditAmt); nTotalCredit += Convert.ToDouble(GJRecord.GridRows[x].creditAmt); } GeneralJournal.repo.DetailsContainer.MoveRight(); } } // All lines after the first one will be depending on the total debit amount and total credit amount else { //if((GoodData (GJRecord.GridRows[1].debitAmt) && (GJRecord.GridRows[1].debitAmt != "0"))) if (nTotalDebit > nTotalCredit) // focus set to the credit field { if (Functions.GoodData(GJRecord.GridRows[x].creditAmt) && (GJRecord.GridRows[x].creditAmt != "0")) { GeneralJournal.repo.DetailsContainer.SetText(GJRecord.GridRows[x].creditAmt); nTotalCredit += Convert.ToDouble(GJRecord.GridRows[x].creditAmt); GeneralJournal.repo.DetailsContainer.MoveRight(); } else { GeneralJournal.repo.DetailsContainer.PressKeys("{Delete}"); GeneralJournal.repo.DetailsContainer.PressKeys("{LShiftKey down}{Tab}{LShiftKey up}"); GeneralJournal.repo.DetailsContainer.SetText(GJRecord.GridRows[x].debitAmt); nTotalDebit += Convert.ToDouble(GJRecord.GridRows[x].debitAmt); GeneralJournal.repo.DetailsContainer.MoveRight(); } } else // focus set to the debit field { if (Functions.GoodData(GJRecord.GridRows[x].debitAmt) && (GJRecord.GridRows[x].debitAmt != "0")) { GeneralJournal.repo.DetailsContainer.SetText(GJRecord.GridRows[x].debitAmt); nTotalDebit += Convert.ToDouble(GJRecord.GridRows[x].debitAmt); GeneralJournal.repo.DetailsContainer.MoveRight(); } else { GeneralJournal.repo.DetailsContainer.PressKeys("{Delete}"); GeneralJournal.repo.DetailsContainer.MoveRight(); GeneralJournal.repo.DetailsContainer.SetText(GJRecord.GridRows[x].creditAmt); nTotalCredit += Convert.ToDouble(GJRecord.GridRows[x].creditAmt); GeneralJournal.repo.DetailsContainer.MoveRight(); } } } // enter line comment if (Functions.GoodData(GJRecord.GridRows[x].lineComment)) { GeneralJournal.repo.DetailsContainer.SetText(GJRecord.GridRows[x].lineComment); } // enter project allocation for the line if (GeneralJournal.repo.AllocateToProject.Enabled && GJRecord.GridRows[x].Projects.Count > 0) { if (Functions.GoodData(GJRecord.GridRows[x].Projects)) { // get global settings if haven't alreayd if (!bCheckGlobalProject) { Settings._SA_Get_AllProjectSettings(); GeneralJournal.repo.Self.Activate(); bCheckGlobalProject = true; } GeneralJournal.repo.AllocateToProject.Click(); if (ProjectAllocationDialog.repo.SelfInfo.Exists()) { ProjectAllocationDialog._SA_EnterProjectAllocationDetails(GJRecord.GridRows[x].Projects); } } } // move to the next line GeneralJournal.repo.DetailsContainer.MoveRight(); } } // if (bRecur && !bSave) // { // Ranorex.Report.Info("Storing the recurring entry " + GJRecord.recurrName + ", " + GJRecord.recurrFrequency + ""); // GeneralJournal.repo.Self.PressKeys("<Ctrl+t>"); // StoreRecurringDialog.repo._SA_DoStoreRecurring (GJRecord.recurrName, GJRecord.recurrFrequency); // GeneralJournal.repo.ToolBar.Undo.Click(); // } if (bSave) { GeneralJournal.repo.Post.Click(); if (Variables.bUseDataFiles) // handle possible messages { while (!GeneralJournal.repo.Self.Enabled) { // dw SimplyMessage.repo._SA_HandleMessage(SimplyMessage.YES_LOC, SimplyMessage._MSG_THISTRANSACTIONUSESLINKEDTAXACCOUNTS_LOC, false, true); // dw SimplyMessage.repo._SA_HandleMessage(SimplyMessage.YES_LOC, SimplyMessage._MSG_THISENTRYUSESLINKEDCONTROLACCOUNTS_LOC, false, true); // dw SimplyMessage.repo._SA_HandleMessage(SimplyMessage.YES_LOC, SimplyMessage._MSG_THERECURRINGTRANSACTIONHASBEENCHANGED_LOC, false, true); } } // dw SimplyMessage.repo._SA_HandleMessage(SimplyMessage.NO_LOC, SimplyMessage._MSG_DOYOUWANTTOSAVENEWEXCHANGERATE_LOC, false, true); } }
public static PURCHASE _SA_Read(PURCHASE TransRecord, bool bOneTime) // method will read all fields and store the data in a PURCHASE record { PURCHASE Purch; // load it in adjustment mode first if (Functions.GoodData(TransRecord)) // load the transaction if specified { PurchasesJournal._SA_Open(TransRecord, true, bOneTime); } // set focus from the settings window back to the journal window //PurchasesJournal.Instance.Window.SetActive(); // create the correct object based on the transaction type string transType = PurchasesJournal.repo.TransTypeDropDown.SelectedItemText; if (transType.ToLower().Contains("invoice")) { Purch = new PURCHASE_INVOICE(); } else if (transType.ToLower().Contains("order")) { Purch = new PURCHASE_ORDER(); } else if (transType.ToLower().Contains("quote")) { Purch = new PURCHASE_QUOTE(); } else { Purch = new PURCHASE_INVOICE(); //Functions.Verify(false, true, "Valid value from transaction list"); } if (Purch.GetType() != typeof(PURCHASE_QUOTE)) // i.e. order or invoice { // Set Paid by and ChequeNumbers ((PURCHASE_COMMON_ORDER_INVOICE)Purch).paymentMethod = PurchasesJournal.repo.PaidBy.SelectedItemText; if (PurchasesJournal.repo.PaidFromInfo.Exists()) { { ((PURCHASE_COMMON_ORDER_INVOICE)Purch).PaidFromAccount.acctNumber = PurchasesJournal.repo.PaidFrom.SelectedItemText; } } if (PurchasesJournal.repo.ChequeNumberInfo.Exists()) { { ((PURCHASE_COMMON_ORDER_INVOICE)Purch).chequeNumber = PurchasesJournal.repo.ChequeNumber.TextValue; } } } if (Purch.GetType() == typeof(PURCHASE_INVOICE)) // set style for invoice, transaction number, & Quote Number if present { { Purch.transNumber = PurchasesJournal.repo.InvoiceNumber.TextValue; if (PurchasesJournal.repo.OrderQuoteNoInfo.Exists()) // doesn't exists for one time { ((PURCHASE_INVOICE)Purch).quoteOrderTransNumber = PurchasesJournal.repo.OrderQuoteNoText.TextValue; } } } else // set transaction number and shipping date for order/quote { Purch.transNumber = PurchasesJournal.repo.OrderQuoteNoText.TextValue; Purch.shipDate = PurchasesJournal.repo.ShipDate.TextValue; } Purch.Vendor.name = PurchasesJournal.repo.VendorNameText.TextValue; Purch.transDate = PurchasesJournal.repo.InvoiceDate.TextValue; if (PurchasesJournal.repo.ExchangeRateInfo.Exists()) { Purch.exchangeRate = PurchasesJournal.repo.ExchangeRate.TextValue; } if (PurchasesJournal.repo.StoreItemsAtInfo.Exists()) { if (PurchasesJournal.repo.StoreItemsAt.Enabled) { Purch.shipToLocation = PurchasesJournal.repo.StoreItemsAt.SelectedItemText; } } // prepare the container PURCH_TABLE PT = new PURCH_TABLE(); // InitializeTable(PT); //int iNumOfCols = PurchasesJournal.repo.TransContainer.ColumnCount; //List<string[]> containerLine = ConvertFunctions.DataGridItemsToListOfString(PurchasesJournal.Instance.TransContainer.Items, iNumOfCols); List <List <string> > Contents = PurchasesJournal.repo.TransContainer.GetContents(); List <ROW> lR = new List <ROW>() { }; //for (int x = 0; x < containerLine.Count; x++) foreach (List <string> currRow in Contents) { // it's a blank row if the item number, quantity received, quantity ordered, description, and amount fields are all blank if ((currRow[PT.iItem] == "") && (currRow[PT.iQuantity] == "") && (currRow[PT.iOrder] == "") && (currRow[PT.iDescription] == "") && (currRow[PT.iAmount] == "")) { // do not add } else { ROW R = new ROW(); // assign recordset R.Item.invOrServNumber = ConvertFunctions.CommaToText(currRow[PT.iItem]); R.quantityReceived = ConvertFunctions.CommaToText(currRow[PT.iQuantity]); R.quantityOrdered = ConvertFunctions.CommaToText(currRow[PT.iOrder]); R.quantityBackordered = ConvertFunctions.CommaToText(currRow[PT.iBackOrder]); R.unit = ConvertFunctions.CommaToText(currRow[PT.iUnit]); //R.Item.invOrServDescription = StrTran(containerLine[5+ iItmColID], "," ,"\comma") // wrong record field R.description = ConvertFunctions.CommaToText(currRow[PT.iDescription]); R.price = ConvertFunctions.CommaToText(currRow[PT.iPrice]); R.TaxCode.code = ConvertFunctions.CommaToText(currRow[PT.iTax]); // blank when no tax R.amount = ConvertFunctions.CommaToText(currRow[PT.iAmount]); R.Account.acctNumber = ConvertFunctions.CommaToText(currRow[PT.iAccount]); // append to detail list lR.Add(R); } //// only remove if more than one line is present. NC - no longer needed so commented out //if(containerLine.Count >iNumOfCols) //{ // // remove line already recorded // for ( int i = 0; i < iNumOfCols; i++) // { // containerLine.RemoveAt(1); // } //} //else //{ // containerLine.RemoveAt(1); //} } // add rows to the record Purch.GridRows = lR; // read project allocation data if (Functions.GoodData(Purch.GridRows)) { //PurchasesJournal.Instance.VendorName.SetFocus(); // Set focus within the journal first, or else sometimes cannot select the account field. for (int x = 0; x < Purch.GridRows.Count; x++) { if (Functions.GoodData(Purch.GridRows[x].amount)) // proceed only if amount is available { PurchasesJournal.repo.TransContainer.SelectCell("Account", x); // select account field PurchasesJournal.repo.TransContainer.PressKeys("{Ctrl Shift}a"); if (ProjectAllocationDialog.repo.SelfInfo.Exists()) { Purch.GridRows[x].Projects = ProjectAllocationDialog._SA_GetProjectAllocationDetails(); // get dialog content ProjectAllocationDialog.repo.Cancel.Click(); } } } } if (PurchasesJournal.repo.PrepayRefNumberInfo.Exists()) { ((PURCHASE_ORDER)Purch).prepayRefNumber = PurchasesJournal.repo.PrepayRefNumber.TextValue; ((PURCHASE_ORDER)Purch).prepaymentAmount = PurchasesJournal.repo.PrepaymentAmount.TextValue; } Purch.freightAmount = PurchasesJournal.repo.FreightAmount.TextValue; Purch.FreightTaxCode.code = PurchasesJournal.repo.FreightCode.TextValue; if (PurchasesJournal.repo.FreightTaxTotalInfo.Exists()) // db has more than 2 taxes defined { Purch.freightTaxTotal = PurchasesJournal.repo.FreightTaxTotal.TextValue; } else // only two taxes and both shown { Purch.freightTax1 = PurchasesJournal.repo.FreightTax1.TextValue; // will not show if only one tax is shown if (PurchasesJournal.repo.FreightTax2Info.Exists()) { Purch.freightTax2 = PurchasesJournal.repo.FreightTax2.TextValue; } } if (PurchasesJournal.repo.TermsPercentInfo.Exists()) { Purch.termsPercent = PurchasesJournal.repo.TermsPercent.TextValue; Purch.termsDays = PurchasesJournal.repo.TermsDay.TextValue; Purch.termsNetDays = PurchasesJournal.repo.TermsNetDays.TextValue; } if (PurchasesJournal.repo.EarlyDiscountInfo.Exists()) { ((PURCHASE_INVOICE)Purch).earlyPaymentDiscountPercent = PurchasesJournal.repo.EarlyDiscount.TextValue; } if (Purch.GetType() == typeof(PURCHASE_INVOICE)) // set tracking { if (Functions.GoodData(Purch.shippedBy) || Functions.GoodData(Purch.trackingNumber)) { PurchasesJournal.repo.Self.PressKeys("{Ctrl}k"); Purch.shippedBy = TrackShipments.repo.Shipper.SelectedItemText; Purch.trackingNumber = TrackShipments.repo.TrackingNumber.TextValue; TrackShipments.repo.OK.Click(); } } return(Purch); }
public static GENERAL_JOURNAL _SA_Read(string sIDToRead) // method will read all fields and store the data in a RECEIPT record { GENERAL_JOURNAL GJE = new GENERAL_JOURNAL(); if (Functions.GoodData(sIDToRead)) { GJE.source = sIDToRead; if (GeneralJournal.repo.Source.TextValue != GJE.source) { GeneralJournal._SA_Open(GJE); } } GJE.journalDate = GeneralJournal.repo.JournalDate.TextValue; GJE.comment = GeneralJournal.repo.Comment.TextValue; if (GeneralJournal.repo.SelfInfo.Exists()) { GJE.currCode = GeneralJournal.repo.CurrencyCode.SelectedItem.Text; } GJE.GridRows.Clear(); List <List <string> > lsContents = GeneralJournal.repo.DetailsContainer.GetContents(); //if (Functions.GoodData (lsContents)) NC - no longer need to check since the lsContents.Count sort of does the same thing //{ for (int x = 0; x < lsContents.Count; x++) { // check for blank line if (lsContents[x][0] != "") { GJ_ROW GR = new GJ_ROW(); GR.Account.acctNumber = lsContents[x][0]; if (lsContents[x][1].Trim() == "--") { GR.debitAmt = "0"; } else { GR.debitAmt = lsContents[x][1]; } if (lsContents[x][2].Trim() == "--") { GR.creditAmt = "0"; } else { GR.creditAmt = lsContents[x][2]; } GR.lineComment = lsContents[x][3]; GJE.GridRows.Add(GR); } } //} // Get project allocations // Move to first cell GeneralJournal.repo.DetailsContainer.ClickFirstCell(); if (Functions.GoodData(GJE.GridRows)) { for (int x = 0; x < GJE.GridRows.Count; x++) { if (GeneralJournal.repo.AllocateToProject.Enabled) { GJE.GridRows[x].Projects.Clear(); GeneralJournal.repo.AllocateToProject.Click(); if (ProjectAllocationDialog.repo.SelfInfo.Exists()) { //List<List<string>> lsContents = ProjectAllocationDialog.repo.DataGrid.GetContents(); //if (Functions.GoodData (lsContents)) //{ // for (int y = 0; y < lsContents.Count; y++) // { // if (Functions.GetField.Trim(' '), 1)) == "") // { // break; // } // else // { // PROJECT_ALLOCATION PA = new PROJECT_ALLOCATION(); // PA.Project.name = Functions.Functions.GetField (lsContents[y], " ", 1); // if(Functions.GetField.Trim(' '), 2)) == "--") // { // PA.Amount = "0"; // } // else // { // PA.Amount = Functions.Functions.GetField (lsContents[y], " ", 2); // } // if(Functions.GetField.Trim(' '), 3)) == "--") // { // PA.Percent = "0"; // } // else // { // PA.Percent = Functions.Functions.GetField (lsContents[y], " ", 3); // } // GJE.GridRows[x].Projects.Add(PA); // } // } GJE.GridRows[x].Projects = ProjectAllocationDialog._SA_GetProjectAllocationDetails(); } ProjectAllocationDialog.repo.Cancel.Click(); } GeneralJournal.repo.DetailsContainer.PressKeys("<Down>"); } } return(GJE); }