public void Test_CurrencyPln_606015()
        {
            var valueToConvert  = "606015.00";
            var numbertoConvert = decimal.Parse(valueToConvert.Replace(",", "."), NumberFormatInfo.InvariantInfo);

            Assert.Equal("sześćset sześć tysięcy piętnaście złotych zero groszy", NumberToText.Convert(numbertoConvert, CreateNumberToTextOption("PLN")));
        }
Beispiel #2
0
 public void SetDisplay(object o)
 {
     if (o is Complex)
     {
         var par = (Complex)o;
         TbText.Text = string.Format("Real part: {0}, Imaginary part: {1}",
                                     NumberToText.NumberText(par.Real),
                                     NumberToText.NumberText(par.Imaginary));
     }
     else if (o is Fraction)
     {
         var fr = (Fraction)o;
         TbText.Text = string.Format("{0} over {1}",
                                     NumberToText.NumberText(fr.Numerator),
                                     NumberToText.NumberText(fr.Denominator));
     }
     else
     {
         try
         {
             var d = Convert.ToDouble(o);
             TbText.Text = NumberToText.NumberText(d);
         }
         catch (Exception) { TbText.Text = "Not a number"; }
     }
 }
Beispiel #3
0
        public void NewWay()
        {
            // TODO: Pomysł 1

            var test = NumberToText.Convert(2.3M, new NumberToTextOptions
            {
                Dictionary = new PolishWithsStemsDictionary();
            });
Beispiel #4
0
 private void PaymentReceiptDetails_Load(object sender, EventArgs e)
 {
     lblORNo.Text         = ORno.ToString();
     lblStudentID.Text    = StudentID;
     lblStudentName.Text  = StudentName;
     txtAmount.Text       = _Amount.ToString();
     lblAmountInText.Text = NumberToText.Convert(_Amount);
 }
        public void Test_SplitDecimal_50_50()
        {
            var options = new NumberToTextOptions
            {
                SplitDecimal = "i"
            };

            Assert.Equal("piecdziesiat i piecdziesiat", NumberToText.Convert(50.50M, options));
        }
Beispiel #6
0
        [InlineData(1000000000000000000, "Invalid Amount.")] //More than 999 trillion

        public void NumberToTextShouldPass(decimal Amount, string expected)
        {
            var numberToText = new NumberToText();

            numberToText.ConvertAmountToWord(Amount);
            string actual = numberToText.AmountInWords.Trim();

            Assert.Equal(expected, actual);
        }
        public void Test_SplitDecimal_0_12()
        {
            var options = new NumberToTextOptions
            {
                Currency = Currency.PLN
            };

            Assert.Equal("zero zlotych dwanascie groszy", NumberToText.Convert(0.12M, options));
        }
Beispiel #8
0
        public void TestProcessNegativeIntegers()
        {
            NumberToText <int> numToText = new NumberToText <int>();

            numToText.SetValues(-10, 100, 50, 20);
            var message  = numToText.Process();
            var expected = "Error: Input should be > 0";

            Assert.AreEqual(expected, message.Replace(Environment.NewLine, ""));
        }
Beispiel #9
0
        public void TestProcessHighErrorMessage()
        {
            NumberToText <int> numToText = new NumberToText <int>();

            numToText.SetValues(5, 10, 10, 50);
            var message  = numToText.Process();
            var expected = "Error: High should be higher value";

            Assert.AreEqual(expected, message.Replace(Environment.NewLine, ""));
        }
Beispiel #10
0
        public void TestProcess()
        {
            NumberToText <int> numToText = new NumberToText <int>();

            numToText.SetValues(10, 100, 20, 50);
            var message  = numToText.Process();
            var expected = "Output - \n 10: 10 \n 20: Fancy \n 50: Pants \n 100: Fancy Pants \n";

            Assert.AreEqual(expected.Replace(" ", "").Replace("\n", ""), message.Replace(" ", "").Replace(Environment.NewLine, ""));
        }
Beispiel #11
0
        private string CreateAmountInWords()
        {
            var options = new NumberToTextOptions
            {
                Stems    = true,
                Currency = Currency.PLN
            };

            return(NumberToText.Convert(Convert.ToDecimal(_grossSum, _culture), options));
        }
        public void Test_SplitDecimal_12_02()
        {
            var options = new NumberToTextOptions
            {
                Currency     = Currency.PLN,
                SplitDecimal = " oraz "
            };

            Assert.Equal("dwanascie zlotych  oraz  dwa grosze", NumberToText.Convert(12.02M, options));
        }
        public void Test_SplitDecimal_12_23()
        {
            var options = new NumberToTextOptions
            {
                Currency     = Currency.PLN,
                SplitDecimal = "i"
            };


            Assert.Equal("dwanascie zlotych i dwadziescia trzy grosze", NumberToText.Convert(12.23M, options));
        }
        public void Test_SplitDecimal_5_5()
        {
            var options = new NumberToTextOptions
            {
                Currency     = Currency.PLN,
                SplitDecimal = "i"
            };


            Assert.Equal("piec zlotych i piecdziesiat groszy", NumberToText.Convert(5.5M, options));
        }
Beispiel #15
0
        public void isValidNumber()
        {
            int number;

            number = -11;

            // NumberToText nt = new NumberToText();
            string result       = NumberToText.NumberToTexts(number, false);
            string actualResult = "Invalid Number";

            Assert.AreEqual(result, actualResult);
        }
Beispiel #16
0
        static void Process()
        {
            var result = string.Empty;
            NumberToText <int> numToTextObject = new NumberToText <int>();

            Read();
            numToTextObject.SetValues(low, high, a, b);
            result = numToTextObject.Process();

            LogToConsole(result);
            FileLogger.Instance.LogToFile(result);
        }
Beispiel #17
0
        public void CanHandleDoubleDigits()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("42");
            var expected = "forty two";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #18
0
        public void CanHandleZeroesTripleDigits()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("600");
            var expected = "six hundred";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #19
0
        public void CanHandleThousands()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("6001");
            var expected = "six thousand one";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #20
0
        public void CanHandleThousandsWithComma()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("1,337");
            var expected = "one thousand three hundred thirty seven";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #21
0
        public void CanHandleMillions()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("12,696,969");
            var expected = "twelve million six hundred ninety six thousand nine hundred sixty nine";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #22
0
        public void CanHandleNegativeTripleDigits()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("-717");
            var expected = "negative seven hundred seventeen";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #23
0
        public void CanHandleBillionsInDebt()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("-88,312,696,969");
            var expected = "negative eighty eight billion three hundred twelve million six hundred ninety six thousand nine hundred sixty nine";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #24
0
        public void CanHandleTripleDigits()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("343");
            var expected = "three hundred forty three";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #25
0
        public void CanHandleEvenTrillions()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("1,000,000,000,000");
            var expected = "one trillion";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #26
0
        public void CanHandleQuestionableZero()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("+0");
            var expected = "positive zero";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #27
0
        public void CanHandleComplexTrillions()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("11,000,421,700,010");
            var expected = "eleven trillion four hundred twenty one million seven hundred thousand ten";

            // assert
            Assert.Equal(expected, actual);
        }
