a68a7f594d
- Add DTOs for tax switch operations including payloads and results. - Create SalesInvoiceFiscalSwitchService to handle sending and retrieving tax data. - Implement SalesInvoiceFiscalService for managing invoice tax submissions and results persistence. - Develop NamaTaxSwitchAdapter for interfacing with the external tax service. - Introduce NamaTaxRequestDto and related classes for structured tax requests.
30 lines
665 B
TypeScript
30 lines
665 B
TypeScript
import translates from '@/common/constants/translates/translates'
|
|
|
|
type EnumTranslateMap = Record<string, string>
|
|
type EnumsRegistry = Record<string, EnumTranslateMap>
|
|
|
|
export interface EnumTranslatedValue {
|
|
value: string | null | undefined
|
|
translate: string | null
|
|
}
|
|
|
|
export function translateEnumValue(
|
|
enumKey: keyof typeof translates.enums,
|
|
value: string | null | undefined,
|
|
): EnumTranslatedValue {
|
|
const enumsRegistry = translates.enums as EnumsRegistry
|
|
const enumMap = enumsRegistry[String(enumKey)]
|
|
|
|
if (!value) {
|
|
return {
|
|
value,
|
|
translate: null,
|
|
}
|
|
}
|
|
|
|
return {
|
|
value,
|
|
translate: enumMap?.[value] ?? null,
|
|
}
|
|
}
|