public async Task <ReceiptVoucherViewModel> CreateReceiptVoucher(ServiceContractPerHour contractToPay, PaymentTransaction newTransaction) { var paymentMgr = new PaymentManager(); try { var data = new ReceiptVoucherViewModel(); data.contractid = contractToPay.ContractId; data.Customerid = contractToPay.CustomerId; data.Contractnumber = contractToPay.ContractNum; data.amount = contractToPay.totalpricewithoutvat; CultureInfo info = new CultureInfo("en-us"); data.datatime = DateTime.Now.ToString("dd/MM/yyyy", info.DateTimeFormat); data.paymentcode = "2";//ToDo data.paymenttype = 2; data.vatrate = contractToPay.vatrate; data.who = 2; var newVoucher = await PostResourceAsync <ReceiptVoucherViewModel>("api/Payment/AddRecieptVoucher", data); if (newVoucher.StatusCode == HttpStatusCode.OK) { //SaveFailedReceiptVoucher(contractToPay, newTransaction); return(newVoucher.Result); } else { return(paymentMgr.SaveFailedReceiptVoucher(contractToPay, newTransaction)); } } catch (Exception ex) { return(paymentMgr.SaveFailedReceiptVoucher(contractToPay, newTransaction)); } }
public PaymentTransaction AddFailedPaymentTransactionWithNoCheckoutId(ServiceContractPerHour contractToPay) { try { PaymentTransaction transaction = new PaymentTransaction() { CustomerId = contractToPay.CustomerId, ContractId = contractToPay.ContractId, PaymentStatus = "000000", PaymentStatusName = "Checkout payment failed", Amount = Convert.ToDecimal(contractToPay.FinalPrice), Who = 2, EntityName = "Failed Payment Transaction for Contract Number [ " + contractToPay.ContractNum + " ] with Total price of : [ " + contractToPay.FinalPrice + " SR ] and customer : [ " + contractToPay.CustomerId + " ]", IsVoucherSaved = false, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, TransactionType = (int)TransactionType.ServiceContractPerHour, TransactionTypeName = TransactionType.ServiceContractPerHour.ToString() }; transaction = CreatePaymentTransaction(transaction); return(transaction); } catch (Exception ex) { IExceptionLogger logger = new DefaultExceptionLogger(); logger.Log("Error", ex); return(null); } }
public ReceiptVoucherViewModel SaveFailedReceiptVoucher(ServiceContractPerHour contractToPay, PaymentTransaction newTransaction) { //Insert into failed reciept vouchers only //string ToEmails = ConfigurationSettings.AppSettings["PaymentFailureEmails"].ToString(); string ToEmails = _storeBase.GetSettingValueByName("PaymentFailureEmails"); string CCEmail = ""; string subject = "خطأ في إنشاء سند قبض للعميل من علي البورتال"; string body = " خطأ في إنشاء سند قبض للعميل رقم "; body += contractToPay.CustomerId; body += " من علي البورتال لعقد رقم "; body += contractToPay.ContractId; var receipt = new ReceiptVoucher(); receipt.ContractId = contractToPay.ContractId; receipt.CustomerId = contractToPay.CustomerId; receipt.ContractNumber = contractToPay.ContractNum; receipt.Amount = Convert.ToDecimal(contractToPay.PriceBeforeDiscount); CultureInfo info1 = new CultureInfo("en-us"); receipt.Date = DateTime.Now.ToString("MM/dd/yyyy", info1.DateTimeFormat); receipt.PaymentCode = "2";//ToDo receipt.PaymentType = 2; receipt.VatRate = Convert.ToDecimal(contractToPay.vatrate); receipt.Who = 2; receipt.IsSaved = false; receipt.CreatedDate = DateTime.Now.ToString("MM/dd/yyyy", info1.DateTimeFormat); receipt.ModifiedDate = DateTime.Now.ToString("MM/dd/yyyy", info1.DateTimeFormat); receipt.TransactionId = newTransaction.Id; _ReceiptVoucherStoreBase.Create(receipt); MailSender.SendEmail02(ToEmails, CCEmail, subject, body, false, ""); return(new ReceiptVoucherViewModel()); }
public ServiceContractPerHour GetHourlyContractDetails(string contractId, UserLanguage Language) { string optionSetGetValFn, otherLangOptionSetGetValFn; switch (Language) { case UserLanguage.Arabic: optionSetGetValFn = "dbo.getOptionSetDisplay"; otherLangOptionSetGetValFn = "dbo.getOptionSetDisplayen"; break; default: optionSetGetValFn = "dbo.getOptionSetDisplayen"; otherLangOptionSetGetValFn = "dbo.getOptionSetDisplay"; break; } string query = String.Format(@"select contract.new_hindvcontractid, contract.new_contractnumber, hourlypricing.new_name as hourlypricingname, Contract.new_finalprice, Contract.new_contractmonth, Isnull(appointment.userrate,0) as userrate, appointment.nextappointment, contract.new_city, contract.new_cityName, contract.new_district, contract.new_districtName , hourlypricing.new_nationalityName, hourlypricing.new_nationality, contract.new_selecteddays, contract.new_shift, contract.new_vatrate as vatrate, contract.new_hoursnumber, contract.new_weeklyvisits, contract.new_totalprice_def as totalprice, contract.new_totalprice_def , ISNULL(contract.new_vatrate,0) * 100 as new_vatrate, contract.new_vatamount, contract.new_discount_def, Round(contract.new_weeklyvisits * contract.new_hoursnumber * Contract.new_contractmonth * hourlypricing.new_hourprice,2,2) as totalPriceBeforeDiscount, contract.new_employeenumber, contract.new_latitude, contract.new_longitude, Convert(date, contract.new_contractstartdate) as new_contractstartdate, Isnull({0}('new_contractmonth','new_HIndvContract',Contract.new_contractmonth),{1}('new_contractmonth','new_HIndvContract',Contract.new_contractmonth) ) as durationname, Contract.statuscode, Contract.createdon, Isnull({2}('statuscode','new_HIndvContract',Contract.statuscode),{3}('statuscode','new_HIndvContract',Contract.statuscode) ) as statusname, contract.new_HIndivClintnameName, contact.mobilephone, contract.new_HIndivClintname --contract.new_discount_def,contract.new_totalprice_def,contract.new_totalvisits_def,contract.new_monthvisits_def, --contract.new_contractmonth,,Contract.new_selectedshifts,Contract.new_visitprice_def, -- --hourlypricing.new_hourlypricingId, from new_HIndvContract contract inner join new_hourlypricing hourlypricing on contract.new_houlrypricing=hourlypricing.new_hourlypricingId left outer join ( select new_hourlyappointmentBase.new_servicecontractperhour, IIF( Count(new_hourlyappointmentBase.new_rate) > 0, ROUND( Sum(Isnull(new_hourlyappointmentBase.new_rate,0)) / Count(new_hourlyappointmentBase.new_rate), 0) , null) as userrate, max(new_hourlyappointmentBase.new_shiftstart) as nextAppointment from new_hourlyappointmentBase where Convert (date, new_shiftstart) <= Convert(date,GetDate()) group by new_servicecontractperhour ) as appointment on new_servicecontractperhour= contract.new_HIndvContractId left outer join contact on contact.contactid = contract.new_HIndivClintname where contract.new_hindvcontractid = '{4}' order by contract.new_ContractNumber desc", optionSetGetValFn, otherLangOptionSetGetValFn, optionSetGetValFn, otherLangOptionSetGetValFn, contractId); DataTable dt = CRMAccessDB.SelectQ(query).Tables[0]; if (dt.Rows.Count == 0) { return(null); } var contract = new ServiceContractPerHour(dt.Rows[0], Language); contract.HourlyPricingCost = new HourlyPricingCost(dt.Rows[0]); return(contract); }
public Dictionary <string, dynamic> CheckOutRequest(ServiceContractPerHour contractToPay) { return(CheckOutRequest(contractToPay.CustomerMobilePhone, contractToPay.ContractId, contractToPay.FinalPrice ?? 0m)); }