Exemple #1
0
        public void AddInvoice()
        {
            var invoice = new InvoiceModel()
            {
                CustomerId = 1,
                EmployeeId = 1,
                SaleDate   = DateTime.UtcNow,
            };
            var invoiceItems = new List <InvoiceItems>();
            var item         = new InvoiceItems()
            {
                ItemId    = 1,
                UnitPrice = 10,
                Quantity  = 2
            };

            invoiceItems.Add(item);
            invoice.InvoiceItemses = invoiceItems;
            var totalCost = 0d;

            foreach (var i in invoiceItems)
            {
                totalCost += i.TotalPrice;
            }

            invoice.TotalAmount = totalCost.ToString();
            Invoice.AddInvoice(invoice);
            var invoiceService = new InvoiceService();
            var invoicePath    = invoiceService.ConstructInvoicePdf(invoice);

            var emailHelper = new EmailHelper();

            emailHelper.SendInvoiceMail(invoice, invoicePath);
        }
        public async Task AddInvoice(InvoiceModel invoice)
        {
            invoice.ModeOfPaymentString = Enum.GetName(typeof(ModeOfPaymentEnum), invoice.ModeOfPayment);
            var invoiceId = await Invoice.AddInvoice(invoice);

            invoice.Id = invoiceId;
            var invoicePath = ConstructInvoicePdf(invoice);

            var isSendEmailInvoice = Settings.GetSetting(Constants.IsInvoiceSendInEmailSetting).Value;

            bool.TryParse(isSendEmailInvoice, out var isSendMailForInvoice);

            var isSendSmsInvoice = Settings.GetSetting(Constants.IsInvoiceSendInSms).Value;

            bool.TryParse(isSendSmsInvoice, out var isSendSmsForInvoice);

            invoice.Customer = Customer.GetCustomer(invoice.CustomerId);
            if (isSendMailForInvoice && !string.IsNullOrEmpty(invoice.Customer?.EmailId))
            {
                var emailHelper = new EmailHelper();
                emailHelper.SendInvoiceMail(invoice, invoicePath);
            }
            else if (isSendSmsForInvoice && !string.IsNullOrEmpty(invoice.Customer?.PhoneNumber))
            {
                var smsService = new SmsService();
                smsService.SendInvoiceSms(invoice);
            }
        }
        public void CreateInvoice()
        {
            TestData Data = DataManager.GetTestData("InvoiceData", DataRandomToken, TestRunNum);

            Login login = new Login(this.DriverManager);

            login.OpenApp().LogIn(Data.Get("Login"));

            Dashboard dashboard = new Dashboard(this.DriverManager);

            dashboard.OpenSideMenu("Client Central").OpenMenu("Invoices");

            Invoice invoice = new Invoice(this.DriverManager);

            invoice.OpenNewInvoiceWindow();
            invoice.AddInvoice(Data, "111");
        }
 public static void Save_Invoice(InvoiceForm f)
 {
     //save Invoice
     try
     {
         if (f.bunifuDatepicker1.Value != null && (f.Textbox1ID.Text != "" || f.Textbox1ID.Text != null))
         {
             //save Invoiec
             int      InvID       = int.Parse(f.Textbox1ID.Text);
             DateTime InvDate     = f.bunifuDatepicker1.Value;
             int      InvSupplier = int.Parse(f.comboBox1.SelectedValue.ToString());
             Invoice  inv         = new Invoice(InvID, InvDate, InvSupplier);
             inv.AddInvoice(dt);
             //save InvoiceDetails
             InvoiceDetails invDetails;
             foreach (DataGridViewRow r in f.dataGridView11.Rows)
             {
                 string MedecineID = r.Cells["ProductID"].Value.ToString();
                 string VAT        = r.Cells["VAT"].Value.ToString();
                 string Price      = r.Cells["Price"].Value.ToString();
                 string Discount   = r.Cells["Discount"].Value.ToString();
                 string quantity   = r.Cells["Quantity"].Value.ToString();
                 string expiryDate = r.Cells["Date"].Value.ToString();
                 invDetails = new InvoiceDetails(MedecineID, InvID, quantity, Price, VAT.Replace("%", ""), expiryDate, Discount.Replace("%", ""));
                 invDetails.AddInvoiceDetails(dt);
                 Stocks.UpdateStocks(dt, int.Parse(MedecineID), int.Parse(quantity));
             }
         }
         else
         {
             MessageBox.Show("Please Fill ID and Date ");
         }
     }
     catch
     {
         //ADD DELETE FUNCTION
         MessageBox.Show("ERROR!!");
     }
 }
Exemple #5
0
 //Metods
 public void AddInvoice(Invoice invoice)
 {
     invoice.AddInvoice(invoice.Order, invoice.DateOfDelivery, invoice.FormOfDelivery, invoice.FormOfPayment);
 }