Skip to content

Commit

Permalink
Select tax app on taxes configuration (#4631)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofzuraw authored Feb 26, 2024
1 parent 19d8bf9 commit 232cd2a
Show file tree
Hide file tree
Showing 38 changed files with 701 additions and 100 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-ears-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Previously we allowed user to select either flat rates or any tax app. To avoid problems if there are more tax apps installed this change adds ability to select tax app that will be used to calculated taxes per channel. User can also select tax app for country exception while configuring taxes. Related [RFC](https://github.com/saleor/saleor/issues/12942)
84 changes: 84 additions & 0 deletions introspection.json
Original file line number Diff line number Diff line change
Expand Up @@ -5428,6 +5428,18 @@
"description": null,
"fields": null,
"inputFields": [
{
"name": "identifier",
"description": "Canonical app ID. If not provided, the identifier will be generated based on app.id.\n\nAdded in Saleor 3.19.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "name",
"description": "Name of the app.",
Expand Down Expand Up @@ -116512,6 +116524,30 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "availableTaxApps",
"description": "List of tax apps that can be assigned to the channel. The list will be calculated by Saleor based on the apps that are subscribed to webhooks related to tax calculations: CHECKOUT_CALCULATE_TAXES\n\nAdded in Saleor 3.19.\n\nRequires one of the following permissions: AUTHENTICATED_STAFF_USER, MANAGE_APPS.",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "App",
"ofType": null
}
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "channelCurrencies",
"description": "List of all currencies supported by shop's channels.\n\nAdded in Saleor 3.1.\n\nRequires one of the following permissions: AUTHENTICATED_STAFF_USER, AUTHENTICATED_APP.",
Expand Down Expand Up @@ -122411,6 +122447,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "taxAppId",
"description": "The tax app id that will be used to calculate the taxes for the given channel. Empty value for `TAX_APP` set as `taxCalculationStrategy` means that Saleor will iterate over all installed tax apps. If multiple tax apps exist with provided tax app id use the `App` with newest `created` date. Will become mandatory in 4.0 for `TAX_APP` `taxCalculationStrategy`.\n\nAdded in Saleor 3.19.",
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "taxCalculationStrategy",
"description": "The default strategy to use for tax calculation in the given channel. Taxes can be calculated either using user-defined flat rates or with a tax app. Empty value means that no method is selected and taxes are not calculated.",
Expand Down Expand Up @@ -122650,6 +122698,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "taxAppId",
"description": "The tax app id that will be used to calculate the taxes for the given channel and country. If not provided, use the value from the channel's tax configuration.\n\nAdded in Saleor 3.19.",
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "taxCalculationStrategy",
"description": "A country-specific strategy to use for tax calculation. Taxes can be calculated either using user-defined flat rates or with a tax app. If not provided, use the value from the channel's tax configuration.",
Expand Down Expand Up @@ -122722,6 +122782,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "taxAppId",
"description": "The tax app identifier that will be used to calculate the taxes for the given channel and country. If not provided, use the value from the channel's tax configuration.\n\nAdded in Saleor 3.19.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "taxCalculationStrategy",
"description": "A country-specific strategy to use for tax calculation. Taxes can be calculated either using user-defined flat rates or with a tax app. If not provided, use the value from the channel's tax configuration.",
Expand Down Expand Up @@ -122958,6 +123030,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "taxAppId",
"description": "The tax app id that will be used to calculate the taxes for the given channel. Empty value for `TAX_APP` set as `taxCalculationStrategy` means that Saleor will iterate over all installed tax apps. If multiple tax apps exist with provided tax app id use the `App` with newest `created` date. Will become mandatory in 4.0 for `TAX_APP` `taxCalculationStrategy`.\n\nAdded in Saleor 3.19.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "taxCalculationStrategy",
"description": "The default strategy to use for tax calculation in the given channel. Taxes can be calculated either using user-defined flat rates or with a tax app. Empty value means that no method is selected and taxes are not calculated.",
Expand Down
22 changes: 22 additions & 0 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"context": "tabel column header",
"string": "Total"
},
"+Ps1jL": {
"string": "Be extra careful with taxes and payment apps, ensure your configuration selects other apps to be used"
},
"+RffqY": {
"context": "Dry run dialog object title",
"string": "Select object type to perform dry run on provided query"
Expand Down Expand Up @@ -4982,6 +4985,9 @@
"context": "dialog title",
"string": "Add Address"
},
"W2OIhn": {
"string": "Use app: {name}"
},
"W32xfN": {
"context": "staff member full name",
"string": "Name"
Expand Down Expand Up @@ -5198,6 +5204,9 @@
"context": "discount type",
"string": "Fixed amount"
},
"XFKV5Z": {
"string": "Created at: {date}"
},
"XFtKV5": {
"context": "input placeholder tag",
"string": "Tag"
Expand Down Expand Up @@ -6704,6 +6713,9 @@
"context": "button",
"string": "Send invite"
},
"hyAOPB": {
"string": "Use Avalara plugin"
},
"hz+9ES": {
"context": "bulk activate label",
"string": "Activate"
Expand Down Expand Up @@ -6979,6 +6991,9 @@
"k0rGBI": {
"string": "Access token is used to authenticate service accounts"
},
"k20lqw": {
"string": "Legacy flow detected - select tax strategy from dropdown"
},
"k3EI/U": {
"context": "dialog header",
"string": "Delete Shipping Zone"
Expand Down Expand Up @@ -8788,6 +8803,10 @@
"wQdR8M": {
"string": "Add search engine title and description to make this category easier to find"
},
"wRvjoc": {
"context": "app created at label",
"string": "Created at"
},
"wTHjt3": {
"string": "Search Orders..."
},
Expand Down Expand Up @@ -9187,6 +9206,9 @@
"context": "order history message",
"string": "Order was cancelled"
},
"zSDfq0": {
"string": "Use flat tax rate"
},
"zSOvI0": {
"string": "Filters"
},
Expand Down
3 changes: 1 addition & 2 deletions playwright/pages/taxesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ export class TaxesPage extends BasePage {
async clickCreateClassButton() {
await this.createClassButton.click();
}

async selectTaxCalculationMethod(method: "FLAT_RATES" | "TAX_APP") {
async selectTaxCalculationMethod(method: "FLAT_RATES" | "saleor.app.avatax") {
await this.clickSelectMethodField();
await this.page.getByTestId(`select-field-option-${method}`).click();
}
Expand Down
3 changes: 2 additions & 1 deletion playwright/tests/taxes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ test("TC: SALEOR_115 Change taxes in channel to use tax app @taxes @e2e", async
await configurationPage.gotoConfigurationView();
await configurationPage.openTaxes();
await taxesPage.selectChannel(CHANNELS.channelForTaxEdition.name);
await taxesPage.selectTaxCalculationMethod("TAX_APP");
await taxesPage.selectTaxCalculationMethod("saleor.app.avatax");
await taxesPage.clickSaveButton();
await taxesPage.expectSuccessBanner();
});

test("TC: SALEOR_116 Change taxes in channel: enter prices without tax, do not show gross price, add country exception @taxes @e2e", async () => {
await taxesPage.gotoChannelsTabUrl();
await taxesPage.selectChannel(CHANNELS.channelForTaxEdition.name);
Expand Down
44 changes: 44 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,13 @@ input AppFilterInput {
}

input AppInput {
"""
Canonical app ID. If not provided, the identifier will be generated based on app.id.

Added in Saleor 3.19.
"""
identifier: String

"""Name of the app."""
name: String

Expand Down Expand Up @@ -29732,6 +29739,15 @@ type Shop implements ObjectWithMetadata {
channel: String!
): [ShippingMethod!]

"""
List of tax apps that can be assigned to the channel. The list will be calculated by Saleor based on the apps that are subscribed to webhooks related to tax calculations: CHECKOUT_CALCULATE_TAXES

Added in Saleor 3.19.

Requires one of the following permissions: AUTHENTICATED_STAFF_USER, MANAGE_APPS.
"""
availableTaxApps: [App!]!

"""
List of all currencies supported by shop's channels.

Expand Down Expand Up @@ -31208,6 +31224,13 @@ type TaxConfiguration implements Node & ObjectWithMetadata {
"""
privateMetafields(keys: [String!]): Metadata

"""
The tax app id that will be used to calculate the taxes for the given channel. Empty value for `TAX_APP` set as `taxCalculationStrategy` means that Saleor will iterate over all installed tax apps. If multiple tax apps exist with provided tax app id use the `App` with newest `created` date. Will become mandatory in 4.0 for `TAX_APP` `taxCalculationStrategy`.

Added in Saleor 3.19.
"""
taxAppId: String

"""
The default strategy to use for tax calculation in the given channel. Taxes can be calculated either using user-defined flat rates or with a tax app. Empty value means that no method is selected and taxes are not calculated.
"""
Expand Down Expand Up @@ -31254,6 +31277,13 @@ type TaxConfigurationPerCountry {
"""
displayGrossPrices: Boolean!

"""
The tax app id that will be used to calculate the taxes for the given channel and country. If not provided, use the value from the channel's tax configuration.

Added in Saleor 3.19.
"""
taxAppId: String

"""
A country-specific strategy to use for tax calculation. Taxes can be calculated either using user-defined flat rates or with a tax app. If not provided, use the value from the channel's tax configuration.
"""
Expand All @@ -31272,6 +31302,13 @@ input TaxConfigurationPerCountryInput {
"""
displayGrossPrices: Boolean!

"""
The tax app identifier that will be used to calculate the taxes for the given channel and country. If not provided, use the value from the channel's tax configuration.

Added in Saleor 3.19.
"""
taxAppId: String

"""
A country-specific strategy to use for tax calculation. Taxes can be calculated either using user-defined flat rates or with a tax app. If not provided, use the value from the channel's tax configuration.
"""
Expand Down Expand Up @@ -31327,6 +31364,13 @@ input TaxConfigurationUpdateInput {
"""List of country codes for which to remove the tax configuration."""
removeCountriesConfiguration: [CountryCode!]

"""
The tax app id that will be used to calculate the taxes for the given channel. Empty value for `TAX_APP` set as `taxCalculationStrategy` means that Saleor will iterate over all installed tax apps. If multiple tax apps exist with provided tax app id use the `App` with newest `created` date. Will become mandatory in 4.0 for `TAX_APP` `taxCalculationStrategy`.

Added in Saleor 3.19.
"""
taxAppId: String

"""
The default strategy to use for tax calculation in the given channel. Taxes can be calculated either using user-defined flat rates or with a tax app. Empty value means that no method is selected and taxes are not calculated.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { AppPermissionFragment } from "@dashboard/graphql";
import { Box, InfoIcon, Tooltip } from "@saleor/macaw-ui-next";
import { Box, InfoIcon, Text, Tooltip } from "@saleor/macaw-ui-next";
import moment from "moment";
import React from "react";
import { FormattedMessage } from "react-intl";

import { messages } from "./messages";
import { useStyles } from "./styles";

interface AppPermissionsProps {
export const AppAdditionalInfo: React.FC<{
permissions?: AppPermissionFragment[] | null;
}

export const AppPermissions: React.FC<AppPermissionsProps> = ({
permissions,
}) => {
const classes = useStyles();

created: string | null;
}> = ({ permissions, created }) => {
return (
<Tooltip>
<Tooltip.Trigger>
Expand All @@ -27,20 +22,30 @@ export const AppPermissions: React.FC<AppPermissionsProps> = ({
<Tooltip.ContentHeading>
<FormattedMessage {...messages.appPermissions} />
</Tooltip.ContentHeading>
<ul className={classes.list}>
<Box as="ul" marginTop={0}>
{permissions?.length ? (
permissions?.map(permission => (
<li key={permission.code}>{permission.name}</li>
<Box as="li" key={permission.code}>
{permission.name}
</Box>
))
) : (
<li>
<Box as="li">
<FormattedMessage {...messages.noPermissions} />
</li>
</Box>
)}
</ul>
</Box>
{created && (
<>
<Tooltip.ContentHeading>
<FormattedMessage {...messages.createdAt} />
</Tooltip.ContentHeading>
<Text variant="caption">
{moment(created).format("YYYY-MM-DD HH:mm")}
</Text>
</>
)}
</Tooltip.Content>
</Tooltip>
);
};
AppPermissions.displayName = "AppPermissions";
export default AppPermissions;
1 change: 1 addition & 0 deletions src/apps/components/AppAdditionalInfo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { AppAdditionalInfo } from "./AppAdditionalInfo";
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ export const messages = defineMessages({
defaultMessage: "None",
description: "app permissions label",
},
createdAt: {
id: "wRvjoc",
defaultMessage: "Created at",
description: "app created at label",
},
});
Loading

0 comments on commit 232cd2a

Please sign in to comment.