Exemplo n.º 1
0
        public async Task <ActionResult> IndividualPaymentMethod(string id)
        {
            DomesticInvoicePaymentManager Mgr; bool offline;

            if (Request.IsAuthenticated && User.Identity.IsAuthenticated)
            {
                offline = false;
                Mgr     = new DomesticInvoicePaymentManager(Lang, UserManager.FindById(User.Identity.GetUserId()));
            }
            else
            {
                offline = true;
                Mgr     = new OfflineDomesticInvoicePaymentManager(Lang);
            }

            DomesticInvoice invoice = await Mgr.GetDomesticInvoice(id);

            if (invoice == null)
            {
                return(HttpNotFound());
            }

            if (invoice.IsPaid)
            {
                var resultMsg = IndividualPaidDomesticInvoice(id, offline);
                return(View("Warning", resultMsg));
            }

            ViewBag.Offline = offline;
            return(View(invoice));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> IndividualOnlineResponse(string InvoiceId)
        {
            DomesticInvoicePaymentManager Mgr; bool offline;

            if (Request.IsAuthenticated && User.Identity.IsAuthenticated)
            {
                offline = false;
                Mgr     = new DomesticInvoicePaymentManager(Lang, UserManager.FindById(User.Identity.GetUserId()));
            }
            else
            {
                offline = true;
                Mgr     = new OfflineDomesticInvoicePaymentManager(Lang);
            }
            ViewBag.Offline = offline;

            DomesticInvoice invoice = await Mgr.GetDomesticInvoice(InvoiceId);


            var paymentResponse = Mgr.GetPaymentResponse(Request.QueryString["id"].ToString());

            if (paymentResponse.Status == HyperPayStatus.Success)
            {
                // Add Succeed Transaction to LaborServices Db
                var transaction = Mgr.AddSuccessTransaction(invoice.CustomerId, invoice.Number, InvoiceId, invoice.InvoiceAmount.Value, paymentResponse);

                // Add reciept voucher & Update Invoice IsPaid Field
                var response = await Mgr.CreateReceiptVoucher(invoice);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    // success CRM voucher creation
                    transaction.IsVoucherSaved = true;
                    Mgr.UpdatePaymentTransaction(transaction);
                }
                else
                {
                    // fail CRM voucher creation
                    Mgr.SaveFailedReceiptVoucher(response.Result, transaction.Id);
                }
                // return success msg
                return(View("Success", IndividualSuccessOnlinePayment(InvoiceId, offline)));
            }
            else
            {
                // Add Failed Transaction to LaborServices Db
                Mgr.AddFailTransaction(invoice.CustomerId, invoice.Number, InvoiceId, invoice.InvoiceAmount.Value, paymentResponse);

                // return fail msg
                return(View("Failure", PaymentFailureMsg(InvoiceId, paymentResponse.Reason,
                                                         Url.Action("IndividualOnlinePayment", "Pay", new { id = InvoiceId, lang = LangCode }))));
            }
        }
        public DomesticInvoice GetDomesticInvoiceDetails(string id, UserLanguage Lang)
        {
            // =================================================

            //string[] columns = { CrmGuidFieldName, CrmDisplayFieldName, "new_indvcontractid", "new_paymentduedate" , "new_fromdate", "new_todate",
            //    "new_custamount", "new_totalamountwithvat", "new_paymenttype" , "new_ispaid", "new_customer"
            //};
            //var entity = GetCrmEntity(id, columns);


            //if (entity == null) return null;

            //return new DomesticInvoice(entity);

            // ===================================================

            string optionSetGetValFn, otherLangOptionSetGetValFn;

            switch (Lang)
            {
            case UserLanguage.Arabic:
                optionSetGetValFn          = "dbo.getOptionSetDisplay";
                otherLangOptionSetGetValFn = "dbo.getOptionSetDisplayen";
                break;

            default:
                optionSetGetValFn          = "dbo.getOptionSetDisplayen";
                otherLangOptionSetGetValFn = "dbo.getOptionSetDisplay";
                break;
            }

            var       query = String.Format(@" Select new_indvpaymentid , new_sabnumber , new_indvcontractid , new_paymentduedate, Convert(date, new_fromdate) as new_fromdate ,
                                                Convert(date, new_todate) as new_todate, new_custamount , 
                                               case when new_totalamountwithvat is null then (isnull(new_vatrate,0)*new_invoiceamount + new_invoiceamount) else new_totalamountwithvat end as new_totalamountwithvat, new_paymenttype,new_ispaid, new_customer, new_indvcontractidname , new_customername,
                                                Isnull({2}('new_paymenttype','{1}',new_paymenttype),{3}('new_paymenttype','{1}',new_paymenttype) ) as new_paymenttypename,
                                                contact.mobilephone, new_indvpayment.new_invoicenodays
                                         From new_indvpayment left outer join contact on contact.contactid =  new_indvpayment.new_customer
                                         Where new_indvpaymentid = '{0}'
                                       ", id, CrmEntityName, optionSetGetValFn, otherLangOptionSetGetValFn);
            DataTable dt    = CRMAccessDB.SelectQ(query).Tables[0];

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            var invoice = new DomesticInvoice(dt.Rows[0]);

            return(invoice);
        }
        public async Task <ActionResult> DomesticInvoice(string id)
        {
            DomesticInvoiceManager Mgr;
            ApplicationUser        u = UserManager.FindById(User.Identity.GetUserId());

            Mgr = new DomesticInvoiceManager(Lang, u);
            DomesticInvoice invoice = await Mgr.GetDomesticInvoiceDetails(id);

            if (invoice == null)
            {
                return(HttpNotFound());
            }

            return(View(invoice));
        }
Exemplo n.º 5
0
        public async Task <ActionResult> IndividualOnlinePayment(string id)
        {
            DomesticInvoicePaymentManager Mgr; bool offline;

            if (Request.IsAuthenticated && User.Identity.IsAuthenticated)
            {
                offline = false;
                Mgr     = new DomesticInvoicePaymentManager(Lang, UserManager.FindById(User.Identity.GetUserId()));
            }
            else
            {
                offline = true;
                Mgr     = new OfflineDomesticInvoicePaymentManager(Lang);
            }

            DomesticInvoice invoice = await Mgr.GetDomesticInvoice(id);

            //System.Globalization.CultureInfo enUS = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
            //DateTime tempdate;
            //string s = invoice.DueDate.Value.ToString("dd-MM-yyyy", enUS);
            //tempdate = DateTime.Parse(s);
            //invoice.DueDate = tempdate;
            if (invoice == null)
            {
                return(HttpNotFound());
            }

            if (invoice.IsPaid)
            {
                var resultMsg = IndividualPaidDomesticInvoice(id, offline);
                return(View("Warning", resultMsg));
            }

            ViewBag.Offline = offline;


            var _responseData = Mgr.CheckOutRequestToPayOnline(invoice.CustomerMobilePhone, invoice.Number, invoice.InvoiceAmount.Value);

            ViewBag.CheckoutId = _responseData["id"];

            return(View(invoice));
        }
        public List <DomesticInvoice> GetDomesticInvoices(string userId, UserLanguage Lang)
        {
            string optionSetGetValFn, otherLangOptionSetGetValFn;

            switch (Lang)
            {
            case UserLanguage.Arabic:
                optionSetGetValFn          = "dbo.getOptionSetDisplay";
                otherLangOptionSetGetValFn = "dbo.getOptionSetDisplayen";
                break;

            default:
                optionSetGetValFn          = "dbo.getOptionSetDisplayen";
                otherLangOptionSetGetValFn = "dbo.getOptionSetDisplay";
                break;
            }

            var       query = String.Format(@" Select new_indvpaymentid , new_sabnumber , new_indvcontractid , new_paymentduedate, new_fromdate , new_todate, new_custamount , 
                                                case when new_totalamountwithvat is null then (isnull(new_vatrate,0)*new_invoiceamount + new_invoiceamount) else new_totalamountwithvat end as new_totalamountwithvat, new_paymenttype,new_ispaid, new_customer, new_indvcontractidname , new_customername,
                                                Isnull({2}('new_paymenttype','{1}',new_paymenttype),{3}('new_paymenttype','{1}',new_paymenttype) ) as new_paymenttypename,
                                                contact.mobilephone
                                         From new_indvpayment left outer join contact on contact.contactid =  new_indvpayment.new_customer
                                         Where new_customer = '{0}'
                                       ", userId, CrmEntityName, optionSetGetValFn, otherLangOptionSetGetValFn);
            DataTable dt    = CRMAccessDB.SelectQ(query).Tables[0];

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            List <DomesticInvoice> invoices = new List <DomesticInvoice>();

            foreach (DataRow item in dt.Rows)
            {
                var invoice = new DomesticInvoice(item);
                invoices.Add(invoice);
            }

            return(invoices);
        }
Exemplo n.º 7
0
        public virtual Task <APIResponseModel <ReceiptVoucherViewModel> > CreateReceiptVoucher(DomesticInvoice invoice)
        {
            CultureInfo             info = new CultureInfo("en-us");
            ReceiptVoucherViewModel data = new ReceiptVoucherViewModel()
            {
                contractid     = invoice.ContractId,
                Customerid     = invoice.CustomerId,
                Contractnumber = invoice.Contract,
                InvoiceNumber  = invoice.Number,
                amount         = invoice.InvoiceAmount.ToString(),
                datatime       = DateTime.Now.ToString("dd/MM/yyyy", info.DateTimeFormat),
                paymentcode    = "2",
                vatrate        = "0.0",
                who            = AppConstants.Who_WebSource,
                InvoiceId      = invoice.Id
            };

            try
            {
                var caller = new ApiCaller(Lang);
                var apiUrl = String.Format("api/Payment/Individual/AddRecieptVoucher");
                return(caller.PostResourceAsync <ReceiptVoucherViewModel>(apiUrl, data));
            }
            catch (Exception ex)
            {
                IExceptionLogger logger = new DefaultExceptionLogger();
                logger.Log("Error", ex);

                return(new Task <APIResponseModel <ReceiptVoucherViewModel> >(() => new APIResponseModel <ReceiptVoucherViewModel>()
                {
                    StatusCode = System.Net.HttpStatusCode.InternalServerError, Result = data
                }));
            }
        }