2023-01-09 09:55:12 +00:00
|
|
|
import {
|
|
|
|
getTaxClassList,
|
|
|
|
getTaxConfigurationList,
|
|
|
|
updateTaxes,
|
|
|
|
} from "../requests/Taxes";
|
|
|
|
|
|
|
|
export function updateTaxConfigurationForChannel({
|
2023-01-25 10:32:28 +00:00
|
|
|
channelSlug = "default-channel",
|
2023-01-09 09:55:12 +00:00
|
|
|
chargeTaxes = true,
|
|
|
|
taxCalculationStrategy = "FLAT_RATES",
|
2023-01-25 10:32:28 +00:00
|
|
|
pricesEnteredWithTax = "false",
|
2023-01-09 09:55:12 +00:00
|
|
|
}) {
|
|
|
|
getTaxConfigurationList().then(taxConfigurationList => {
|
|
|
|
const taxConfigurationForChannel = taxConfigurationList.find(
|
|
|
|
taxConfiguration => taxConfiguration.node.channel.slug === channelSlug,
|
|
|
|
);
|
|
|
|
updateTaxes({
|
|
|
|
id: taxConfigurationForChannel.node.id,
|
|
|
|
chargeTaxes,
|
|
|
|
taxCalculationStrategy,
|
2023-01-25 10:32:28 +00:00
|
|
|
pricesEnteredWithTax,
|
2023-01-09 09:55:12 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getDefaultTaxClass() {
|
|
|
|
getTaxClassList().then(taxClassArray => {
|
|
|
|
const taxClass = taxClassArray.find(
|
|
|
|
taxClassItem => taxClassItem.node.name === "No Taxes",
|
|
|
|
);
|
|
|
|
return taxClass.node;
|
|
|
|
});
|
|
|
|
}
|