Esempio n. 1
0
        private NotificationSMS FormatInvoiceSms(NotificationInvoice noti)
        {
            var sms = new NotificationSMS();
            sms.HubId = noti.DistributorId;
            sms.Recipitents = GetPhoneNumber(new List<Guid> { noti.DistributorId, noti.SalemanId, noti.OutletId });// new List<string> { "254722557538" };
            sms.SmsBody = "Invoice " + noti.DocumentRef + "\n"
                + "of Vat AMT=" + noti.TotalVat + ",\n"
                + "Discount  AMT=" + noti.SalevalueDiscount + ",\n"
                + "Gross AMT=" + noti.TotalGross + ",\n"
                + "and  Net AMT=" + noti.TotalNet + "\nStatus= Approved ";

            return sms;
        }
Esempio n. 2
0
        private MailMessage FormatInvoice(NotificationInvoice notification)
        {
            var distributor = _costCentreRepository.GetById(notification.DistributorId);
            var salesman = _costCentreRepository.GetById(notification.SalemanId);
            var outlet = _costCentreRepository.GetById(notification.OutletId);
            if (outlet == null || distributor == null || salesman == null)
                throw new Exception("Invalid distributor , salesman or outlet");
            var msg = new MailMessage();
            GetAddresses(distributor.Id).ForEach(msg.To.Add);
            GetAddresses(salesman.Id).ForEach(msg.To.Add);
            GetAddresses(outlet.Id).ForEach(msg.To.Add);
           // msg.To.Add("*****@*****.**");


            if (msg.To.Count == 0) return null;
            msg.Subject = string.Format("Invoice {0} Notification", notification.DocumentRef);
            msg.IsBodyHtml = true;
            string html = "<div>";
            html += "</br><table >";
            html += "<thead><tr><th>Item</th><th>Quantity</th><th>UnitPrice</th><th>VAT</th><th>Discount</th><th>Total Gross</th><th>Total Net</th></tr></thead>";
            foreach (var item in notification.Items)
            {
                html += string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td></tr>", item.ItemName, item.Quantity, item.UnitPrice, item.TotalVat, item.Discount, item.TotalGross, item.TotalNet);
            }
            html += " </table>";

            string body = string.Empty;
            using (StreamReader reader = new StreamReader("service/resources/invoiceEmailTemplate.htm"))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Distributor}", distributor.Name);
            body = body.Replace("{Salesman}", salesman.Name);
            body = body.Replace("{Outlet}", outlet.Name);
            body = body.Replace("{SalevalueDiscount}", notification.SalevalueDiscount.ToString("N2"));
            body = body.Replace("{TotalVat}", notification.TotalVat.ToString("N2"));
            body = body.Replace("{TotalNet}", notification.TotalNet.ToString("N2"));
            body = body.Replace("{TotalGross}", notification.TotalGross.ToString("N2"));
            body = body.Replace("{OrderRef}", notification.OrderRef);
            body = body.Replace("{DocumentRef}", notification.DocumentRef);


            body = body.Replace("{Items}", html);

            msg.Body = body;
            return msg;
        }