{"version":3,"file":"invoiceConfigurationStore-1f1fb88a.js","sources":["../../src/app/services/generated/invoicerulesService.ts","../../src/store/modules/invoiceConfigurationStore.ts"],"sourcesContent":["import Guid from \"@/app/types/common/guid\";\nimport { Instant, LocalDate, LocalTime } from \"@js-joda/core\";\nimport {ModelObject, BaseModelObject, ValidationRule} from \"@/app/services/modelObject\";\nimport ServiceBase from \"@/app/services/serviceBase\";\nimport converters from \"@/app/services/converters\"\n\n// Model Objects\n\nexport class InvoiceFieldRequirement extends ModelObject {\n\n public show: boolean = false;\n public required: boolean = false;\n\n public constructor(jsonSerializedObject?: any) {\n super();\n if (jsonSerializedObject) {\n this.show = jsonSerializedObject.show;\n this.required = jsonSerializedObject.required;\n }\n\n }\n\n public toJsonSerializedObject(): any {\n const toRet = {} as any;\n toRet.show = this.show;\n toRet.required = this.required;\n return toRet;\n }\n\n public toProto(): any {\n return this.toJsonSerializedObject();\n }\n\n public toBinary(): Uint8Array {\n return new TextEncoder().encode(JSON.stringify(this.toJsonSerializedObject()));\n }\n\n public validationRules: ValidationRule = [\n ];\n}\n\n\nexport class InvoiceRequirements extends ModelObject {\n\n public invoiceRecipientTaxNumber: InvoiceFieldRequirement = new InvoiceFieldRequirement();\n\n public constructor(jsonSerializedObject?: any) {\n super();\n if (jsonSerializedObject) {\n this.invoiceRecipientTaxNumber = new InvoiceFieldRequirement(jsonSerializedObject.invoiceRecipientTaxNumber);\n }\n\n }\n\n public toJsonSerializedObject(): any {\n const toRet = {} as any;\n toRet.invoiceRecipientTaxNumber = this.invoiceRecipientTaxNumber.toJsonSerializedObject();\n return toRet;\n }\n\n public toProto(): any {\n return this.toJsonSerializedObject();\n }\n\n public toBinary(): Uint8Array {\n return new TextEncoder().encode(JSON.stringify(this.toJsonSerializedObject()));\n }\n\n public validationRules: ValidationRule = [\n {field: \"invoiceRecipientTaxNumber\", rule: (v: any) => !!v || \"invoiceRecipientTaxNumber is required\"},\n {field: \"invoiceRecipientTaxNumber\", rule: (v: any) => v.validate()},\n ];\n}\n\n\nexport class GetInvoiceRequirementsRequest extends ModelObject {\n\n public tenantId: Guid = Guid.createEmpty();\n\n public constructor(jsonSerializedObject?: any) {\n super();\n if (jsonSerializedObject) {\n this.tenantId = Guid.fromString(jsonSerializedObject.tenantId);\n }\n\n }\n\n public toJsonSerializedObject(): any {\n const toRet = {} as any;\n toRet.tenantId = this.tenantId.toString();\n return toRet;\n }\n\n public toProto(): any {\n return this.toJsonSerializedObject();\n }\n\n public toBinary(): Uint8Array {\n return new TextEncoder().encode(JSON.stringify(this.toJsonSerializedObject()));\n }\n\n public validationRules: ValidationRule = [\n {field: \"tenantId\", rule: (v: any) => !v.isEmpty() || \".TenantId cannot be empty\"},\n ];\n}\n\n\nexport class GetInvoiceRequirementsResponse extends ModelObject {\n\n public requirements: InvoiceRequirements = new InvoiceRequirements();\n\n public constructor(jsonSerializedObject?: any) {\n super();\n if (jsonSerializedObject) {\n this.requirements = new InvoiceRequirements(jsonSerializedObject.requirements);\n }\n\n }\n\n public toJsonSerializedObject(): any {\n const toRet = {} as any;\n toRet.requirements = this.requirements.toJsonSerializedObject();\n return toRet;\n }\n\n public toProto(): any {\n return this.toJsonSerializedObject();\n }\n\n public toBinary(): Uint8Array {\n return new TextEncoder().encode(JSON.stringify(this.toJsonSerializedObject()));\n }\n\n public validationRules: ValidationRule = [\n {field: \"requirements\", rule: (v: any) => !!v || \"requirements is required\"},\n {field: \"requirements\", rule: (v: any) => v.validate()},\n ];\n}\n\n\nexport class InvoiceRulesService extends ServiceBase {\n\n public async getInvoiceRequirements(tenantId: Guid, opts?: {requestTimeoutMs?: number, sessionToken?: string}): Promise {\n const req = new GetInvoiceRequirementsRequest();\n req.tenantId = tenantId;\n const extractor = (response:any) => new GetInvoiceRequirementsResponse(response).requirements;\n return this.makeJsonRequest(\"invoiceRules/v1/getInvoiceRequirements\", req.toJsonSerializedObject(), extractor, opts);\n };\n}\n\nexport const invoiceRulesService = new InvoiceRulesService();","import api from \"@/app/api\";\nimport type { InvoiceRequirements } from \"@/app/services/generated/invoicerulesService\";\nimport { invoiceRulesService } from \"@/app/services/generated/invoicerulesService\";\nimport userStore from \"@/store/modules/userStore\";\nimport { reactive, readonly, watch } from \"vue\";\n\ninterface InvoiceConfigurationStoreState {\n invoiceRequirements: InvoiceRequirements | null;\n}\n\nconst state = reactive({\n invoiceRequirements: null,\n});\n\nconst refreshStore = async () => {\n [state.invoiceRequirements] = await Promise.all([\n invoiceRulesService.getInvoiceRequirements(api.tenantId),\n ]);\n};\n\nwatch(\n () => userStore.state.tenant,\n async () => {\n if (userStore.state.tenant) {\n await refreshStore();\n }\n },\n { immediate: true }\n);\n\nexport default {\n state: readonly(state),\n refreshStore,\n};\n"],"names":[],"mappings":"mfAQO,MAAM,gCAAgC,WAAqC,CAKvE,YAAY,qBAA4B,CACrC,QAJH,0BAAgB,IAChB,8BAAoB,IA0BpB,qCAAkC,CAAA,GAtBjC,uBACF,KAAK,KAAO,qBAAqB,KACjC,KAAK,SAAW,qBAAqB,SAG3C,CAEO,wBAA8B,CACjC,MAAM,MAAQ,CAAA,EACd,aAAM,KAAO,KAAK,KAClB,MAAM,SAAW,KAAK,SACf,KACX,CAEO,SAAe,CACpB,OAAO,KAAK,wBACd,CAEO,UAAuB,CACrB,OAAA,IAAI,YAAc,EAAA,OAAO,KAAK,UAAU,KAAK,uBAAwB,CAAA,CAAC,CAC/E,CAIJ,CA/Ba,0DAkCN,MAAM,4BAA4B,WAAiC,CAI/D,YAAY,qBAA4B,CACrC,QAHH,+CAAqD,IAAI,yBAwBzD,qCAAkC,CACjC,CAAC,MAAO,4BAA6B,KAAO,GAAW,CAAC,CAAC,GAAK,uCAAuC,EACrG,CAAC,MAAO,4BAA6B,KAAO,GAAW,EAAE,UAAU,CAAA,GAtBnE,uBACF,KAAK,0BAA4B,IAAI,wBAAwB,qBAAqB,yBAAyB,EAGjH,CAEO,wBAA8B,CACjC,MAAM,MAAQ,CAAA,EACR,aAAA,0BAA4B,KAAK,0BAA0B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