Beispiel #28
0
        public void CanHandleSingleDigit()
        {
            // arrange
            string actual;
            var    test = new NumberToText();

            // act
            actual = test.Convert("9");
            var expected = "nine";

            // assert
            Assert.Equal(expected, actual);
        }
        public JSON GenerateRequestForPayment(RequestForPayment Param)
        {
            JSON returnJSON = new JSON();

            Application app      = new Application();
            object      misValue = System.Reflection.Missing.Value;

            if (File.Exists(FormController.ServerPathTempForms() + Param.FileName + ".docx"))
            {
                File.Delete(FormController.ServerPathTempForms() + Param.FileName + ".docx");
            }

            try
            {
                File.Copy(FormController.ServerPathFormsTemplate() + "Request for Payment.docx", FormController.ServerPathTempForms() + Param.FileName + ".docx");

                Document doc = app.Documents.Open(FormController.ServerPathTempForms() + Param.FileName + ".docx");

                Dictionary <string, string> bookmarks = new Dictionary <string, string> {
                    { "RequestDate", Param.RequestDate },
                    { "Payee", Param.Payee },
                    { "AmountInWords", $"{NumberToText.Convert(Param.AmountInValue)} Pesos" },
                    { "AmountInValue", "₱ " + String.Format("{0:n}", Param.AmountInValue) },
                    { "Purpose", Param.Purpose },
                    { "DueDate", Param.DueDate },
                    { "PreparedBy", GenFunct.ToTitleCase($"{Param.PreparedBy.FirstName} {Param.PreparedBy.MiddleName}. {Param.PreparedBy.LastName} {Param.PreparedBy.Suffix}") },
                    { "FormOfPayment", GetFormOfPaymentDescription(Param.FormOfPaymentID, Param.OtherFormOfPayment) },
                    //{ "OtherFormOfPayment", Param.OtherFormOfPayment },
                    { "RecommendedBy", GenFunct.ToTitleCase($"{Param.RecommendedBy.FirstName} {Param.RecommendedBy.MiddleName}. {Param.RecommendedBy.LastName} {Param.RecommendedBy.Suffix}") }
                };

                FormToWord.ApplyDataToBookmark(bookmarks, doc);

                doc.Save();
                doc.Close();

                app.Quit();

                LLFCForm LLFCFormObj = new LLFCForm();
                LLFCFormObj.FormDownloadFile = Param.FileName;

                returnJSON.FormData = LLFCFormObj;
            }
            catch (Exception ex)
            {
                app.Quit();
                returnJSON.Message = $"Error Occured: {ex.Message}";
            }

            return(returnJSON);
        }
