示例#1
0
        public CombinedSalesComparer(DateTime startdate, DateTime enddate, bool compare)
        {
            db = new BettingSuiteDataContext();
            //get available sales for both shop and master in the date range
            List <master_daily_sale> mastersalesList = db.master_daily_sales.Where(a => a.date >= startdate && a.date <= enddate).ToList <master_daily_sale>();

            if (compare)
            {
                shopsalesList = db.shop_daily_sales.Where(a => a.date >= startdate && a.date <= enddate).ToList <shop_daily_sale>();
            }
            //get all the available shops
            List <shop> shops = db.shops.ToList <shop>();

            foreach (shop shop in shops)
            {
                List <master_daily_sale> mlist = mastersalesList.Where(a => a.shop1 == shop).ToList <master_daily_sale>();
                if (compare)
                {
                    List <shop_daily_sale> slist = shopsalesList.Where(a => a.shop1 == shop).ToList <shop_daily_sale>();
                    SalesCombiner          sc    = new SalesCombiner(mlist, slist, shop);
                    sc.computeSales();
                    sclist_.Add(sc);
                }
                else
                {
                    SalesCombiner sc = new SalesCombiner(mlist, shop);
                    sc.computeSales();
                    sclist_.Add(sc);
                }
            }
        }
示例#2
0
        private bool savePaymentDetails(PaymentNotificationRequestHelper pnr)
        {
            BettingSuiteDataContext db = new BettingSuiteDataContext();

            if (iSNotDuplicate(pnr.getPaymentLogId(), db))
            {
                try
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        PaymentNotificationRequest pr = setPaymentRequestObjAndSave(pnr, db);
                        shop shop = new CRUD.shop_crud().find_shop_By_ID(pr.CustReference);
                        foreach (PaymentItemHelper it in pnr.getPaymentItems())
                        {
                            if (it.getItemCode().Equals(ConfigurationManager.AppSettings["SalesCode"].ToString()))
                            {
                                AddSalesTransaction(shop, pr, db);
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["LEASE DEBT"].ToString()))
                            {
                                //do lease debt lodgement
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["OPERATIONAL DEBT"].ToString()))
                            {
                                //do operational debt lodgement
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["ONLINE AGENCY"].ToString()))
                            {
                                //send online dept updates on online agency
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["ONLINE USER"].ToString()))
                            {
                                //send online dept updates on online user
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["PAYMENT COMMISION"].ToString()))
                            {
                                //futute implementation
                            }
                            else
                            {
                                //send acknologement message of payments
                            }
                        }

                        db.SubmitChanges();
                        scope.Complete();

                        return(true);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else
            {
            }
            return(false);
        }
示例#3
0
        public void loadStream(string x)
        {
            //if (Request.ContentType == "text/xml" || Request.ContentType == "text/plain" || Request.ContentType == "text/html"|| Request.ContentType == "application/xml")
            //{

            XDocument doc      = null;;
            XDocument xmlInput = XDocument.Parse(x);
            IEnumerable <XElement> requests = xmlInput.Elements();
            //initialize to objects and process then return request;
            string root = xmlInput.Root.Name.ToString();

            if (root.Contains("Customer"))
            {
                doc = generateCustomerValidationRequests(doc, requests);
            }
            else if (root.Contains("PaymentNotificationRequest"))
            {
                payment_request req = new payment_request {
                    request = x, date = DateTime.Now
                };
                BettingSuiteDataContext db = new BettingSuiteDataContext();
                db.payment_requests.InsertOnSubmit(req);
                db.SubmitChanges();

                var paymentrequests = xmlInput.Descendants("Payment").ToList();
                doc = generatePaymentNotificationRequests(doc, paymentrequests);
            }

            sendResponse(doc);
            // }

            //}
        }
示例#4
0
        private void AddSalesTransaction(shop shop, PaymentNotificationRequest pnr, BettingSuiteDataContext db)
        {
            int tt = db.transaction_categories.Single(a => a.code.Equals("L")).id;

            if (pnr.isReversal)
            {
                tt = db.transaction_categories.Single(a => a.code.Equals("LR")).id;
            }
            transaction_category selectedtran = db.transaction_categories.SingleOrDefault(a => a.id == tt);

            //string[] MDS = {"S", "W", "C", "SR", "WR","CR"};

            string[] MLR = { "L", "R", "LR", "RR" };
            string[] LPT = { "LP", "LPR" };

            if (MLR.Contains(selectedtran.code))
            {
                decimal amount = new decimal(null);
                AddnewLodgementReimbursementTransaction(shop, selectedtran, pnr, db, amount);
            }

            else
            {
            }
        }
