public void should_Fail_Generate_Invoice()
        {
            var command = new GenerateInvoice("INV001", "AmmountDue:2000|Period:2019Jan01|CallCharge:1900|Tax:100");

            var result = _mediator.Send(command).Result;

            Assert.True(result.IsFailure);
            Assert.False(TestInitializer.Events.OfType <InvoiceGenerated>().Any());
        }
Exemple #2
0
        public void GenerateInvoice_Header()
        {
            var             idUser    = 1;
            var             idInvoice = 13;
            var             invoiceNr = "10";
            GenerateInvoice test      = new GenerateInvoice(idUser, idInvoice, invoiceNr);

            test.header();
            Assert.IsTrue(!string.IsNullOrEmpty(test._stringWriter.ToString()));
        }
Exemple #3
0
        public void GenerateInvoice_Products()
        {
            var             idUser    = 1;
            var             idInvoice = 13;
            var             invoiceNr = "10";
            GenerateInvoice test      = new GenerateInvoice(idUser, idInvoice, invoiceNr);

            test.products();
            bool html = test._stringWriter.ToString().Contains("Cena netto");

            Assert.IsTrue(html);
        }
Exemple #4
0
        public void GenerateInvoice_Persons()
        {
            var             idUser    = 1;
            var             idInvoice = 13;
            var             invoiceNr = "10";
            GenerateInvoice test      = new GenerateInvoice(idUser, idInvoice, invoiceNr);

            test.persons();
            bool html = test._stringWriter.ToString().Contains("Kupujący");

            Assert.IsTrue(html);
        }
Exemple #5
0
        public void GenerateInvoice_Head()
        {
            var             idUser    = 1;
            var             idInvoice = 13;
            var             invoiceNr = "10";
            GenerateInvoice test      = new GenerateInvoice(idUser, idInvoice, invoiceNr);

            test.head();
            bool html = test._stringWriter.ToString().Contains("Typ dokumentu");

            Assert.IsTrue(html);
        }
