예제 #1
0
        public static void ViewHandler(TaxCalcForm tf)
        {
            TaxableEntity te = GetEntityFromUI(tf);

            if (te == null)
            {
                ShowError();
                return;
            }
            string archetype        = ComputeArchetype(te);
            COMPUTATION_CONTEXT ctx = new COMPUTATION_CONTEXT();
            TaxDTO td = new TaxDTO {
                id = te.id, taxparams = te.taxparams
            };

            ctx.Put("tax_cargo", td);
            bool rs = CommandDispatcher.Dispatch(archetype, ctx);

            if (rs)
            {
                TaxDTO temp = (TaxDTO)ctx.Get("tax_cargo");
                tf.Liabilitytxt.Text = Convert.ToString(temp.taxparams.TaxLiability);
                tf.Refresh();
            }
        }
예제 #2
0
        private void ImportTaxes()
        {
            Header("Importing Taxes");

            Api oldProxy = GetOldStoreBV6Proxy();
            ApiResponse <List <TaxDTO> > items = oldProxy.TaxesFindAll();

            foreach (TaxDTO old in items.Content)
            {
                wl("Tax: " + old.CountryName + ", " + old.RegionAbbreviation + " " + old.PostalCode);

                long   oldId = old.TaxScheduleId;
                TaxDTO tx    = old;
                if (TaxScheduleMapper.ContainsKey(oldId))
                {
                    tx.TaxScheduleId = TaxScheduleMapper[oldId];
                }

                Api bv6proxy = GetBV6Proxy();
                var res      = bv6proxy.TaxesCreate(tx);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        wl("SUCCESS");
                    }
                }
            }
        }
예제 #3
0
        public async Task <ActionResult> pvwEditTax([FromBody] TaxDTO _sarpara)
        {
            TaxDTO _Tax = new TaxDTO();

            try
            {
                string     baseadress = config.Value.urlbase;
                HttpClient _client    = new HttpClient();
                _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                var result = await _client.GetAsync(baseadress + "api/Tax/GetTaxById/" + _sarpara.TaxId);

                string valorrespuesta = "";
                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta = await(result.Content.ReadAsStringAsync());
                    _Tax           = JsonConvert.DeserializeObject <TaxDTO>(valorrespuesta);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                throw ex;
            }



            return(PartialView(_Tax));
        }