Beispiel #30
0
        public void fillRpt(string name, TextEdit txtPaid, string offerName, DateTime dtBegin, DateTime dtEnd, string carry, int RGpaymentMethod)
        {
            var gymData = db.GymDatas.Find(1);

            ulong n = 0;

            ulong.TryParse(txtPaid.Text, out n);

            string msg = n > 0 ? NumberToText.ConvertToArabic(ulong.Parse(txtPaid.Text)) : txtPaid.Text;

            rptCashIn rpt = new rptCashIn();

            rpt.paramGymName.Value = gymData.Name;
            rpt.paramPhone.Value   = gymData.Phone1;
            rpt.paramPhone2.Value  = gymData.Phone2;
            rpt.paramName.Value    = name;
            rpt.paramMoney.Value   = txtPaid.Text;
            rpt.paramAmount.Value  = msg;
            rpt.paramReceipt.Value = (Properties.Settings.Default.RecieptID);
            DateTime dt1 = DateTime.Now.Date;

            dt1 = dt1.Date;
            rpt.paramDate.Value  = dt1;
            rpt.paramOffer.Value = offerName;
            DateTime dt = dtBegin;

            dt = dt.Date;
            rpt.paramFrom.Value = dt;
            dt = dtEnd;
            dt = dt.Date;
            rpt.paramTo.Value      = dt;
            rpt.paramCarry.Value   = carry;
            rpt.paramPhone.Value   = gymData.Phone1;
            rpt.paramAddress.Value = gymData.Address;
            byte[]       img  = gymData.Logo;
            MemoryStream ms   = new MemoryStream(img);
            Image        _img = Image.FromStream(ms);

            if (RGpaymentMethod == 0)
            {
                rpt.chk1.Checked = true;
            }
            else
            {
                rpt.chk2.Checked = true;
            }
            rpt.xrPictureBox1.Image = _img;
            rpt.paramUser.Value     = Program.Username;
            rpt.ShowPreview();
        }
Beispiel #31
0
        private void radioGroup1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lblAmmount.Text == "")
            {
                return;
            }
            txtNo.Text = "";
            if (radioGroup1.Text.Trim() == "DD" || radioGroup1.Text.Trim() == "Cheque")
            {
                lblNO.Visible = txtNo.Visible = true;
                if (radioGroup1.Text.Trim() == "Cheque")
                {
                    NumberToText nm = new NumberToText();
                    m_sbQueryText.Length = 0;
                    m_sbQueryText.AppendFormat("select nextno from NexusGarments_Master_ChequeBook where id = (select min(id) from NexusGarments_Master_ChequeBook where isClosed='False')");
                    dbHandler.Loadchequeno(txtNo, m_sbQueryText.ToString());
                    lblamount.Visible = lblDate.Visible = lblPay.Visible = true;
                    txtAmmount.Visible = datChequeDate.Visible = txtPay.Visible = true;
                    txtAmmount.Text = nm.changeCurrencyToWords(lblAmmount.Text.ToString());
                    txtPay.Text = lkeCompany.Text.ToString();

                }
                else {
                    lblamount.Visible = lblDate.Visible = lblPay.Visible = false;
                    txtAmmount.Visible = datChequeDate.Visible = txtPay.Visible = false;
                }

            }
            else {
                lblNO.Visible = txtNo.Visible = false;
                lblamount.Visible = lblDate.Visible = lblPay.Visible = false;
                txtAmmount.Visible = datChequeDate.Visible = txtPay.Visible = false;
            }
        }