Exemple #6
0
        public void GenerateInvoice_InitializeObject_ReturnInvoiceObject()
        {
            var idUser           = 1;
            var idInvoice        = 13;
            var invoiceNr        = "10";
            var invoiceGenerator = new GenerateInvoice(idUser, idInvoice, invoiceNr);

            Assert.AreEqual(invoiceGenerator._idInvoice, idInvoice);
            Assert.AreEqual(invoiceGenerator._idUser, idUser);
            Assert.AreEqual(invoiceGenerator._idInvoice, idInvoice);
            Assert.IsNotNull(invoiceGenerator._idContractor);
            Assert.IsNotNull(invoiceGenerator._stringWriter);
            Assert.IsNotNull(invoiceGenerator._writer);
        }
        //[Authorize(Roles = "Admin,Client,Employee")]
        public ActionResult Index(GenerateInvoice GenerateInvoice, string[] ItemId, string[] ItemType, string[] ItemDescription, string[] Unit, string[] UnitPrice, string[] ItemDuration, string[] Actions, string[] ActionTax,
                                  Int64[] Taxation, Int64[] TaxationId, float[] TaxactionAmount, string[] CalculatedTax, float NetAmount = 0, float AdditionalCost = 0, float Deductions = 0, float GrandTotal = 0)
        {
            string        body        = "";
            UserViewModel userDetails = generic.GetUserDetail(User.Identity.GetUserId());

            ViewData["UserProfile"]      = userDetails;
            GenerateInvoice.SubscriberId = userDetails.SubscriberId;
            GenerateInvoice.CorporateId  = userDetails.UserId;
            GenerateInvoice.Status       = "Submitted";
            GenerateInvoice.Acknowledge  = false;
            GenerateInvoice.Total        = NetAmount;
            GenerateInvoice.NetAmount    = GrandTotal;

            if (string.IsNullOrEmpty(GenerateInvoice.InvoiceNumber))
            {
                body = "Invoice has been created Invoice No. ";
            }
            else
            {
                body = "Invoice has been edited Invoice No. ";
            }

            if (GenerateInvoice.InvoiceNumber == null)
            {
                GenerateInvoice.InvoiceNumber = admin.GetInvoiceNumber();
            }


            var result = admin.AddInvoice(GenerateInvoice, ItemId, ItemType, ItemDescription, Unit, UnitPrice, ItemDuration, Actions, Taxation, CalculatedTax, ActionTax);

            admin.AddNotification(userDetails.SubscriberId, userDetails.UserId, body + GenerateInvoice.InvoiceNumber + " From ", "INVOICE", GenerateInvoice.InvoiceNumber, false, DateTime.Now);

            if (result == true)
            {
                if (!string.IsNullOrEmpty(GenerateInvoice.ReferenceId))
                {
                    foreach (string file in Request.Files)
                    {
                        HttpPostedFileBase attachment = Request.Files[file] as HttpPostedFileBase;
                        admin.uploadInvFile(GenerateInvoice.ReferenceId, attachment);
                    }
                }
            }
            string message1 = "You have received an Invoice (" + GenerateInvoice.InvoiceNumber + ") from " + userDetails.Name; //eg "message hello ";

            //   generic.sendSMSMessage(message1, generic.GetUserDetail(userDetails.SubscriberId).PhoneNumber);
            generic.sendSMS(message1, generic.GetUserDetail(userDetails.SubscriberId).PhoneNumber);
            return(RedirectToAction("MyInvoices", "Invoice", new { area = "CMS", data = result }));
        }
        public static void CreatePdfDocumentFromSerializedString(String pdfMs)
        {
            if (String.IsNullOrEmpty(pdfMs))
                return;

            GenerateInvoice invoice = new GenerateInvoice();
            invoice = (GenerateInvoice)JsonConvert.DeserializeObject(pdfMs, invoice.GetType());

            String defaultFilePath = ConfigurationManager.AppSettings["PDFFilePath"];
            Guid guid = Guid.NewGuid();
            String fileName = defaultFilePath + guid.ToString() + ".pdf";
            byte[] bytes = Convert.FromBase64String(invoice.InvoiceString);
            FileStream fs = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write, FileShare.None);
            fs.Write(bytes, 0, bytes.Length);
            fs.Close();
        }
Exemple #9
0
        public void GenerateInvoice_GenerateFileOnFileSystem_ThrowError()
        {
            var             idUser    = 1;
            var             idInvoice = 13;
            var             invoiceNr = "10";
            GenerateInvoice test      = new GenerateInvoice(idUser, idInvoice, invoiceNr);
            string          file      = null;

            try
            {
                file = test.generateFile();
                Assert.Fail("Shouldn't run on file system!");
            }
            catch
            {
                Assert.IsTrue(string.IsNullOrEmpty(file));
            }
        }
Exemple #10
0
 public GenerateFP(InvType typeFP)
 {
     this.log        = LogUtil.GetLogger <GenerateFP>();
     this.fptkBLL    = new FPTKdal();
     this.billBL     = SaleBillCtrl.Instance;
     this.generBL    = GenerateInvoice.Instance;
     this.taxCard    = TaxCardFactory.CreateTaxCard();
     this.IsNewJDC   = false;
     this.NPCType    = 0;
     this.components = null;
     this.FPleftnum  = 0;
     this.Initialize();
     base.StartPosition  = FormStartPosition.CenterScreen;
     this.fpType         = typeFP;
     this.FPType_Card    = (InvoiceType)this.fpType;
     this.djType         = CommonTool.GetInvTypeStr(typeFP);
     this.lableFPZL.Text = ShowString.ShowFPZL(this.djType);
     this.FPleftnum      = (int)this.taxCard.GetInvNumber(this.FPType_Card);
 }
Exemple #11
0
 public GenerateInvoiceTest()
 {
     _freightMock = new Mock <IFreight>();
     _freightSearchStrategyMock = new Mock <IFreightSearchStrategy>();
     _genereteInvoice           = new GenerateInvoice(_freightMock.Object, _freightSearchStrategyMock.Object);
 }