/// <summary> /// Deletes an AUIncrement by AUIncrementID /// </summary> /// <param name="incrementID">ID of AUIncrement to delete</param> public virtual List<AUFeesRecord> GetFeesHierarchyForLotId(int lotID) { var allfees = new List<AUFeesRecord>(); var query = _feesRepo.Table; query = query.Where(c => lotID == c.AUEntityID); query = query.Where(c => c.AUEntityType.Contains("AULot")); var lotfees = query.FirstOrDefault(); if (lotfees != null) { allfees.Add(lotfees); } var lot = _lotRepo.GetById(lotID); if (lot != null) { foreach (var co in lot.AUConsignmentRecords) { //var query2 = _feesRepo.Table; //query2 = query2.Where(c => c.AUEntityID == co.AUConsignmentID); //query2 = query2.Where(c => c.AUEntityType.Contains("AUConsignment")); //var consignmentfees = query2.FirstOrDefault(); var consignmentfees = GetFeesHierarchyForConsignmentId(co.AUConsignmentID); if (consignmentfees != null) //A lot should never exist without a consignment { foreach (var AUFeesRecord in consignmentfees) { allfees.Add(AUFeesRecord); if (lotfees == null && (AUFeesRecord.AUEntityType == "AUConsignment" || AUFeesRecord.AUEntityType == "AUConsignment(I)")) { var inhlotfees = new AUFeesRecord(); inhlotfees.AUEntityID = lotID; inhlotfees.AUEntityType = "AULot(I)"; inhlotfees.CommissionCanExceedReserveInd = AUFeesRecord.CommissionCanExceedReserveInd; inhlotfees.ExpertisingFeeAmt = AUFeesRecord.ExpertisingFeeAmt; inhlotfees.FixedFeeAmt = AUFeesRecord.FixedFeeAmt; inhlotfees.InsuranceSoldPct = AUFeesRecord.InsuranceSoldPct; inhlotfees.InsuranceUnsoldPct = AUFeesRecord.InsuranceUnsoldPct; inhlotfees.InterestOnAdvancePct = AUFeesRecord.InterestOnAdvancePct; inhlotfees.MinCommissionMailSoldAmt = AUFeesRecord.MinCommissionMailSoldAmt; inhlotfees.MinCommissionMailUnsoldAmt = AUFeesRecord.MinCommissionMailUnsoldAmt; inhlotfees.MinCommissionPublicSoldAmt = AUFeesRecord.MinCommissionPublicSoldAmt; inhlotfees.MinCommissionPublicUnsoldAmt = AUFeesRecord.MinCommissionPublicUnsoldAmt; inhlotfees.MinimumConsignorTotalFeeAmt = AUFeesRecord.MinimumConsignorTotalFeeAmt; inhlotfees.MiscFeeAmt = AUFeesRecord.MiscFeeAmt; inhlotfees.SoldPct = AUFeesRecord.SoldPct; inhlotfees.UnsoldPct = AUFeesRecord.UnsoldPct; allfees.Add(inhlotfees); } } } } } return allfees; }
public virtual List<AUFeesRecord> GetFeesHierarchyForConsignmentId(int consignmentID) { var allfees = new List<AUFeesRecord>(); var consignmentfees = new AUFeesRecord(); consignmentfees = GetFeesForOneId(consignmentID, "AUConsignment"); if (consignmentfees != null) { allfees.Add(consignmentfees); } var consignment = _consignmentRepo.GetById(consignmentID); if (consignment != null) { foreach (var cr in consignment.AUConsignorRecords) { //Nonsense: check to see if in list yet in case getting same consignor. //Should: // - May not happen for Lots because a lot entry point should always be for only one (active, published) consignment // - May happen for a Consignment that belongs to 2 active consignors //TODO - how to inherit consignment fees for multiple consignors //bool exists = allfees.Exists(element => element.AUEntityID == cr.AUConsignorID); //if (!exists) //{ var consignorfees = GetFeesForOneId(cr.AUConsignorID, "AUConsignor"); if (consignorfees != null) //you should always have a consignor fees record - even if it is the default all zero record { allfees.Add(consignorfees); if (consignmentfees == null) { // if you didn't find entry point consignmentfees, create an inherited consignment fees record from the // consignor values. Mark it as AUConsignment(I) // TODO: the consignment fee inheritance model breaks if 2 consignors var inhconsignmentfees = new AUFeesRecord(); inhconsignmentfees.AUEntityID = consignmentID; inhconsignmentfees.AUEntityType = "AUConsignment(I)"; inhconsignmentfees.CommissionCanExceedReserveInd = consignorfees.CommissionCanExceedReserveInd; inhconsignmentfees.ExpertisingFeeAmt = consignorfees.ExpertisingFeeAmt; inhconsignmentfees.FixedFeeAmt = consignorfees.FixedFeeAmt; inhconsignmentfees.InsuranceSoldPct = consignorfees.InsuranceSoldPct; inhconsignmentfees.InsuranceUnsoldPct = consignorfees.InsuranceUnsoldPct; inhconsignmentfees.InterestOnAdvancePct = consignorfees.InterestOnAdvancePct; inhconsignmentfees.MinCommissionMailSoldAmt = consignorfees.MinCommissionMailSoldAmt; inhconsignmentfees.MinCommissionMailUnsoldAmt = consignorfees.MinCommissionMailUnsoldAmt; inhconsignmentfees.MinCommissionPublicSoldAmt = consignorfees.MinCommissionPublicSoldAmt; inhconsignmentfees.MinCommissionPublicUnsoldAmt = consignorfees.MinCommissionPublicUnsoldAmt; inhconsignmentfees.MinimumConsignorTotalFeeAmt = consignorfees.MinimumConsignorTotalFeeAmt; inhconsignmentfees.MiscFeeAmt = consignorfees.MiscFeeAmt; inhconsignmentfees.SoldPct = consignorfees.SoldPct; inhconsignmentfees.UnsoldPct = consignorfees.UnsoldPct; allfees.Add(inhconsignmentfees); } } //} } } return allfees; }
/// <summary> /// Gets the fees whatever the entery point: AUConsignor, AUConsignment, AULot. Will "inherit" any missing entry /// </summary> /// <param name="entryID">ID of entry point entity /// <param name="entryType"> Name of entry point: AUConsignor or AUConsignment or AULot</param> public virtual List<AUFeesRecord> GetFeesHierarchyForEntryPoint(int entryID, string entryType) { var allfees = new List<AUFeesRecord>(); if (entryType == "AULot") allfees = GetFeesHierarchyForLotId(entryID); else if (entryType == "AUConsignment") allfees = GetFeesHierarchyForConsignmentId(entryID); else if (entryType == "AUConsignor") { //AUConsignor = highest level var fee = new AUFeesRecord(); fee = GetFeesForOneId(entryID, entryType); //NOTE: THIS SHOULD NOT BE NEEDED BECAUSE CONSIGNOR FEE IS STORED WHEN NEW CONSIGNOR IS STORED if (fee == null) { fee.AUEntityID = entryID; fee.AUEntityType = "AUConsignor"; fee.CommissionCanExceedReserveInd = false; fee.ExpertisingFeeAmt = 0; fee.FixedFeeAmt = 0; fee.InsuranceSoldPct = 0; fee.InsuranceUnsoldPct = 0; fee.InterestOnAdvancePct = 0; fee.MinCommissionMailSoldAmt = 0; fee.MinCommissionMailUnsoldAmt = 0; fee.MinCommissionPublicSoldAmt = 0; fee.MinCommissionPublicUnsoldAmt = 0; fee.MinimumConsignorTotalFeeAmt = 0; fee.MiscFeeAmt = 0; fee.SoldPct = 0; fee.UnsoldPct = 0; allfees.Add(fee); } allfees.Add(fee); } return allfees; }
public ActionResult CreateUpdateConsignor(AUConsignorRecord record) { if (ModelState.IsValid) { AUConsignorRecord consignor = _consignorRepo.GetById(record.AUConsignorID); if (consignor == null) { var CurrentCustomer = _authenticationService.GetAuthenticatedCustomer(); record.CreatedBy = CurrentCustomer.Username; record.UpdatedBy = CurrentCustomer.Username; record.CreatedOnDT = System.DateTime.UtcNow; record.UpdatedOnDT = System.DateTime.UtcNow; //Make updated by same as created by date for initial store //record.UpdatedOnDT = System.DateTime.UtcNow; record.UpdatedOnDT = record.CreatedOnDT; _consignorRepo.Insert(record); //store a blank fee at the highest level to make consignor fees easier/more consistent grid design var fee = new AUFeesRecord(); fee.AUEntityID = record.AUConsignorID; fee.AUEntityType = "AUConsignor"; fee.CommissionCanExceedReserveInd = false; fee.ExpertisingFeeAmt = 0; fee.FixedFeeAmt = 0; fee.InsuranceSoldPct = 0; fee.InsuranceUnsoldPct = 0; fee.InterestOnAdvancePct = 0; fee.MinCommissionMailSoldAmt = 0; fee.MinCommissionMailUnsoldAmt = 0; fee.MinCommissionPublicSoldAmt = 0; fee.MinCommissionPublicUnsoldAmt = 0; fee.MinimumConsignorTotalFeeAmt = 0; fee.MiscFeeAmt = 0; fee.SoldPct = 0; fee.UnsoldPct = 0; _feesRepo.Insert(fee); SuccessNotification("Consignor Created Successfully - please add consignments and fees!"); return RedirectToRoute(new { Action = "CreateUpdateConsignor", Controller = "AUConsignor", ConsignorId = record.AUConsignorID }); } else { //use latest consignor record to update with most up-do-date data rather than stale record consignor.Prefix = record.Prefix; consignor.FirstName = record.FirstName; consignor.MiddleName = record.MiddleName; consignor.LastName = record.LastName; consignor.CustomerID = record.CustomerID; consignor.Suffix = record.Suffix; consignor.WEMailID = record.WEMailID; consignor.HEMailID = record.HEMailID; consignor.EMailPrefCode = record.EMailPrefCode; //consignor.CommissionCanExceedReserveInd = record.CommissionCanExceedReserveInd; //consignor.SoldPct = record.SoldPct; //consignor.UnsoldPct = record.UnsoldPct; //consignor.InsuranceSoldPct = record.InsuranceSoldPct; //consignor.InsuranceUnsoldPct = record.InsuranceUnsoldPct; //consignor.MinCommissionPublicSoldAmt = record.MinCommissionPublicSoldAmt; //consignor.MinCommissionPublicUnsoldAmt = record.MinCommissionPublicUnsoldAmt; //consignor.MinCommissionMailSoldAmt = record.MinCommissionMailSoldAmt; //consignor.MinCommissionMailUnsoldAmt = record.MinCommissionMailUnsoldAmt; //consignor.FixedFeeAmt = record.FixedFeeAmt; //consignor.MinimumConsignorTotalFeeAmt = record.MinimumConsignorTotalFeeAmt; //consignor.InterestOnAdvancePct = record.InterestOnAdvancePct; //consignor.MiscFeeAmt = record.MiscFeeAmt; //consignor.MiscFeeAmt = record.MiscFeeAmt; //consignor.MiscFeeType = record.MiscFeeType; //consignor.ExpertisingFeeAmt = record.ExpertisingFeeAmt; //consignor.CreatedOnDT = System.DateTime.UtcNow; --> don't overlay created info //consignor.CreatedBy = CurrentCustomer.Username; var CurrentCustomer = _authenticationService.GetAuthenticatedCustomer(); consignor.UpdatedBy = CurrentCustomer.Username; consignor.UpdatedOnDT = System.DateTime.UtcNow; //this is how nop converts it back out //consignor.CreatedOnDT = _dateTimeHelper.ConvertToUserTime(customer.CreatedOnUtc, DateTimeKind.Utc); //public virtual DateTime CreatedOnDT { get; set; } //public virtual string CreatedBy { get; set; } //public virtual DateTime UpdatedOnDT { get; set; } //public virtual string UpdatedBy { get; set; } _consignorRepo.Update(consignor); _cacheManager.Clear(); SuccessNotification("Changed Saved!"); //return View(consignment); //now with customer view engine return View("~/Views/AUConsignor/CreateUpdateConsignor.cshtml", consignor); //not hit first time?? //return View("~/Plugins/Widgets.PromoSlider/Views/PromoSlider/CreateUpdatePromoSlider.cshtml", slider); } } else { return View(); //return View("~/Views/PromoSlider/CreateUpdatePromoSlider.cshtml"); //not hit first time? //return View("~/Plugins/Widgets.PromoSlider/Views/PromoSlider/CreateUpdatePromoSlider.cshtml"); } }
public ActionResult CreateUpdateFees(AUFeesRecord model) { //TODO: Implement permissions across all actions //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) // return AccessDeniedView(); //var productCategory = _categoryService.GetProductCategoryById(model.Id); //if (productCategory == null) // throw new ArgumentException("No product category mapping found with the specified id"); string feetype = ""; var fee = new AUFeesRecord(); if (model.AUFeesID > 0) { fee = _feesRepo.GetById(model.AUFeesID); //TODO: push into service } else { //Make sure you don't carry the Inherited indicator (I) into the database feetype = model.AUEntityType; if (model.AUEntityType == "AUConsignment(I)") { feetype = "AUConsignment"; } else if (model.AUEntityType == "AULot(I)") { feetype = "AULot"; } fee.AUEntityType = feetype; fee.AUEntityID = model.AUEntityID; //Hack - force in the Order here for displaying if (feetype == "AUConsignor") { fee.DisplayOrder = 0; } else if (feetype == "AUConsignment") { fee.DisplayOrder = 2; } else if (feetype == "AULot") { fee.DisplayOrder = 3; } } fee.CommissionCanExceedReserveInd = model.CommissionCanExceedReserveInd; fee.ExpertisingFeeAmt = model.ExpertisingFeeAmt; fee.FixedFeeAmt = model.FixedFeeAmt; fee.InsuranceSoldPct = model.InsuranceSoldPct; fee.InsuranceUnsoldPct = model.InsuranceUnsoldPct; fee.InterestOnAdvancePct = model.InterestOnAdvancePct; fee.MinCommissionMailSoldAmt = model.MinCommissionMailSoldAmt; fee.MinCommissionMailUnsoldAmt = model.MinCommissionMailUnsoldAmt; fee.MinCommissionPublicSoldAmt = model.MinCommissionPublicSoldAmt; fee.MinCommissionPublicUnsoldAmt = model.MinCommissionPublicUnsoldAmt; fee.MinimumConsignorTotalFeeAmt = model.MinimumConsignorTotalFeeAmt; fee.MiscFeeAmt = model.MiscFeeAmt; fee.SoldPct = model.SoldPct; fee.UnsoldPct = model.UnsoldPct; if (model.AUFeesID > 0) { _feesRepo.Update(fee); //TODO: push into service } else { _feesRepo.Insert(fee); } return new NullJsonResult(); }
public ActionResult InheritFees(AUFeesRecord model) { //TODO: AUTHORIZE //if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) // return AccessDeniedView(); var fee = _feesRepo.GetById(model.AUFeesID); _feesRepo.Delete(fee); return new NullJsonResult(); }
public ActionResult DeleteFees(string btnIdToRefresh, string frmIdToRefresh, AUFeesRecord model) { //TODO: AUTHORIZE //if (!_permissionService.Authorize(StandardPermissionProvider.ManageCategories)) // return AccessDeniedView(); var fee = _feesRepo.GetById(model.AUFeesID); if (fee != null) //should not happen once you start hiding the inherit button on an inherited fee { _feesRepo.Delete(fee); ViewBag.RefreshPage = true; ViewBag.btnId = btnIdToRefresh; ViewBag.formId = frmIdToRefresh; } return new NullJsonResult(); }