Repository navigation
Store the ticket billing country as an ISO code #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6a69990
Store the ticket billing country as an ISO 3166-1 alpha-2 code
claude 229d3a4
Merge branch 'main' into billing-country-iso
Jan0707 d93ec8b
Fix HTML entity encoding in TicketCountrySelect.vue
Jan0707 7f46885
Make 'Bitte Land auswählen' option required
Jan0707 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...ctus-extension-programmierbar-bundle/src/shared/__tests__/invoice-billing-country.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { describe, expect, jest, test } from '@jest/globals' | ||
| import PDFDocument from 'pdfkit' | ||
| import { generateInvoicePdf, type InvoiceData } from '../invoice-generator.ts' | ||
|
|
||
| // `import.meta.url` in the font loader cannot be parsed by Jest's CJS transform. | ||
| jest.mock('../museo-font.ts', () => ({ tryLoadMuseoFont: () => null })) | ||
|
|
||
| const INVOICE: InvoiceData = { | ||
| invoiceNumber: 'PB-CON26-001', | ||
| invoiceDate: '20.10.2026', | ||
| purchaserName: 'Mika Muster', | ||
| purchaserEmail: 'mika@example.com', | ||
| companyName: 'Beispiel GmbH', | ||
| companyVatId: null, | ||
| billingAddressLine1: 'Musterstraße 1', | ||
| billingAddressLine2: null, | ||
| billingCity: 'Wien', | ||
| billingPostalCode: '1010', | ||
| billingCountry: null, | ||
| conferenceTitle: 'Konferenz 2026', | ||
| ticketType: 'Regular', | ||
| ticketCount: 1, | ||
| unitPriceGrossCents: 11900, | ||
| subtotalCents: 10000, | ||
| discountAmountCents: 0, | ||
| vatAmountCents: 1900, | ||
| totalGrossCents: 11900, | ||
| } | ||
|
|
||
| /** Render the invoice and return every string drawn into it. */ | ||
| async function renderedTexts(billingCountry: string | null) { | ||
| const text = jest.spyOn(PDFDocument.prototype, 'text') | ||
| try { | ||
| await generateInvoicePdf({ ...INVOICE, billingCountry }) | ||
| return text.mock.calls.map(([value]) => value) | ||
| } finally { | ||
| text.mockRestore() | ||
| } | ||
| } | ||
|
|
||
| describe('invoice billing country', () => { | ||
| test('prints an ISO code as the German country name', async () => { | ||
| const texts = await renderedTexts('AT') | ||
|
|
||
| expect(texts).toContain('Österreich') | ||
| expect(texts).not.toContain('AT') | ||
| }) | ||
|
|
||
| test('prints legacy free text exactly as it was entered', async () => { | ||
| expect(await renderedTexts('Germany')).toContain('Germany') | ||
| expect(await renderedTexts('Deutschland')).toContain('Deutschland') | ||
| }) | ||
|
|
||
| test('prints no country line when the country is missing or blank', async () => { | ||
| const withCountry = await renderedTexts('AT') | ||
|
|
||
| for (const missing of [null, '', ' ']) { | ||
| const texts = await renderedTexts(missing) | ||
| expect(texts).toEqual(withCountry.filter((value) => value !== 'Österreich')) | ||
| } | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <script setup lang="ts"> | ||
| import { BILLING_COUNTRIES } from 'shared-code' | ||
|
|
||
| // Billing country as an ISO 3166-1 alpha-2 code (e.g. "DE"), as stored on the order. | ||
| defineProps<{ modelValue: string; required?: boolean }>() | ||
| const emit = defineEmits<{ 'update:modelValue': [value: string] }>() | ||
| </script> | ||
|
|
||
| <template> | ||
| <div> | ||
| <label class="text-gray-400 mb-2 block text-sm font-bold"> | ||
| Land <span v-if="required" class="text-lime">*</span> | ||
| </label> | ||
| <select | ||
| aria-label="Land" | ||
| :value="modelValue" | ||
| class="w-full rounded-lg border border-gray-700 bg-gray-800 px-4 py-3 text-white focus:border-lime focus:outline-none" | ||
| @change="emit('update:modelValue', ($event.target as HTMLSelectElement).value)" | ||
| > | ||
| <option value="" :disabled="required">Bitte Land auswählen</option> | ||
| <option v-for="country in BILLING_COUNTRIES" :key="country.code" :value="country.code"> | ||
| {{ country.name }} | ||
| </option> | ||
| </select> | ||
| </div> | ||
| </template> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.