@medusajs/tax
Version:
Medusa Tax module
114 lines • 5.89 kB
TypeScript
import { Context, DAL, InferEntityType, InternalModuleDeclaration, ITaxModuleService, ITaxProvider, ModulesSdkTypes, TaxRegionDTO, TaxTypes } from "@medusajs/framework/types";
import { ModulesSdkUtils } from "@medusajs/framework/utils";
import { TaxRate, TaxRateRule, TaxRegion } from "../models";
import { TaxProviderService } from ".";
type InjectedDependencies = {
baseRepository: DAL.RepositoryService;
taxRateService: ModulesSdkTypes.IMedusaInternalService<any>;
taxRegionService: ModulesSdkTypes.IMedusaInternalService<any>;
taxRateRuleService: ModulesSdkTypes.IMedusaInternalService<any>;
taxProviderService: TaxProviderService;
[key: `tp_${string}`]: ITaxProvider;
};
declare const TaxModuleService_base: ModulesSdkUtils.MedusaServiceReturnType<{
TaxRate: {
dto: TaxTypes.TaxRateDTO;
};
TaxRegion: {
dto: TaxTypes.TaxRegionDTO;
};
TaxRateRule: {
dto: TaxTypes.TaxRateRuleDTO;
};
TaxProvider: {
dto: TaxTypes.TaxProviderDTO;
};
}>;
export default class TaxModuleService extends TaxModuleService_base implements ITaxModuleService {
protected readonly moduleDeclaration: InternalModuleDeclaration;
protected readonly container_: InjectedDependencies;
protected baseRepository_: DAL.RepositoryService;
protected taxRateService_: ModulesSdkTypes.IMedusaInternalService<InferEntityType<typeof TaxRate>>;
protected taxRegionService_: ModulesSdkTypes.IMedusaInternalService<InferEntityType<typeof TaxRegion>>;
protected taxRateRuleService_: ModulesSdkTypes.IMedusaInternalService<InferEntityType<typeof TaxRateRule>>;
protected taxProviderService_: TaxProviderService;
constructor({ baseRepository, taxRateService, taxRegionService, taxRateRuleService, taxProviderService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
createTaxRates(data: TaxTypes.CreateTaxRateDTO[], sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
createTaxRates(data: TaxTypes.CreateTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO>;
protected createTaxRates_(data: TaxTypes.CreateTaxRateDTO[], sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
updateTaxRates(id: string, data: TaxTypes.UpdateTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO>;
updateTaxRates(ids: string[], data: TaxTypes.UpdateTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
updateTaxRates(selector: TaxTypes.FilterableTaxRateProps, data: TaxTypes.UpdateTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
protected updateTaxRates_(idOrSelector: string | string[] | TaxTypes.FilterableTaxRateProps, data: TaxTypes.UpdateTaxRateDTO, sharedContext?: Context): Promise<{
id: string;
rate: number | null;
code: string;
name: string;
is_default: boolean;
is_combinable: boolean;
tax_region: {
id: string;
country_code: string;
province_code: string | null;
metadata: Record<string, unknown> | null;
created_by: string | null;
provider: {
id: string;
is_enabled: boolean;
regions: any[];
created_at: Date;
updated_at: Date;
deleted_at: Date | null;
};
parent: any;
children: any[];
tax_rates: any[];
created_at: Date;
updated_at: Date;
deleted_at: Date | null;
provider_id: string | null;
parent_id: string | null;
};
rules: {
id: string;
metadata: Record<string, unknown> | null;
created_by: string | null;
tax_rate: any;
reference: string;
reference_id: string;
created_at: Date;
updated_at: Date;
deleted_at: Date | null;
tax_rate_id: string;
}[];
metadata: Record<string, unknown> | null;
created_by: string | null;
raw_rate: Record<string, unknown> | null;
created_at: Date;
updated_at: Date;
deleted_at: Date | null;
tax_region_id: string;
}>;
private setTaxRateRulesForTaxRates;
private getTaxRateIdsFromSelector;
upsertTaxRates(data: TaxTypes.UpsertTaxRateDTO[], sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
upsertTaxRates(data: TaxTypes.UpsertTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO>;
createTaxRegions(data: TaxTypes.CreateTaxRegionDTO, sharedContext?: Context): Promise<TaxRegionDTO>;
createTaxRegions(data: TaxTypes.CreateTaxRegionDTO[], sharedContext?: Context): Promise<TaxRegionDTO[]>;
createTaxRegions_(data: TaxTypes.CreateTaxRegionDTO[], sharedContext?: Context): Promise<TaxRegionDTO[]>;
createTaxRateRules(data: TaxTypes.CreateTaxRateRuleDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateRuleDTO>;
createTaxRateRules(data: TaxTypes.CreateTaxRateRuleDTO[], sharedContext?: Context): Promise<TaxTypes.TaxRateRuleDTO[]>;
createTaxRateRules_(data: TaxTypes.CreateTaxRateRuleDTO[], sharedContext?: Context): Promise<TaxTypes.TaxRateRuleDTO[]>;
getTaxLines(items: (TaxTypes.TaxableItemDTO | TaxTypes.TaxableShippingDTO)[], calculationContext: TaxTypes.TaxCalculationContext, sharedContext?: Context): Promise<(TaxTypes.ItemTaxLineDTO | TaxTypes.ShippingTaxLineDTO)[]>;
private getTaxLinesFromProvider;
private normalizeTaxCalculationContext;
private prepareTaxRegionInputForCreate;
private verifyProvinceToCountryMatch;
private getTaxRatesForItem;
private getTaxRateQueryForItem;
private checkRuleMatches;
private prioritizeRates;
private normalizeRegionCodes;
}
export {};
//# sourceMappingURL=tax-module-service.d.ts.map