Esempio n. 1
0
        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);
//                    }
//                }
            }
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        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);
            }
        }