예제 #4
0
        public ActionResult UpdateTax(TaxDTO Tx)
        {
            int Count = posMasters.UpdateTax(Tx);

            return(new JsonResult {
                Data = Count, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #5
0
        public ActionResult SaveTax(TaxDTO Tx)
        {
            Tx.statusid  = 1;
            Tx.createdby = Convert.ToInt64(Session["UserId"]);
            int Count = posMasters.SaveTax(Tx);

            return(new JsonResult {
                Data = Count, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #6
0
        //DTO
        public TaxDTO ToDto()
        {
            TaxDTO dto = new TaxDTO();

            dto.ApplyToShipping = this.ApplyToShipping;
            dto.CountryName     = this.CountryName;
            dto.Id                 = this.Id;
            dto.PostalCode         = this.PostalCode;
            dto.Rate               = this.Rate;
            dto.RegionAbbreviation = this.RegionAbbreviation;
            dto.StoreId            = this.StoreId;
            dto.TaxScheduleId      = this.TaxScheduleId;

            return(dto);
        }
예제 #7
0
        public void FromDto(TaxDTO dto)
        {
            if (dto == null)
            {
                return;
            }

            this.ApplyToShipping = dto.ApplyToShipping;
            this.CountryName     = dto.CountryName;
            this.Id                 = dto.Id;
            this.PostalCode         = dto.PostalCode;
            this.Rate               = dto.Rate;
            this.RegionAbbreviation = dto.RegionAbbreviation;
            this.StoreId            = dto.StoreId;
            this.TaxScheduleId      = dto.TaxScheduleId;
        }
예제 #8
0
        public async Task <ActionResult <Tax> > SaveTax([FromBody] TaxDTO _TaxP)
        {
            Tax _Tax = _TaxP;

            try
            {
                // DTO_NumeracionSAR _liNumeracionSAR = new DTO_NumeracionSAR();
                string     baseadress = config.Value.urlbase;
                HttpClient _client    = new HttpClient();
                _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                var result = await _client.GetAsync(baseadress + "api/Tax/GetTaxById/" + _Tax.TaxId);

                string valorrespuesta = "";
                _Tax.FechaModificacion   = DateTime.Now;
                _Tax.UsuarioModificacion = HttpContext.Session.GetString("user");
                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta = await(result.Content.ReadAsStringAsync());
                    _Tax           = JsonConvert.DeserializeObject <TaxDTO>(valorrespuesta);
                }

                if (_Tax == null)
                {
                    _Tax = new Models.Tax();
                }

                if (_TaxP.TaxId == 0)
                {
                    _Tax.FechaCreacion   = DateTime.Now;
                    _Tax.UsuarioCreacion = HttpContext.Session.GetString("user");
                    var insertresult = await Insert(_TaxP);
                }
                else
                {
                    _TaxP.UsuarioCreacion = _Tax.UsuarioCreacion;
                    _TaxP.FechaCreacion   = _Tax.FechaCreacion;
                    var updateresult = await Update(_Tax.TaxId, _TaxP);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                throw ex;
            }

            return(Json(_Tax));
        }
예제 #9
0
        /// <summary>
        ///     Allows you to populate the current tax object using an TaxDTO instance
        /// </summary>
        /// <param name="dto">An instance of the tax from the REST API</param>
        public void FromDto(TaxDTO dto)
        {
            if (dto == null)
            {
                return;
            }

            ApplyToShipping  = dto.ApplyToShipping;
            CountryIsoAlpha3 = dto.CountryIsoAlpha3;
            Id                 = dto.Id;
            PostalCode         = dto.PostalCode;
            Rate               = dto.Rate;
            ShippingRate       = dto.ShippingRate;
            RegionAbbreviation = dto.RegionAbbreviation;
            StoreId            = dto.StoreId;
            TaxScheduleId      = dto.TaxScheduleId;
        }
예제 #10
0
        /// <summary>
        ///     Allows you to convert the current tax object to the DTO equivalent for use with the REST API
        /// </summary>
        /// <returns>A new instance of TaxDTO</returns>
        public TaxDTO ToDto()
        {
            var dto = new TaxDTO
            {
                ApplyToShipping  = ApplyToShipping,
                CountryIsoAlpha3 = CountryIsoAlpha3,
                Id                 = Id,
                PostalCode         = PostalCode,
                Rate               = Rate,
                ShippingRate       = ShippingRate,
                RegionAbbreviation = RegionAbbreviation,
                StoreId            = StoreId,
                TaxScheduleId      = TaxScheduleId
            };

            return(dto);
        }
예제 #11
0
        public void Taxes_TestCreateAndFindAndDelete()
        {
            //Create API Proxy.
            var proxy = CreateApiProxy();

            //Get list of all tax schedules
            var lstOfTaxSchedule = proxy.TaxSchedulesFindAll();

            //Create Tax
            var tax = new TaxDTO
            {
                Rate             = 5,
                ShippingRate     = 5,
                ApplyToShipping  = true,
                StoreId          = 1,
                PostalCode       = "33401",
                CountryIsoAlpha3 = "US",
                TaxScheduleId    = lstOfTaxSchedule.Content.First().Id
            };
            var createResponse = proxy.TaxesCreate(tax);

            CheckErrors(createResponse);
            Assert.IsFalse(createResponse.Content.Id == 0);

            //Find Tax
            var findResponse = proxy.TaxesFind(createResponse.Content.Id);

            CheckErrors(findResponse);
            Assert.AreEqual(createResponse.Content.Rate, findResponse.Content.Rate);
            Assert.AreEqual(createResponse.Content.ShippingRate, findResponse.Content.ShippingRate);

            //Update Tax
            createResponse.Content.ShippingRate = 10;
            createResponse.Content.Rate         = 10;
            var updateResponse = proxy.TaxesUpdate(createResponse.Content);

            CheckErrors(updateResponse);
            Assert.AreEqual(createResponse.Content.ShippingRate, updateResponse.Content.ShippingRate);
            Assert.AreEqual(createResponse.Content.Rate, updateResponse.Content.Rate);

            //Delete Tax
            var deleteResponse = proxy.TaxesDelete(createResponse.Content.Id);

            CheckErrors(deleteResponse);
            Assert.IsTrue(deleteResponse.Content);
        }
예제 #12
0
        /// <summary>
        ///     Allows the REST API to create or update a tax
        /// </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 ID and that this is an update, otherwise it assumes to create a tax.
        /// </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 TaxDTO object</param>
        /// <returns>TaxDTO - Serialized (JSON) version of the tax</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 <TaxDTO>();

            TaxDTO postedCategory = null;

            try
            {
                postedCategory = Json.ObjectFromJson <TaxDTO>(postdata);
            }
            catch (Exception ex)
            {
                response.Errors.Add(new ApiError("EXCEPTION", ex.Message));
                return(Json.ObjectToJson(response));
            }

            var item = new Tax();

            item.FromDto(postedCategory);

            if (id < 1)
            {
                if (!HccApp.OrderServices.Taxes.ExactMatchExists(item))
                {
                    if (HccApp.OrderServices.Taxes.Create(item))
                    {
                        id = item.Id;
                    }
                }
            }
            else
            {
                HccApp.OrderServices.Taxes.Update(item);
            }
            response.Content = item.ToDto();
            data             = Json.ObjectToJson(response);
            return(data);
        }
예제 #13
0
 public IHttpActionResult Put([FromUri] int id, [FromBody] TaxDTO Tax)
 {
     TaxService.PrePutDTO(ModelState, currentClient, id, Tax);
     return(Ok());
 }
예제 #14
0
 public TaxDTO Post([FromBody] TaxDTO Tax)
 {
     return(TaxService.PrePostDTO(ModelState, currentClient, Tax));
 }