fix: Tax region + rates clean up (#9279)
What - Require `code` on Tax Rates - Update dashboard to account for non-nullable code on Tax Rates - Include `automatic_taxes` in API Route response Closes CC-524 CC-525
This commit is contained in:
+1
@@ -59,6 +59,7 @@ export const EditRegionForm = ({
|
||||
await updateRegion(
|
||||
{
|
||||
name: values.name,
|
||||
automatic_taxes: values.automatic_taxes,
|
||||
currency_code: values.currency_code.toLowerCase(),
|
||||
payment_providers: values.payment_providers,
|
||||
is_tax_inclusive: values.is_tax_inclusive,
|
||||
|
||||
+14
-14
@@ -21,12 +21,10 @@ type TaxRegionCreateFormProps = {
|
||||
const TaxRegionCreateSchema = z.object({
|
||||
name: z.string().optional(),
|
||||
code: z.string().optional(),
|
||||
rate: z
|
||||
.object({
|
||||
float: z.number().optional(),
|
||||
value: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
rate: z.object({
|
||||
float: z.number().optional(),
|
||||
value: z.string().optional(),
|
||||
}),
|
||||
country_code: z.string().min(1),
|
||||
})
|
||||
|
||||
@@ -49,14 +47,16 @@ export const TaxRegionCreateForm = ({ parentId }: TaxRegionCreateFormProps) => {
|
||||
const { mutateAsync, isPending } = useCreateTaxRegion()
|
||||
|
||||
const handleSubmit = form.handleSubmit(async (values) => {
|
||||
const defaultRate =
|
||||
values.name && values.rate?.float
|
||||
? {
|
||||
name: values.name,
|
||||
rate: values.rate.float,
|
||||
code: values.code,
|
||||
}
|
||||
: undefined
|
||||
const defaultRate = values.name
|
||||
? {
|
||||
name: values.name,
|
||||
rate:
|
||||
values.rate?.value === ""
|
||||
? undefined
|
||||
: parseFloat(values.rate.value!),
|
||||
code: values.code,
|
||||
}
|
||||
: undefined
|
||||
|
||||
await mutateAsync(
|
||||
{
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ type TaxRegionProvinceCreateFormProps = {
|
||||
const CreateTaxRegionProvinceSchema = z.object({
|
||||
province_code: z.string().min(1),
|
||||
name: z.string().optional(),
|
||||
code: z.string().optional(),
|
||||
code: z.string().min(1),
|
||||
rate: z
|
||||
.object({
|
||||
float: z.number().optional(),
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ import { createTaxRulePayload } from "../../../common/utils"
|
||||
|
||||
const TaxRegionCreateTaxOverrideSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
code: z.string().optional(),
|
||||
code: z.string().min(1),
|
||||
rate: z
|
||||
.object({
|
||||
float: z.number().optional(),
|
||||
@@ -408,7 +408,7 @@ export const TaxRegionCreateTaxOverrideForm = ({
|
||||
render={({ field }) => {
|
||||
return (
|
||||
<Form.Item>
|
||||
<Form.Label optional>
|
||||
<Form.Label>
|
||||
{t("taxRegions.fields.taxCode")}
|
||||
</Form.Label>
|
||||
<Form.Control>
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ const getStackedModalId = (type: TaxRateRuleReferenceType) =>
|
||||
|
||||
const TaxRegionTaxRateEditSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
code: z.string().optional(),
|
||||
code: z.string().min(1),
|
||||
rate: z.object({
|
||||
float: z.number().optional(),
|
||||
value: z.string().optional(),
|
||||
@@ -80,7 +80,7 @@ export const TaxRegionTaxOverrideEditForm = ({
|
||||
const form = useForm<z.infer<typeof TaxRegionTaxRateEditSchema>>({
|
||||
defaultValues: {
|
||||
name: taxRate.name,
|
||||
code: taxRate.code || "",
|
||||
code: taxRate.code,
|
||||
rate: {
|
||||
value: taxRate.rate?.toString() || "",
|
||||
},
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ type TaxRegionTaxRateCreateFormProps = {
|
||||
|
||||
const TaxRegionTaxRateCreateSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
code: z.string().optional(),
|
||||
code: z.string().min(1),
|
||||
rate: z
|
||||
.object({
|
||||
float: z.number().optional(),
|
||||
@@ -57,7 +57,7 @@ export const TaxRegionTaxRateCreateForm = ({
|
||||
tax_region_id: taxRegion.id,
|
||||
is_default: true,
|
||||
name: values.name,
|
||||
code: values.code || undefined,
|
||||
code: values.code,
|
||||
rate: values.rate?.float,
|
||||
is_combinable: values.is_combinable,
|
||||
},
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ export const TaxRegionTaxRateEditForm = ({
|
||||
const form = useForm<z.infer<typeof TaxRegionTaxRateEditSchema>>({
|
||||
defaultValues: {
|
||||
name: taxRate.name,
|
||||
code: taxRate.code || "",
|
||||
code: taxRate.code,
|
||||
rate: {
|
||||
value: taxRate.rate?.toString() || "",
|
||||
},
|
||||
@@ -51,7 +51,7 @@ export const TaxRegionTaxRateEditForm = ({
|
||||
await mutateAsync(
|
||||
{
|
||||
name: values.name,
|
||||
code: values.code || null,
|
||||
code: values.code,
|
||||
rate: values.rate?.float,
|
||||
is_combinable: values.is_combinable,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user