示例#5
0
        private XDocument ProcessCustomerValidationRequestsAndGetResponse(List <CustomerValidationRequest> cvrequests)
        {
            BettingSuiteDataContext           db                 = new BettingSuiteDataContext();
            List <CustomerValidationResponse> cvresponses        = new List <CustomerValidationResponse>(cvrequests.Count());
            List <CustomerValidationResponse> invalidcvresponses = new List <CustomerValidationResponse>(cvrequests.Count());

            foreach (CustomerValidationRequest cvr in cvrequests)
            {
                int      refr     = int.Parse(cvr.getCustReference().Substring(1));
                customer customer = null;

                //check Type of customer
                if (cvr.getCustReference().StartsWith(ConfigurationManager.AppSettings["AGENT PREFIX"]))
                {
                    shop shop = db.shops.SingleOrDefault(a => a.id == refr);
                    if (shop != null)
                    {
                        customer = new customer(shop);
                        customer.setPrefix(cvr.getCustReference().ElementAt(0).ToString());
                        if (customer.getReference() != refr)
                        {
                            customer = null;
                        }
                    }
                    else
                    {
                        customer = null;
                    }


                    if (customer != null)
                    {
                        // customer.setPaymentItem(cvr.getPaymentItemCode());
                        CustomerValidationResponse cr = new CustomerValidationResponse(customer, cvr.getMerchantReference());
                        cvresponses.Add(cr);
                    }
                    else
                    {
                        customer = new customer(null, null, null, null, null, null, 1);
                        customer.setPrefix(cvr.getCustReference().ElementAt(0).ToString());
                        customer.setReference(refr);
                        CustomerValidationResponse icr = new CustomerValidationResponse(customer, cvr.getMerchantReference());
                        invalidcvresponses.Add(icr);
                    }
                }
                else
                {
                    // Implement Online Users Later
                    customer = new customer(null, null, null, null, null, null, 1);
                    // customer.setPrefix(cvr.getCustReference().ElementAt(0).ToString());
                    customer.setReference(refr);
                    CustomerValidationResponse icr = new CustomerValidationResponse(customer, cvr.getMerchantReference());
                    invalidcvresponses.Add(icr);
                }
            }
            return(generateCustomerValidationResponse(cvresponses, invalidcvresponses));
        }
示例#6
0
        public application Application(BettingSuiteDataContext db)
        {
            application app = new application
            {
                app_id = Guid.NewGuid().ToString()
            };

            db.applications.InsertOnSubmit(app);
            return(app);
        }
示例#7
0
        private bool iSNotDuplicate(int paymentID, BettingSuiteDataContext db)
        {
            PaymentNotificationRequest pr = db.PaymentNotificationRequests.SingleOrDefault(a => a.PaymentLogId == paymentID);

            if (pr != null)
            {
                return(false);
            }
            return(true);
        }
