public IActionResult TransferQuery(int id) { var currentUser = _partnerManager.GetPartnerById(this.HttpContext.User.Identity.Name); var moneyTransfer = new MoneyTransferRepo(_db, _partnerManager, _partnerActivity).GetByApiTransaction(id, currentUser.Account); if (moneyTransfer == null) { return(Ok(new { resultCode = 0, resultDesc = "OK", success = "no", queryTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") })); } return(Ok(new { resultCode = 0, resultDesc = "OK", success = "yes", data = new { transferTime = moneyTransfer.CreatedOn.ToString("yyyy/MM/dd HH:mm:ss"), transferId = moneyTransfer.Id, seq = moneyTransfer.ApiTransaction, from = moneyTransfer.CreatedBy.Id + " | " + moneyTransfer.CreatedBy.Account, to = moneyTransfer.Partner.Id + " | " + moneyTransfer.Partner.Account, amt = moneyTransfer.Amount, netAmt = moneyTransfer.NetAmount, recAmt = moneyTransfer.ReceivedAmount, taxPer = moneyTransfer.TaxPercent, taxAmt = moneyTransfer.TaxAmount, bonusPer = moneyTransfer.BonusPercent, bonusAmt = moneyTransfer.BounsAmount, bonusTaxPer = moneyTransfer.BounsTaxPercent, bonusTaxAmt = moneyTransfer.BounsTaxAmount }, queryTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") })); }
public IActionResult Create(int mt) { var currentRoleId = partnerManager.GetCurrentUserRole(this.HttpContext); var permission = partnerActivity.GetPartAct("MoneyTransfer.Adjustment", currentRoleId); if (permission == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحيات الكافية ", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } if (permission.Details == null) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحيات الكافية ", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } if (permission.Details.Count == 0) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحيات الكافية ", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } var moneyTransfer = new MoneyTransferRepo(db, partnerManager, partnerActivity).GetSingleOrDefault(mt); if (moneyTransfer == null) { toastNotification.AddErrorToastMessage("لا توجد بيانات "); return(Redirect(Request.Headers["Referer"].ToString())); } if (moneyTransfer.Adjusted || moneyTransfer.AdjustmentNo > 0) { toastNotification.AddErrorToastMessage("تم اجراء تسوية سابقة على هذه العملية ", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } if (!permission.Details.Any(x => x.ToRole.Id == moneyTransfer.CreatedBy.Role.Id)) { toastNotification.AddErrorToastMessage("ليس لديك الصلاحيات الكافية لاجراء تسوية لهذه الجهة ", new ToastrOptions { Title = "" }); return(Redirect(Request.Headers["Referer"].ToString())); } var model = new CreateAdjustmentDto(); model.OriginTrans = moneyTransfer; model.TaxPercent = moneyTransfer.TaxPercent; model.BonusPercent = moneyTransfer.BonusPercent; model.BounsTaxPercent = moneyTransfer.BounsTaxPercent; model.FixedFactor = moneyTransfer.FixedFactor; return(View(model)); }
//[HttpGet] public IActionResult CreatePDF(int id) { var model = new MoneyTransferRepo(_db, _partnerManager, _partnerActivity).GetSingleOrDefault(id); if (model == null) { return(Ok("غير موجود")); } var roleId = User.Claims.FirstOrDefault(p => p.Type == ClaimTypes.GivenName).Value; var permission = _partnerActivity.GetPartAct("MoneyTransfer.Print", int.Parse(roleId)); var currUserId = User.Claims.FirstOrDefault(p => p.Type == ClaimTypes.MobilePhone).Value; if (permission == null) { return(LocalRedirect("/Account/AccessDenied")); } if (permission.Scope.Id != "Everyone" && model.CreatedBy.Id != currUserId) { return(LocalRedirect("/Account/AccessDenied")); } var globalSettings = new GlobalSettings { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4, Margins = new MarginSettings { Top = 10 }, DocumentTitle = "Money Transfer" }; var objectSettings = new ObjectSettings { PagesCount = true, HtmlContent = new MoneyTransferTemplate(_db, _partnerManager, environment, _partnerActivity).GetHTMLString(id), WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(environment.WebRootPath, "css", "Reports", "rptMoneyTransfer.css") }, //HeaderSettings = {FontName = "Arial", FontSize = 9, Right = "page [page] of [topage]",Line=true}, FooterSettings = { FontName = "Arial", FontSize = 9, Right = "page [page] of [topage]", Line = true, Center = "Y Company" }, }; var pdf = new HtmlToPdfDocument { GlobalSettings = globalSettings, Objects = { objectSettings } }; var file = converter.Convert(pdf); return(File(file, "application/pdf")); }
public string GetHTMLString(int id) { var result = new MoneyTransferRepo(db, partnerManager, partnerActivity).GetSingleOrDefault(id); var sb = new StringBuilder(); sb.Append(@"<html> <head></head> <body> <table class='header_table'> <tbody> <tr> <td><img src='" + Path.Combine(environment.WebRootPath, "images", "Y-Logo2.png") + @"' alt='YCo Logo' class='brand-image' width='70' height='70' style='opacity: .8'></td> <td><h1>بيع رصيد شاحن فوري</h1></td> <td> <div style='display:bloack;'>" + DateTime.Now.ToString("yyyy/MM/dd") + @"</div> <div style='display:bloack;'>" + DateTime.Now.ToString("ss:mm:H") + @"</div> </td> </tr> </tbody> </table> <table class='RefData'> <tbody> <tr> <td style='width:20%;'>رقم المرجع</td> <td style='width:30%;font-size:25px;font-weight:bold;'>" + result.Id + @"</td> <td style='width:20%;'>التاريخ</td> <td style='width:30%;'>" + result.CreatedOn.ToString("yyyy/MM/dd ss:mm:H") + @"</td> </tr> </tbody> <table> <table class='AmountDetails' > <thead> <tr style='height:40px;'> <th colspan='2' style='border-left:1px solid #cbcdcf;'>من</th> <th colspan='2'>الى</th> </tr> </thead> <tbody> <tr style='height:40px;'> <td style='width:20%;text-align:right;padding-right:10px;'>الرقم :</td> <td style='width:30%;border-left:1px solid #cbcdcf;'>" + result.CreatedBy.Id + @"</td> <td style='width:20%;text-align:right;padding-right:10px;'>الرقم :</td> <td style='width:30%;'>" + result.Partner.Id + @"</td> </tr> <tr style='height:40px;'> <td style='width:20%;text-align:right;padding-right:10px;'>الحساب :</td> <td style='width:30%;border-left:1px solid #cbcdcf;'>" + result.CreatedBy.Account + @"</td> <td style='width:20%;text-align:right;padding-right:10px;'>الحساب :</td> <td style='width:30%;'>" + result.Partner.Account + @"</td> </tr> <tr style='height:40px;'> <td style='width:20%;text-align:right;padding-right:10px;'>الاسم :</td> <td style='width:30%;border-left:1px solid #cbcdcf;'>" + result.CreatedBy.Name + @"</td> <td style='width:20%;text-align:right;padding-right:10px;'>الاسم :</td> <td style='width:30%;'>" + result.Partner.Name + @"</td> </tr> <tr style='height:40px;'> <td style='width:20%;text-align:right;padding-right:10px;'>النوع :</td> <td style='width:30%;border-left:1px solid #cbcdcf;'>" + result.CreatedBy.Role.Name + @"</td> <td style='width:20%;text-align:right;padding-right:10px;'>النوع :</td> <td style='width:30%;'>" + result.Partner.Role.Name + @"</td> </tr> <tr style='height:40px;'> <td style='width:20%;text-align:right;padding-right:10px;'>الرصيد :</td> <td style='width:30%;border-left:1px solid #cbcdcf;'>" + result.CreatedBy.Balance.ToString("N2") + @"</td> <td style='width:20%;text-align:right;padding-right:10px;'>الرصيد :</td> <td style='width:30%;'>" + result.Partner.Balance.ToString("N2") + @"</td> </tr> </tbody> <table> <table class='AmountDetails'> <thead> <th colspan='4'>التفــــــاصيــــــل</th> </thead> <tbody> <tr> <td style='width:15%;text-align:right;'>المبلغ</td> <td style='width:30%;text-align:center;'>" + result.Amount.ToString("N2") + @"</td> <td style='width:55%;text-align:right;font-size:18px;'>" + new MonyToString().NumToStr(result.Amount) + @"</td> </tr> <tr> <td style='width:15%;text-align:right;'>نسبة ثابتة</td> <td style='width:30%;text-align:center;'>" + result.FixedFactor.ToString("N6") + @"</td> <td style='width:55%;text-align:right;font-size:18px;'></td> </tr> <tr> <td style='width:15%;text-align:right;'>الصافي</td> <td style='width:30%;text-align:center;'>" + result.NetAmount.ToString("N2") + @"</td> <td style='width:55%;text-align:right;font-size:18px;'>" + new MonyToString().NumToStr(result.NetAmount) + @"</td> </tr> <tr> <td style='width:15%;text-align:right;'>نسبة الضريبة</td> <td style='width:30%;text-align:center;'>" + result.TaxPercent.ToString("N2") + @" %</td> <td style='width:55%;text-align:right;'></td> </tr> <tr> <td style='width:15%;text-align:right;'>مبلغ الضريبة</td> <td style='width:30%;text-align:center;'>" + result.TaxAmount.ToString("N2") + @"</td> <td style='width:55%;text-align:right;font-size:18px;'>" + new MonyToString().NumToStr(result.TaxAmount) + @"</td> </tr> <tr> <td style='width:15%;text-align:right;'>نسبة العمولة</td> <td style='width:30%;text-align:center;'>" + result.BonusPercent.ToString("N2") + @" %</td> <td style='width:55%;text-align:right;'></td> </tr> <tr> <td style='width:15%;text-align:right;'>مبلغ العمولة</td> <td style='width:30%;text-align:center;'>" + result.BounsAmount.ToString("N2") + @"</td> <td style='width:55%;text-align:right;font-size:18px;'>" + new MonyToString().NumToStr(result.BounsAmount) + @"</td> </tr> <tr> <td style='width:15%;text-align:right;'>نسبة ضريبة المنبع</td> <td style='width:30%;text-align:center;'>" + result.BounsTaxPercent.ToString("N2") + @" %</td> <td style='width:55%;text-align:right;'></td> </tr> <tr> <td style='width:10%;text-align:right;'>مبلغ ضريبة المنبع</td> <td style='width:30%;text-align:center;'>" + result.BounsTaxAmount.ToString("N2") + @"</td> <td style='width:60%;text-align:right;font-size:18px;'>" + new MonyToString().NumToStr(result.BounsTaxAmount) + @"</td> </tr> <tr> <td style='width:15%;text-align:right;'>المبلغ المطلوب</td> <td style='width:30%;text-align:center;'>" + result.ReceivedAmount.ToString("N2") + @"</td> <td style='width:55%;text-align:right;font-size:18px;'>" + new MonyToString().NumToStr(result.ReceivedAmount) + @"</td> </tr> </tbody> <table> <table style='margin-bottom:30px;'> <tbody> <tr style='height:50px;'> <td style='font-size:26px;font-weight:bold;background-color: #EDF0F2;'>" + new MonyToString().NumToStr(result.ReceivedAmount) + @"</td> </tr> </tbody> </table> <table style='margin-bottom:30px;'> <tbody> <tr style='height:50px;'> <td style='width:33%;'>المستلم</td> <td style='width:33%;'></td> <td style='width:33%;'>المحاسب </td> </tr> <tr style='height:50px;'> <td style='width:33%;font-weight:bold;'>" + result.Partner.Name + @"</td> <td style='width:33%;'></td> <td style='width:33%;'></td> </tr> </tbody> </table> </body><html> "); return(sb.ToString()); }
public IActionResult Detail(int id) { var model = new MoneyTransferRepo(_db, _partnerManager, _partnerActivity).GetSingleOrDefault(id); return(View(model)); }
public IActionResult MoneyTranferQuery(MoneyTransferQueryDto model, [FromQuery (Name = "direction")] string direction) { #region Prepare Query model.Error = string.Empty; Partner targetPartner = null; var currUserId = _partnerManager.GetCurrentUserId(this.HttpContext); var currRoleId = _partnerManager.GetCurrentUserRole(this.HttpContext); var currAccountId = _partnerManager.GetCurrentUserAccount(this.HttpContext); var permission = _partnerActivity.GetPartAct("MoneyTransfer.Query", currRoleId); if (permission == null) { model.Error = "ليس لديك الصلاحيات الكافية"; return(View(model)); } if (!string.IsNullOrEmpty(model.QPartnerId) && model.QPartnerId != currUserId) { var validateTargetPartnerResult = _partnerManager.Validate(model.QPartnerId); targetPartner = validateTargetPartnerResult.Success ? validateTargetPartnerResult.Partner : null; if (targetPartner == null) { model.Error = "يرجى التأكد من الرقم المراد الاستعلام عنه"; return(View(model)); } } if (permission.Scope.Id == "CurOpOnly" && model.QPartnerId != currUserId) { model.Error = "ليس لديك الصلاحيات الكافية للاستعلام عن هذا الرقم"; return(View(model)); } else if (permission.Scope.Id == "Exclusive" && targetPartner != null && targetPartner.RefPartner.Id != currUserId) { model.Error = "ليس لديك الصلاحيات الكافية للاستعلام عن هذا الرقم"; return(View(model)); } #endregion ModelState.Clear(); if (direction == "pre" && model.Paging.PageNo > 1) { model.Paging.PageNo -= 1; } if (direction == "next") { model.Paging.PageNo += 1; } if (model.QFromDate == DateTime.MinValue) { model.QFromDate = DateTime.Today.AddMonths(-1); } if (model.QToDate == DateTime.MinValue) { model.QFromDate = DateTime.Today; } model.QueryUser = _partnerManager.GetCurrentUserId(this.HttpContext); model.QScope = permission.Scope.Id; var result = new MoneyTransferRepo(_db, _partnerManager, _partnerActivity).MTQueryWithPaging(model); if (result != null && result.Results != null) { model.Paging.Count = new MoneyTransferRepo(_db, _partnerManager, _partnerActivity).GetCount(model); } else { model.Paging.Count = 0; } return(View(result)); }
public IActionResult Confirmation(CreateMoneyTransferDto model) { if (model.Id > 0) { model.Error = "تم التحويل مسبقا"; return(View(model)); } var moneyTransfer = new MoneyTransfer(); moneyTransfer.Partner = _partnerManager.GetPartnerById(model.PartnerId); moneyTransfer.PayType.Id = model.PayTypeId; moneyTransfer.PayNo = model.PayNo; moneyTransfer.PayDate = model.PayDate; moneyTransfer.PayBank = model.PayBank; moneyTransfer.CreatedBy = _partnerManager.GetPartnerById(_partnerManager.GetCurrentUserId(this.HttpContext)); moneyTransfer.AccessChannel.Id = "web"; moneyTransfer.Amount = model.Amount; moneyTransfer.BillNo = model.BillNo; moneyTransfer.RequestNo = model.RequestNo; moneyTransfer.RequestAmount = model.RequestAmount; moneyTransfer.Note = model.Note; moneyTransfer.NetAmount = model.NetAmount; moneyTransfer.TaxPercent = model.TaxPercent; moneyTransfer.TaxAmount = model.TaxAmount; moneyTransfer.BonusPercent = model.BonusPercent; moneyTransfer.BounsAmount = model.BounsAmount; moneyTransfer.BounsTaxPercent = model.BounsTaxPercent; moneyTransfer.BounsTaxAmount = model.BounsTaxAmount; moneyTransfer.ReceivedAmount = model.ReceivedAmount; var result = new MoneyTransferRepo(_db, _partnerManager, _partnerActivity).Create(moneyTransfer); if (result.Success) { model.Id = result.AffectedCount; ModelState.SetModelValue("Id", new ValueProviderResult("" + result.AffectedCount + "", CultureInfo.InvariantCulture)); //CreatePDF(model.Id); moneyTransfer.NetAmount = Math.Round(moneyTransfer.NetAmount, 2); moneyTransfer.Partner.Balance = _partnerManager.GetBalance(moneyTransfer.Partner.Account); moneyTransfer.CreatedBy.Balance = _partnerManager.GetBalance(moneyTransfer.CreatedBy.Account); new NotificationRepo(_db, _partnerManager).SendNotification <MoneyTransfer>("MoneyTransfer.Create", result.AffectedCount, moneyTransfer); return(View(model)); } else { if (result.AffectedCount == -500) { model.Error = "لم يتم تعريف هذا الاجراء او ليس لديك الصلاحية الكافية"; } else if (result.AffectedCount == -501) { model.Error = $"رصيدك غير كافي { model.CreatorBalance.ToString("N0") } "; } else if (result.AffectedCount == -502) { model.Error = $"المبلغ اقل من الاحد الادنى المسموح به"; } if (result.AffectedCount == -503) { model.Error = $"المبلغ اكبر من الاحد الاعلى المسموح به"; } } return(View(model)); }
public IActionResult Transfer(MoneyTransferDto mt) { if (!Utility.ValidYMobileNo(mt.pid)) { return(BadRequest(new ApiResponse(-3000, "Sorry, the target mobile was wrong"))); } if (mt.amt <= 0) { return(BadRequest(new ApiResponse(-3001, "Sorry, the amount was wrong"))); } var partnerResult = this._partnerManager.Validate(mt.pid); if (!partnerResult.Success) { return(BadRequest(new ApiResponse(-3002, "Sorry, the target pos was wrong"))); } var currentUser = _partnerManager.GetPartnerById(this.HttpContext.User.Identity.Name); var moneyTransfer = new MoneyTransfer(); moneyTransfer.Partner = partnerResult.Partner; moneyTransfer.PayType.Id = "cash"; moneyTransfer.PayNo = "0000"; moneyTransfer.PayDate = DateTime.Now; moneyTransfer.PayBank = ""; moneyTransfer.CreatedBy = currentUser; moneyTransfer.AccessChannel.Id = "api"; moneyTransfer.Amount = mt.amt; moneyTransfer.BillNo = "00"; moneyTransfer.RequestNo = "00"; moneyTransfer.RequestAmount = mt.amt; moneyTransfer.Note = mt.note; moneyTransfer.ApiTransaction = mt.seq; var result = new MoneyTransferRepo(_db, _partnerManager, _partnerActivity).Create(moneyTransfer); if (!result.Success) { if (result.AffectedCount == -500) { return(BadRequest(new ApiResponse(-3003, "Sorry, undefined rule"))); } if (result.AffectedCount == -501) { return(BadRequest(new ApiResponse(-3004, $"Sorry, your balance was not enough {(currentUser.Balance - currentUser.Reserved).ToString("N0")}"))); } if (result.AffectedCount == -502) { return(BadRequest(new ApiResponse(-3005, $"Sorry, amount less than min limit"))); } if (result.AffectedCount == -503) { return(BadRequest(new ApiResponse(-3006, "Sorry, amount more than max limit"))); } if (result.AffectedCount == -506) { return(BadRequest(new ApiResponse(-3007, "Sorry, your account was invalid"))); } if (result.AffectedCount == -507) { return(BadRequest(new ApiResponse(-3008, "Sorry, inconsistent data"))); } if (result.AffectedCount == -508) { return(BadRequest(new ApiResponse(-3009, $"Sorry, duplicated sequence {moneyTransfer.ApiTransaction}"))); } } moneyTransfer = new MoneyTransferRepo(_db, _partnerManager, _partnerActivity).GetSingleOrDefault(result.AffectedCount); moneyTransfer.Partner.Balance = _partnerManager.GetBalance(moneyTransfer.Partner.Account); moneyTransfer.CreatedBy.Balance = _partnerManager.GetBalance(moneyTransfer.CreatedBy.Account); new NotificationRepo(_db, _partnerManager).SendNotification <MoneyTransfer>("MoneyTransfer.Create", result.AffectedCount, moneyTransfer); return(Ok(new { resultCode = 0, resultDesc = "OK", transferId = moneyTransfer.Id, seq = moneyTransfer.ApiTransaction, from = moneyTransfer.CreatedBy.Id + " | " + moneyTransfer.CreatedBy.Account, to = moneyTransfer.Partner.Id + " | " + moneyTransfer.Partner.Account, amt = moneyTransfer.Amount, netAmt = moneyTransfer.NetAmount, recAmt = moneyTransfer.ReceivedAmount, taxPer = moneyTransfer.TaxPercent, taxAmt = moneyTransfer.TaxAmount, bonusPer = moneyTransfer.BonusPercent, bonusAmt = moneyTransfer.BounsAmount, bonusTaxPer = moneyTransfer.BounsTaxPercent, bonusTaxAmt = moneyTransfer.BounsTaxAmount, yourBal = (moneyTransfer.CreatedBy.Balance - moneyTransfer.CreatedBy.Reserved) })); }