Skip to content

Commit

Permalink
adding is from eu check
Browse files Browse the repository at this point in the history
  • Loading branch information
BcOleks committed Dec 4, 2023
1 parent 1b9106a commit 010212e
Showing 1 changed file with 45 additions and 8 deletions.
53 changes: 45 additions & 8 deletions src/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ const template = `
<div>{{texts.notTaxPayerSK}}</div>
{{/if}}
{{/unless}}
{{#unless domestic}}
<div>
{{#if isCreditNote}}
{{texts.taxPaysCustomerCreditNote}}
{{else}}
{{texts.taxPaysCustomerInvoice}}
{{/if}}
</div>
{{#unless isFromEuropeanUnion}}
{{#unless domestic}}
<div>
{{#if isCreditNote}}
{{texts.taxPaysCustomerCreditNote}}
{{else}}
{{texts.taxPaysCustomerInvoice}}
{{/if}}
</div>
{{/unless}}
{{/unless}}
{{#if note}}<div id="freeNote">{{note}}</div>{{/if}}
</div>
Expand Down Expand Up @@ -318,11 +320,44 @@ handlebars.registerHelper('formatPrice', (value, currency) => priceFormatters[cu

const domesticCountries = ['The United States of America', 'United Kingdom']

const europeanUnionCountries = [
'Austria',
'Belgium',
'Bulgaria',
'Cyprus',
'Czech Republic',
'Germany',
'Denmark',
'Estonia',
'Spain',
'Finland',
'France',
'Greece',
'Hungary',
'Croatia',
'Ireland, Republic',
'Italy',
'Lithuania',
'Luxembourg',
'Latvia',
'Malta',
'Netherlands',
'Poland',
'Portugal',
'Romania',
'Sweden',
'Slovenia',
'Slovakia',
]

export const isDomestic = (vendorCountry, clientCountry) =>
vendorCountry === clientCountry ||
domesticCountries.includes(clientCountry) ||
clientCountry.includes('US')

export const isFromEU = (clientCountry) =>
europeanUnionCountries.includes(clientCountry)

export default function renderInvoice(_context, language) {
const context = {..._context}

Expand All @@ -331,6 +366,8 @@ export default function renderInvoice(_context, language) {

context.domestic = isDomestic(context.vendorCountry, context.clientCountry)

context.isFromEuropeanUnion = isFromEU(context.clientCountry)

if (context.vendorID && context.vendorID.startsWith('@@')) {
context.vendorID = null
}
Expand Down

0 comments on commit 010212e

Please sign in to comment.