feat: make companyCode optional (#458)

* feat:  make companyCode optional

* fix: 🐛 return empty string if no companyCode in order-fulfilled

* build: 👷 add changeset
This commit is contained in:
Adrian Pilarczyk 2023-05-12 10:51:00 +02:00 committed by GitHub
parent 9ecb6291a5
commit 0c039f59dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 9 deletions

View file

@ -0,0 +1,5 @@
---
"saleor-app-taxes": minor
---
Make companyCode optional in Avatax.

View file

@ -6,7 +6,7 @@ export const avataxConfigSchema = z.object({
username: z.string().min(1, { message: "Username requires at least one character." }),
password: z.string().min(1, { message: "Password requires at least one character." }),
isSandbox: z.boolean(),
companyCode: z.string().min(1, { message: "Company code requires at least one character." }),
companyCode: z.string().optional(),
isAutocommit: z.boolean(),
shippingTaxCode: z.string().optional(),
});

View file

@ -29,7 +29,7 @@ const mapPayload = ({ order, config }: CommitTransactionMapPayloadArgs): CommitT
return {
transactionCode,
companyCode: config.companyCode,
companyCode: config.companyCode ?? "",
documentType: DocumentType.SalesInvoice,
model: {
commit: true,

View file

@ -250,6 +250,7 @@ export const AvataxConfigurationForm = () => {
<TextField required label="Password" {...field} {...textFieldProps} />
)}
/>
{formState.errors.password && (
<FormHelperText error>{formState.errors.password.message}</FormHelperText>
)}
@ -260,15 +261,16 @@ export const AvataxConfigurationForm = () => {
control={control}
defaultValue={defaultValues.companyCode}
render={({ field }) => (
<TextField
required
type="text"
{...field}
label="Company code"
{...textFieldProps}
/>
<TextField type="text" {...field} label="Company code" {...textFieldProps} />
)}
/>
<FormHelperText>
{"When not provided, the default company will be used. "}
<AppLink href="https://developer.avalara.com/erp-integration-guide/sales-tax-badge/transactions/simple-transactions/company-codes/">
Read more
</AppLink>{" "}
about company codes.
</FormHelperText>
{formState.errors.companyCode && (
<FormHelperText error>{formState.errors.companyCode.message}</FormHelperText>
)}