private MailMessage FormatReceipt(NotificationReceipt 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("Reciept {0} Notification", notification.DocumentRef);
            msg.IsBodyHtml = true;
            string html = "";
            foreach (var item in notification.Items)
            {
                html += string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td></tr>", item.ItemName, item.Reference, item.Description, item.Quantity);
            }
            string body = string.Empty;
            using (StreamReader reader = new StreamReader("service/resources/ReceiptEmailTemplate.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("{TotalGross}", notification.TotalAmount.ToString("N2"));
            body = body.Replace("{OrderRef}", notification.OrderRef);
            body = body.Replace("{DocumentRef}", notification.DocumentRef);
            body = body.Replace("{InvoiceRef}", notification.InvoiceRef);


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

            msg.Body = body;
            return msg;
        }
        private NotificationSMS FormatReceiptSms(NotificationReceipt 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 = "Receipt " + noti.DocumentRef + ",\n"
                + "OrderRef" + noti.OrderRef + ",\n"
                + "InvoiceRef=" + noti.InvoiceRef + ",\n"
                + "and Amount Paid=" + noti.TotalAmount.ToString("N2") + "\nStatus= Received ";

            return sms;
        }