示例#8
0
        private void AddDebtTransaction(shop shop, PaymentNotificationRequest pr, BettingSuiteDataContext db)
        {
            try
            {
                List <debt> debts = new CRUD.debt_crud().getShopdebts(shop, null);

                if (debts != null && debts.Count > 0)
                {
                    decimal amount = lodgeDebt(debts, pr.Amount, shop.master_balance_sheets[0]);
                    if (amount > 0)
                    {
                        transaction_category saleslodge = db.transaction_categories.SingleOrDefault(a => a.code == "L");
                        //amount = LodgeSales(shop, amount, shop.master_balance_sheets[0]);
                        AddnewLodgementReimbursementTransaction(shop, saleslodge, pr, db, amount);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#9
0
        private void AddnewLodgementReimbursementTransaction(shop shop, transaction_category tran, PaymentNotificationRequest pnr, BettingSuiteDataContext db)
        {
            DateTime             date          = DateTime.Today;
            master_balance_sheet masterbalance = new CRUD.master_balance_sheet_crud().getMasterBalanceByShopId(shop.id);

            if (masterbalance == null)
            {
                masterbalance = new master_balance_sheet
                {
                    shop           = shop.id,
                    credit_balance = 0,
                    online_credit  = 0,
                    sales_balance  = 0,
                    netbalance     = 0,
                };
                masterbalance = new CRUD.master_balance_sheet_crud(masterbalance).insert_master_balance_sheet();
            }

            master_transaction reversalmastertransaction = new master_transaction();


            master_lodgement_reimbursment newmlr = new master_lodgement_reimbursment
            {
                amount               = pnr.Amount,
                bank                 = 0,//interswitch id,
                date                 = date,
                shop                 = shop.id,
                teller_number        = pnr.PaymentLogId.ToString(),
                islocked             = true,
                isverified           = true,
                payment_type         = 5,
                transaction_category = tran.id,
            };

            login lodin = db.logins.Single(a => a.username == "InterSwitch");
            master_transaction newmastertransaction = new master_transaction
            {
                amount          = Math.Abs(pnr.Amount),
                balance_before  = (masterbalance != null) ? masterbalance.sales_balance : 0,
                balance_after   = (masterbalance != null) ? getbal(masterbalance.sales_balance, pnr.Amount, tran) : pnr.Amount,
                shop            = shop.id,
                trans_category  = tran.id,
                trans_timestamp = DateTime.Now,
                trans_type      = (tran.type == true) ? 1 : 0,
                posted_by       = lodin.id,// interswitch id,
                description     = pnr.PaymentReference + " Posted For " + date.ToShortDateString(),
                details         = (tran.code == "L") ? "Lodgement For " + date.ToShortDateString() : "Lodgement Reversal For " + date.ToShortDateString()
            };

            masterbalance.sales_balance = (masterbalance != null) ? getbal(masterbalance.sales_balance, newmastertransaction.amount, tran) : newmastertransaction.amount;
            masterbalance.netbalance    = (masterbalance != null) ? getbal(masterbalance.netbalance, newmastertransaction.amount, tran) : newmastertransaction.amount;

            bool loadtran = new Utilities.TransactionHelper().SaveMasterLodgementTransaction(newmlr, newmastertransaction, masterbalance);

            if (loadtran)
            {
                try
                {
                    bool mailvalidity = new Utilities.Mail_Validity_Helper().getMailSendingStatus();
                    SMS_Vendor_Validity_Helper valhelp = new SMS_Vendor_Validity_Helper();
                    sms_vendor vendor = valhelp.getVendorsByName("50kobo");

                    bool smsvalidity = (DateTime.Today <= vendor.expiry_date) ? true : false;

                    if (newmlr.bank1.code != "CASH")
                    {
                        sms message;
                        if (tran.code == "L")
                        {
                            if (smsvalidity)
                            {
                                sm mm = new CRUD.sms_crud().findByCode("CA");
                                message = new sms();

                                if (message.initializeParameters(shop, mm.subject.Trim() + "\r\n" + mm.content.Trim() + "\r\n" + mm.conclusion.Trim(), newmlr))
                                {
                                    message.CustomizeAndSendSMS();
                                }
                            }
                            if (mailvalidity)
                            {
                                mail       mail   = new CRUD.mail_crud().findByCode("LA");
                                MailClient client = new MailClient();
                                client.SendLodgementReimbursementMail(shop, mail, newmastertransaction);
                            }
                        }
                        else if (tran.code == "R")
                        {
                            if (smsvalidity)
                            {
                                sm mm = new CRUD.sms_crud().findByCode("DA");
                                message = new sms();
                                if (message.initializeParameters(shop, mm.subject + "\r\n" + mm.content + "\r\n" + mm.conclusion, newmlr))
                                {
                                    message.CustomizeAndSendSMS();
                                }
                            }
                            if (mailvalidity)
                            {
                                mail       mail   = new CRUD.mail_crud().findByCode("RA");
                                MailClient client = new MailClient();
                                client.SendLodgementReimbursementMail(shop, mail, newmastertransaction);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
            else
            {
            }
        }
示例#10
0
 private PaymentNotificationRequest setPaymentRequestObjAndSave(PaymentNotificationRequestHelper pnr, BettingSuiteDataContext db)
 {
     try
     {
         PaymentNotificationRequest newpr = new PaymentNotificationRequest();
         newpr.Amount                   = Math.Abs(pnr.getAmount());
         newpr.BankCode                 = pnr.getBankCode();
         newpr.BankName                 = pnr.getBankName();
         newpr.BranchName               = pnr.getBranchName();
         newpr.CategoryCode             = pnr.getCategoryCode();
         newpr.CategoryName             = pnr.getCategoyName();
         newpr.ChannelName              = pnr.getChannelName();
         newpr.CollectionsAccount       = pnr.getCollectionsAccount();
         newpr.CustomerAddress          = pnr.getCustomerAddress();
         newpr.CustomerName             = pnr.getCustomerName();
         newpr.CustomerPhoneNumber      = pnr.getCustomerPhoneNumber();
         newpr.CustReference            = int.Parse(pnr.getCustReference().Substring(1));
         newpr.DepositorName            = pnr.getDepositorName();
         newpr.FeeName                  = pnr.getFeeName();
         newpr.FTPPassword              = pnr.getFTPPassword();
         newpr.FTPUsername              = pnr.getFTPUsername();
         newpr.InstitutionId            = pnr.getInstitutionID();
         newpr.InstitutionName          = pnr.getInstitutionName();
         newpr.isReversal               = pnr.isReversal();
         newpr.Location                 = pnr.getLocation();
         newpr.OriginalPaymentLogid     = pnr.getOriginalPaymentLogId();
         newpr.OriginalPaymentName      = pnr.getOriginalPaymentName();
         newpr.OriginalPaymentReference = pnr.getOriginalPaymentReference();
         newpr.OtherCustomerInfo        = pnr.getOtherCustomerInfo();
         newpr.PaymentCurrency          = pnr.getPaymentCurrency();
         newpr.PaymentDate              = pnr.getPaymentDate();
         newpr.PaymentLogId             = pnr.getPaymentLogId();
         newpr.PaymentMethod            = pnr.getPaymentMethod();
         newpr.PaymentReference         = pnr.getPaymentReference();
         newpr.PaymentStatus            = pnr.getPaymentStatus();
         newpr.ServicePassword          = pnr.getServicePassword();
         newpr.ServiceUsername          = pnr.getServiceUsername();
         newpr.SettlementDate           = pnr.getSettlementDate();
         List <PaymentItem>       pItems = null;
         List <PaymentItemHelper> phs    = pnr.getPaymentItems();
         // List<Item> t = db.Items.ToList<Item>();
         if (phs.Count > 0)
         {
             pItems = new List <PaymentItem>();
             foreach (PaymentItemHelper pay in phs)
             {
                 PaymentItem p = new PaymentItem();
                 p.ItemAmount      = pay.getItemAmount();
                 p.LeadBankCbnCode = pay.getLeadBankCbnCode();
                 p.LeadBankCode    = pay.getLeadBankCode();
                 p.LeadBankName    = pay.getLeadBankName();
                 p.Item            = db.Items.SingleOrDefault(a => a.code.Equals(pay.getItemCode())).id;
                 pItems.Add(p);
                 // setItemCodeLater
             }
             db.PaymentItems.InsertAllOnSubmit(pItems);
             db.PaymentNotificationRequests.InsertOnSubmit(newpr);
         }
         return(newpr);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
示例#11
0
        private XDocument ProcessNotificationRequestsAndGetResponse(List <PaymentNotificationRequestHelper> pnrequests)
        {
            BettingSuiteDataContext            db          = new BettingSuiteDataContext();
            List <PaymentNotificationResponse> pnresponses = new List <PaymentNotificationResponse>(pnrequests.Count());

            // List<PaymentNotificationResponse> invalidpnresponses = new List<PaymentNotificationResponse>(pnrequests.Count());
            foreach (PaymentNotificationRequestHelper pnr in pnrequests)
            {
                int      refr     = int.Parse(pnr.getCustReference().Substring(1));
                customer customer = null;
                //check Type of customer
                if (pnr.getCustReference().StartsWith(ConfigurationManager.AppSettings["AGENT PREFIX"]))
                {
                    shop shop = db.shops.SingleOrDefault(a => a.id == refr);
                    if (shop != null)
                    {
                        customer = new customer(shop);
                        if (customer.getReference() != refr)
                        {
                            customer = null;
                        }
                    }
                    else
                    {
                        customer = null;
                    }


                    if (customer != null)
                    {
                        // customer.setPaymentItem(cvr.getPaymentItemCode());
                        PaymentNotificationResponse pr = new PaymentNotificationResponse(customer, pnr);
                        pr.setStatus(0);
                        savePaymentDetails(pnr);
                        pr.setPaymentLogId(pnr.getPaymentLogId().ToString());
                        pnresponses.Add(pr);
                    }
                    else
                    {
                        customer = new customer(null, null, null, null, null, null, 1);
                        customer.setReference(refr);
                        PaymentNotificationResponse ipr = new PaymentNotificationResponse(customer, pnr);
                        ipr.setStatus(1);
                        pnresponses.Add(ipr);
                    }
                }
                else if (pnr.getCustReference().StartsWith(ConfigurationManager.AppSettings["ONLINE USER PREFIX"]))
                {
                    // SORT OUT ONLINE LATER
                }

                else
                {
                    customer = new customer(null, null, null, null, null, null, 1);
                    customer.setReference(refr);
                    PaymentNotificationResponse ipr = new PaymentNotificationResponse(customer, pnr);
                    ipr.setStatus(1);
                    pnresponses.Add(ipr);
                }
            }
            return(generatePaymentNotificationResponse(pnresponses));
        }
示例#12
0
        private bool savePaymentDetails(PaymentNotificationRequestHelper pnr)
        {
            BettingSuiteDataContext db = new BettingSuiteDataContext();

            if (iSNotDuplicate(pnr.getPaymentLogId(), db))
            {
                try
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        PaymentNotificationRequest pr = setPaymentRequestObjAndSave(pnr, db);
                        shop shop = new CRUD.shop_crud().find_shop_By_ID(pr.CustReference);
                        foreach (PaymentItemHelper it in pnr.getPaymentItems())
                        {
                            if (it.getItemCode().Equals(ConfigurationManager.AppSettings["SalesCode"].ToString()))
                            {
                                AddSalesTransaction(shop, pr, db);
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["LeaseDebtCode"].ToString()))
                            {
                                AddDebtTransaction(shop, pr, db);
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["OperationalDebtCode"].ToString()))
                            {
                                AddDebtTransaction(shop, pr, db);
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["Online Agency"].ToString()))
                            {
                                //sendmail
                                MailClient mc   = new MailClient();
                                mail       mail = new CRUD.mail_crud().findByCode("OL");
                                string     body = mail.content;
                                body = body.Replace("{shop_code}", shop.shop_code);
                                body = body.Replace("{account_name}", pnr.getCustomerName());
                                body = body.Replace("{amount}", "₦" + pr.Amount.ToString());
                                body = body.Replace("{amount_to_lodge}", "₦" + (decimal.Multiply(pr.Amount, decimal.Parse("1.10"))).ToString());
                                body = body.Replace("{payment_method}", "InterSwitch");

                                mc.SendBulkMail(ConfigurationManager.AppSettings["ONLINE SENDING MAIL"].ToString(), shop.shop_code + " (₦" + pr.Amount.ToString() + ") ", body);
                                //send sms to agent
                                SMS_Vendor_Validity_Helper valhelp = new SMS_Vendor_Validity_Helper();
                                sms_vendor vendor = valhelp.getVendorsByName("50kobo");

                                bool smsvalidity = (DateTime.Today <= vendor.expiry_date) ? true : false;

                                if (smsvalidity)
                                {
                                    sms message = new sms();
                                    if (message.initializeParameters(shop, "Online Lodgement Confirmation" + "\r\n" + "Your lodgement of " + pr.Amount.ToString() + " for online agency has being confirmed. You would be credited with " + (decimal.Multiply(pr.Amount, decimal.Parse("1.10"))).ToString() + "\r\n" + "", pr.PaymentDate))
                                    {
                                        message.CustomizeAndSendSMS();
                                    }
                                }
                                //send online dept updates on online user
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["Online User"].ToString()))
                            {
                            }
                            else if (it.getItemCode().Equals(ConfigurationManager.AppSettings["Payment Commision"].ToString()))
                            {
                                //futute implementation
                            }
                            else
                            {
                                SMS_Vendor_Validity_Helper valhelp = new SMS_Vendor_Validity_Helper();
                                sms_vendor vendor = valhelp.getVendorsByName("50kobo");

                                bool smsvalidity = (DateTime.Today <= vendor.expiry_date) ? true : false;

                                if (smsvalidity)
                                {
                                    sms message = new sms();
                                    if (message.initializeParameters(shop, "Payment Confirmation" + "\r\n" + "Your lodgement of " + pr.Amount.ToString() + " for " + it.getItemName() + " has being confirmed and would be processed shortly" + "\r\n" + "call 014609630 for info/complaints", pr.PaymentDate))
                                    {
                                        message.CustomizeAndSendSMS();
                                    }
                                }
                            }
                        }

                        db.SubmitChanges();
                        scope.Complete();

                        return(true);
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }
            else
            {
            }
            return(false);
        }