Skip to content
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

adding is from eu check #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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