Esempio n. 1
0
        public TaxModule() : base("/tax")
        {
            Get("/id/{id}", _ => GetTaxById(_));
            Get("/{municipality}/{year}/{month}/{day}", _ => GetTax(_));
            Post("/add", _ =>
            {
                try
                {
                    var model = this.Bind <Tax>();
                    Taxes.Add(model);

                    var r = Response.AsJson(model).WithHeader("Location", $"/tax/id/{model.Id}");
                    return(r);
                }
                catch (Exception e)
                {
                    return(Helper.ErrorResponse(e, HttpStatusCode.InternalServerError));
                }
            });
            Put("/{id}", _ =>
            {
                try
                {
                    var request = this.Bind <RequestObject>();
                    var model   = this.Bind <Tax>();
                    Taxes.UpdateTax(request.Id, model);

                    return(model);
                }
                catch (Exception e)
                {
                    return(Helper.ErrorResponse(e, HttpStatusCode.InternalServerError));
                }
            });
            Delete("/{id}", _ =>
            {
                try
                {
                    var request = this.Bind <RequestObject>();
                    Taxes.Delete(request.Id);

                    return(HttpStatusCode.NoContent);
                }
                catch (Exception e)
                {
                    return(Helper.ErrorResponse(e, HttpStatusCode.InternalServerError));
                }
            });
        }
Esempio n. 2
0
        // Taxes

        public bool TaxSchedulesDestroy(long scheduleId)
        {
            try
            {
                List <Tax> taxes = Taxes.FindByTaxSchedule(context.CurrentStore.Id, scheduleId);
                foreach (Tax t in taxes)
                {
                    Taxes.Delete(t.Id);
                }
                TaxSchedules.Delete(scheduleId);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public void ClearTaxes(FSAppointment appointmentRow)
        {
            if (appointmentRow == null)
            {
                return;
            }

            if (IsExternalTax(appointmentRow.TaxZoneID))
            {
                foreach (PXResult <FSAppointmentTaxTran, Tax> res in Taxes.View.SelectMultiBound(new object[] { appointmentRow }))
                {
                    FSAppointmentTaxTran taxTran = (FSAppointmentTaxTran)res;
                    Taxes.Delete(taxTran);
                }

                appointmentRow.CuryTaxTotal = 0;
                appointmentRow.CuryDocTotal = GetCuryDocTotal(appointmentRow.CuryBillableLineTotal, appointmentRow.CuryDiscTot,
                                                              0, 0);
            }
        }