Exemplo n.º 1
0
        /// <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;

            string sT5018Summary = @"C:\Users\Public\Documents\Simply Accounting\2018\Data\Summary of Contract Payments.pdf";// @"C:\Users\_sabvt\Documents\Simply Accounting\DATA\Summary of Contract Payments.pdf";

            string sInstallPath = Simply._SA_GetProgramPath();
            string sDllPath     = string.Format(@"{0}acPDFCreatorLib.Net.dll", sInstallPath);

            // Check Sage 50 pdf engine dll is installed before starting test case
            if (Functions.VerifyFileExists(sDllPath))
            {
                // Remove existing pdf file
                Functions.RemoveExistingFile(sT5018Summary);

                // Create a T5018 vendor
                VENDOR tvendor = new VENDOR();

                tvendor.name = StringFunctions.RandStr("A(9)");
                tvendor.includeFilingT5018CheckBox = true;
                PayablesLedger._SA_Create(tvendor);
                PayablesLedger._SA_Close();

                // Create an item
                ITEM       item      = new ITEM();
                ITEM_PRICE itemPrice = new ITEM_PRICE();
                itemPrice.currency            = "Canadian Dollars";
                itemPrice.priceList           = "Regular";
                itemPrice.pricePerSellingUnit = Functions.RandCashAmount();
                item.ItemPrices.Add(itemPrice);


                if (this.varItem == "")
                {
                    item.invOrServNumber = StringFunctions.RandStr("A(9)");

                    InventoryServicesLedger._SA_Create(item);
                    InventoryServicesLedger._SA_Close();
                }
                else
                {
                    item.invOrServNumber = this.varItem;
                }

                // Create purchase invoice using T5018 vendor
                PURCHASE_INVOICE purInv = new PURCHASE_INVOICE();
                purInv.Vendor      = tvendor;
                purInv.transNumber = StringFunctions.RandStr("9(8)");

                ROW firstRow = new ROW();
                firstRow.Item.invOrServNumber = item.invOrServNumber;
                firstRow.quantityReceived     = Functions.RandCashAmount(2);
                firstRow.price = Functions.RandCashAmount();
                purInv.GridRows.Add(firstRow);

                PurchasesJournal._SA_Create(purInv);
                PurchasesJournal._SA_Close();

                // Print T5018 summary to a file
                string sCraNumber = "403381601RZ0001";
                Simply._Print_T5018Summary(sCraNumber);


                // Verify printed file
                if (!Functions.VerifyFileExists(sT5018Summary))
                {
                    Functions.Verify(false, true, "Printed T5018 form found");
                }
            }
            else
            {
                Functions.Verify(false, true, "PDF engine dll file found");
            }

            // Wait 5 seconds before moving on to next testcase
            Thread.Sleep(5000);
        }
        /// <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 vendor
            VENDOR ven = new VENDOR();

            if (this.varItem == "")
            {
                ven.name = "Vend" + StringFunctions.RandStr("X(8)");

                PayablesLedger._SA_Create(ven);
                PayablesLedger._SA_Close();
            }
            else
            {
                ven.name = this.varVendor;
            }

            // Create an item
            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
            PURCHASE_INVOICE pi = new PURCHASE_INVOICE();

            pi.Vendor = ven;
            ROW r = new ROW();

            r.Item             = item;
            r.quantityReceived = Functions.RandCashAmount(2);
            r.price            = Functions.RandCashAmount();

            pi.GridRows.Add(r);

            if (this.varPInvoice == "")
            {
                pi.transNumber = StringFunctions.RandStr("9(8)");
                PurchasesJournal._SA_Create(pi);
                System.Threading.Thread.Sleep(2000);
                PurchasesJournal._SA_Close();
            }
            else
            {
                pi.transNumber = this.varPInvoice;
            }

            // Adjust the invoice

            pi.GridRows[0].quantityReceived = Functions.RandCashAmount(2);
            PurchasesJournal._SA_Create(pi, true, true);
            PurchasesJournal._SA_Close();
        }
Exemplo n.º 3
0
        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);
        }