Esempio n. 1
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);
        }
Esempio n. 2
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
            {
            }
        }
Esempio n. 3
0
        private bool iSNotDuplicate(int paymentID, BettingSuiteDataContext db)
        {
            PaymentNotificationRequest pr = db.PaymentNotificationRequests.SingleOrDefault(a => a.PaymentLogId == paymentID);

            if (pr != null)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 4
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)
            {
            }
        }
Esempio n. 5
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
            {
            }
        }
Esempio n. 6
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);
     }
 }
Esempio n. 7
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);
        }