public static TaxSchedule MapToEntity(this TaxScheduleCreateDto dto) { var entity = new TaxSchedule(); switch (dto.ScheduleType) { case ScheduleType.Daily: entity.TaxEndDate = dto.TaxStartDate.Date; break; case ScheduleType.Weekly: entity.TaxEndDate = dto.TaxStartDate.AddDays(6).Date; break; case ScheduleType.Monthly: entity.TaxEndDate = dto.TaxStartDate.AddMonths(1).AddDays(-1).Date; break; case ScheduleType.Yearly: entity.TaxEndDate = dto.TaxStartDate.AddYears(1).AddDays(-1).Date; break; default: break; } entity.ScheduleType = dto.ScheduleType; entity.TaxStartDate = dto.TaxStartDate.Date; entity.Tax = dto.Tax; entity.MunicipalityId = dto.MunicipalityId; return(entity); }
private void LoadRates(TaxSchedule ts) { this.litRates.Text = string.Empty; foreach (Tax t in MTApp.OrderServices.Taxes.GetRates(MTApp.CurrentStore.Id, ts.Id)) { RenderTax(t); } }
private TaxSchedule CreateVilniusYearlyTaxSchedule() { var entry = new TaxScheduleEntryYearly(2016, 0.1); var schedule = new TaxSchedule("Vilnius"); schedule.AddEntry(entry); return(schedule); }
private TaxSchedule CreateVilniusChristmasTaxSchedule() { var entry = new TaxScheduleEntryDaily(2016, 12, 25, 0.1); var schedule = new TaxSchedule("Vilnius"); schedule.AddEntry(entry); return(schedule); }
private TaxSchedule CreateVilnius1stWeekOfSummerTaxSchedule() { var entry = new TaxScheduleEntryWeekly(2016, 6, 1, 0.7); var schedule = new TaxSchedule("Vilnius"); schedule.AddEntry(entry); return(schedule); }
private TaxSchedule CreateVilniusMonthlyTaxSchedule() { var entry = new TaxScheduleEntryMonthly(2016, 5, 0.4); var schedule = new TaxSchedule("Vilnius"); schedule.AddEntry(entry); return(schedule); }
private bool Save() { string ids = Request.QueryString["id"]; long id = long.Parse(ids); ts = MTApp.OrderServices.TaxSchedules.FindForThisStore(id); ts.Name = this.ScheduleNameField.Text; return(MTApp.OrderServices.TaxSchedules.Update(ts)); }
private void PostponePayment(TaxSchedule Tax) { Game1.addHUDMessage(new HUDMessage(Util.Helper.Translation.Get("PostponedPaymentText"), 2)); if (State.PostPoneDaysLeft > 0) { State.PostPoneDaysLeft -= 1; } Game1.chatBox.addInfoMessage(Util.Helper.Translation.Get("PostponeChatText").ToString().Replace("#playerName#", Game1.player.displayName).Replace("#Tax#", $"{State.PendingTaxAmount}")); OnPostPoneTaxesCompleted?.Invoke(this, new EventHandlerMessage(State.PendingTaxAmount, Game1.player.IsMale)); }
protected void btnCreate_Click(object sender, EventArgs e) { var t = new TaxSchedule { Name = txtDisplayName.Text.Trim() }; HccApp.OrderServices.TaxSchedules.Create(t); txtDisplayName.Text = string.Empty; EditedTaxScheduleId = t.Id; LoadTaxScheduleEditor(); }
public EconomyPage(UIFramework ui, Texture2D texture, string Hovertext, TaxationService taxation) : base(ui, texture, Hovertext) { this.taxation = taxation; //Elements.Add(new OptionsElement(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11233"))); //Elements.Add(new ContentElementText(Game1.content.LoadString("Strings\\StringsFromCSFiles:OptionsPage.cs.11234"))); Elements.Add(new ContentElementHeaderText(Util.Helper.Translation.Get("BalanceReportText"))); Elements.Add(new ContentElementText(() => $"{Util.Helper.Translation.Get("CurrentLotValueText")}: {taxation.LotValue.Sum}g")); Elements.Add(new ContentElementText(() => $"{Util.Helper.Translation.Get("CurrentTaxBalance")}: {taxation.State?.PendingTaxAmount}g")); TaxSchedule scheduledTask = null; CustomWorldDate date = null; load(); void load() { scheduledTask = taxation.State?.ScheduledTax.OrderBy(c => c.DayCount).FirstOrDefault(c => !c.Paid); date = scheduledTask?.DayCount.ToWorldDate(); }; Elements.Add(new ContentElementText(() => { load(); return(scheduledTask != null ? Util.Helper.Translation.Get("NextScheduledTaxText") : Util.Helper.Translation.Get("NoBillsForYouText")); })); Elements.Add(new ContentElementText(() => { return(scheduledTask != null ? $"{Game1.content.LoadString("Strings\\StringsFromCSFiles:Utility.cs.5678", date.DayOfMonth, (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.es) ? date.Season.GetLocalizedSeason().ToLower() : date.Season.GetLocalizedSeason(), date.Year)} - {scheduledTask.Sum}g" : ""); })); payButton = new ClickableComponent(new Rectangle(xPositionOnScreen + 64, Game1.activeClickableMenu.height + 50, (int)Game1.dialogueFont.MeasureString("_____________").X, 96), "", "_____________"); for (int i = 0; i < Elements.Count; ++i) { Slots.Add(new ClickableComponent( new Rectangle( xPositionOnScreen + Game1.tileSize / 4, yPositionOnScreen + Game1.tileSize * 5 / 4 + Game1.pixelZoom + i * (height - Game1.tileSize * 2) / 7, width - Game1.tileSize / 2, (height - Game1.tileSize * 2) / 7 + Game1.pixelZoom), i.ToString())); } this.Draw = DrawContent; this.DrawHover = DrawHoverContent; this.LeftClickAction += Leftclick; }
// Create or Update public override string PostAction(string parameters, System.Collections.Specialized.NameValueCollection querystring, string postdata) { string data = string.Empty; string ids = FirstParameter(parameters); long id = 0; long.TryParse(ids, out id); ApiResponse <TaxScheduleDTO> response = new ApiResponse <TaxScheduleDTO>(); TaxScheduleDTO postedCategory = null; try { postedCategory = MerchantTribe.Web.Json.ObjectFromJson <TaxScheduleDTO>(postdata); } catch (Exception ex) { response.Errors.Add(new ApiError("EXCEPTION", ex.Message)); return(MerchantTribe.Web.Json.ObjectToJson(response)); } TaxSchedule item = new TaxSchedule(); item.FromDto(postedCategory); if (id < 1) { TaxSchedule existing = MTApp.OrderServices.TaxSchedules.FindByName(item.Name); if (existing == null) { // Create MTApp.OrderServices.TaxSchedules.Create(item); } else { item.Id = existing.Id; } } else { MTApp.OrderServices.TaxSchedules.Update(item); } response.Content = item.ToDto(); data = MerchantTribe.Web.Json.ObjectToJson(response); return(data); }
/// <summary> /// Allows the REST API to create or update a tax schedule /// </summary> /// <param name="parameters"> /// Parameters passed in the URL of the REST API call. If there is a first parameter found in the /// URL, the method will assume it is the tax schedule ID and that this is an update, otherwise it assumes to create a /// tax schedule. /// </param> /// <param name="querystring">Name/value pairs from the REST API call querystring. This is not used in this method.</param> /// <param name="postdata">Serialized (JSON) version of the TaxScheduleDTO object</param> /// <returns>TaxDTO - Serialized (JSON) version of the tax schedule</returns> public override string PostAction(string parameters, NameValueCollection querystring, string postdata) { var data = string.Empty; var ids = FirstParameter(parameters); long id = 0; long.TryParse(ids, out id); var response = new ApiResponse <TaxScheduleDTO>(); TaxScheduleDTO postedCategory = null; try { postedCategory = Json.ObjectFromJson <TaxScheduleDTO>(postdata); } catch (Exception ex) { response.Errors.Add(new ApiError("EXCEPTION", ex.Message)); return(Json.ObjectToJson(response)); } var item = new TaxSchedule(); item.FromDto(postedCategory); if (id < 1) { var existing = HccApp.OrderServices.TaxSchedules.FindByNameForThisStore(item.Name); if (existing == null) { // Create HccApp.OrderServices.TaxSchedules.Create(item); } else { item.Id = existing.Id; } } else { HccApp.OrderServices.TaxSchedules.Update(item); } response.Content = item.ToDto(); data = Json.ObjectToJson(response); return(data); }
protected void btnAddNewRegion_Click(System.Object sender, System.Web.UI.ImageClickEventArgs e) { msg.ClearMessage(); try { MerchantTribe.Commerce.Taxes.TaxSchedule t = new TaxSchedule(); t.Name = this.DisplayNameField.Text.Trim(); MTApp.OrderServices.TaxSchedules.Create(t); msg.ShowOk("Added: " + t.Name); LoadSchedules(); DisplayNameField.Text = ""; } catch (Exception Ex) { msg.ShowException(Ex); } }
public bool Save() { var result = false; if (Page.IsValid) { TaxSchedule ts; if (TaxScheduleId.HasValue) { ts = HccApp.OrderServices.TaxSchedules.FindForThisStore(TaxScheduleId.Value); ts.Name = txtScheduleName.Text.Trim(); } else { ts = new TaxSchedule(); ts.Name = txtScheduleName.Text.Trim(); HccApp.OrderServices.TaxSchedules.Create(ts); TaxScheduleId = ts.TaxScheduleId(); } decimal defaultRate = 0; if (decimal.TryParse(txtDefaultRate.Text.Trim(), out defaultRate)) { ts.DefaultRate = defaultRate; } decimal defaultShippingRate = 0; if (decimal.TryParse(txtDefaultShippingRate.Text.Trim(), out defaultShippingRate)) { ts.DefaultShippingRate = defaultShippingRate; } result = HccApp.OrderServices.TaxSchedules.Update(ts); if (!result) { ucMessageBox.ShowError("Failed to update tax schedule"); } } return(result); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); msg.ClearMessage(); ts = new TaxSchedule(); if (!Page.IsPostBack) { string id = Request.QueryString["id"]; PopulateCountries(); string homeCountry = WebAppSettings.ApplicationCountryBvin; lstCountry.SelectedValue = homeCountry; PopulateRegions(lstCountry.SelectedItem.Value); LoadSchedule(long.Parse(id)); } }
internal void PayTaxes(TaxSchedule Tax = null) { if (Tax == null) { Tax = State.AllTaxScheduled.FirstOrDefault(); } if (Tax.Sum > Game1.player.Money) { Game1.addHUDMessage(new HUDMessage(Util.Helper.Translation.Get("PayTax_NotEnoughMoneyText"), 3)); return; } Game1.player.Money = Math.Max(0, Game1.player.Money - Tax.Sum); Tax.Paid = true; State.PostPoneDaysLeft = State.PostPoneDaysLeftDefault; Game1.addHUDMessage(new HUDMessage(Util.Helper.Translation.Get("TaxPaidText").ToString().Replace("#Tax#", $"{Tax.Sum}"), 2)); OnPayTaxesCompleted?.Invoke(this, new EventHandlerMessage(Tax.Sum, Game1.player.IsMale)); OnTaxScheduleListUpdated?.Invoke(this, State.AllUnpaidTaxScheduled.GetAllFromThisSeason(Game1.stats.DaysPlayed)); }
// List or Find Single public override string GetAction(string parameters, System.Collections.Specialized.NameValueCollection querystring) { string data = string.Empty; if (string.Empty == (parameters ?? string.Empty)) { // List ApiResponse <List <TaxScheduleDTO> > response = new ApiResponse <List <TaxScheduleDTO> >(); List <TaxSchedule> results = MTApp.OrderServices.TaxSchedules.FindAll(MTApp.CurrentStore.Id); List <TaxScheduleDTO> dto = new List <TaxScheduleDTO>(); foreach (TaxSchedule item in results) { dto.Add(item.ToDto()); } response.Content = dto; data = MerchantTribe.Web.Json.ObjectToJson(response); } else { // Find One Specific Category ApiResponse <TaxScheduleDTO> response = new ApiResponse <TaxScheduleDTO>(); string ids = FirstParameter(parameters); long id = 0; long.TryParse(ids, out id); TaxSchedule item = MTApp.OrderServices.TaxSchedules.Find(id); if (item == null) { response.Errors.Add(new ApiError("NULL", "Could not locate that item. Check id and try again.")); } else { response.Content = item.ToDto(); } data = MerchantTribe.Web.Json.ObjectToJson(response); } return(data); }
/// <summary> /// Adds the taxt schedule. /// </summary> //[TestMethod] //[Priority(2)] public void AddTaxtSchedule() { #region Arrange var taxtschedule0 = _irepo.GetAddTaxSchedule(); var t = new TaxSchedule { StoreId = _application.CurrentStore.Id, Name = taxtschedule0.Name, DefaultRate = taxtschedule0.DefaultRate, DefaultShippingRate = taxtschedule0.DefaultShippingRate, }; #endregion //Act/Arrange Assert.IsTrue(_application.OrderServices.TaxSchedules.Create(t)); //Act var resulttaxschedule = _application.OrderServices.TaxSchedules.FindByNameForThisStore(taxtschedule0.Name); //Assert Assert.AreEqual(taxtschedule0.Name, resulttaxschedule.Name); }
private bool CheckIfDateInRange(TaxSchedule schedule, DateTime date) { return(schedule.ScheduleRanges.Any(i => date.Date.Ticks >= i.StartDate.Date.Ticks && date.Date.Ticks <= i.EndDate.Date.Ticks)); }
private void LoadSchedule(long id) { ts = MTApp.OrderServices.TaxSchedules.FindForThisStore(id); this.ScheduleNameField.Text = ts.Name; LoadRates(ts); }
public async Task <IHttpActionResult> Add(Guid municipalityUuid, DateTime startPeriod, TaxSchedule schedule, double value) { var tax = new Tax { MunicipalityUuid = municipalityUuid, StartPeriod = startPeriod, Schedule = schedule, Value = value }; var entityUuid = await TaxService.Add(tax); if (entityUuid == Guid.Empty) { return(BadRequest()); } return(Ok(entityUuid)); }
public void OrderCalculator_TestBugWithFreeShipping_12738() { //InitBasicStubs(); var app = CreateHccAppInMemory(); // Create taxes var tax1 = new TaxSchedule { Name = "Tax1" }; var tax2 = new TaxSchedule { Name = "Tax2" }; app.OrderServices.TaxSchedules.Create(tax1); app.OrderServices.TaxSchedules.Create(tax2); var taxrate1 = new Tax { Rate = 10, ShippingRate = 5, CountryIsoAlpha3 = "USA", ApplyToShipping = true, TaxScheduleId = tax1.Id }; var taxrate2 = new Tax { Rate = 10, ShippingRate = 10, CountryIsoAlpha3 = "USA", ApplyToShipping = true, TaxScheduleId = tax2.Id }; app.OrderServices.Taxes.Create(taxrate1); app.OrderServices.Taxes.Create(taxrate2); // Prepare products var catA = new Category { Name = "Category A" }; var catB = new Category { Name = "Category B" }; var prod1 = new Product { ProductName = "Product 1", SitePrice = 100, TaxSchedule = tax1.Id }; var prod2 = new Product { ProductName = "Product 2", SitePrice = 50, TaxSchedule = tax2.Id }; app.CatalogServices.Categories.Create(catA); app.CatalogServices.Categories.Create(catB); app.CatalogServices.Products.Create(prod1); app.CatalogServices.Products.Create(prod2); app.CatalogServices.CategoriesXProducts.AddProductToCategory(prod1.Bvin, catA.Bvin); app.CatalogServices.CategoriesXProducts.AddProductToCategory(prod2.Bvin, catB.Bvin); // Prepare promotion var promFreeShipping = new Promotion { Mode = PromotionType.OfferForLineItems, Name = "FREE SHIPPING", IsEnabled = true }; promFreeShipping.AddQualification(new LineItemCategory(catA.Bvin)); promFreeShipping.AddAction(new LineItemFreeShipping()); app.MarketingServices.Promotions.Create(promFreeShipping); var o = new Order { StoreId = app.CurrentStore.Id }; var li1 = prod1.ConvertToLineItem(app, 1); var li2 = prod2.ConvertToLineItem(app, 1); o.Items.Add(li1); o.Items.Add(li2); // Create Shipping Method var sm = new ShippingMethod(); var flatRatePerOrder = new FlatRatePerOrder(); flatRatePerOrder.Settings.Amount = 2m; sm.Bvin = Guid.NewGuid().ToString(); sm.ShippingProviderId = flatRatePerOrder.Id; sm.Settings = flatRatePerOrder.Settings; sm.Adjustment = 0m; sm.Name = "Flat Rate Per Item"; sm.ZoneId = -100; // US All Zone app.OrderServices.ShippingMethods.Create(sm); app.OrderServices.EnsureDefaultZones(app.CurrentStore.Id); o.ShippingAddress.City = "Richmond"; o.ShippingAddress.CountryBvin = Country.UnitedStatesCountryBvin; o.ShippingAddress.Line1 = "124 Anywhere St."; o.ShippingAddress.PostalCode = "23233"; o.ShippingAddress.RegionBvin = "VA"; o.ShippingMethodId = sm.Bvin; o.ShippingProviderId = sm.ShippingProviderId; app.CalculateOrder(o); Assert.IsTrue(li1.IsMarkedForFreeShipping); Assert.IsFalse(li2.IsMarkedForFreeShipping); Assert.AreEqual(1.33m, li1.ShippingPortion); Assert.AreEqual(0.67m, li2.ShippingPortion); Assert.AreEqual(10m, li1.TaxPortion); Assert.AreEqual(5m, li2.TaxPortion); Assert.AreEqual(2m, o.TotalShippingBeforeDiscounts); Assert.AreEqual(2m, o.TotalShippingAfterDiscounts); Assert.AreEqual(15m, o.ItemsTax); Assert.AreEqual(0.14m, o.ShippingTax); Assert.AreEqual(15.14m, o.TotalTax); }
public async Task <IHttpActionResult> Update(Guid uuid, Guid municipalityUuid, DateTime startPeriod, TaxSchedule schedule) { try { var tax = new Tax { Uuid = uuid, MunicipalityUuid = municipalityUuid, StartPeriod = startPeriod, Schedule = schedule }; await TaxService.Update(tax); } catch { return(BadRequest()); } return(Ok()); }