-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add support for Japan to the tax details modal #8974
Changes from 19 commits
93cad6f
7ede193
232a92b
66f1501
51880a5
c12c5d8
addbd1d
1175bfe
9919e3a
e871333
7a313c4
7e15b02
276137b
60797d6
3d11f18
a1ee604
63f1ff9
355a0b9
98cc50e
f9b72ee
44822c6
4632375
acea9d9
0ae6d2e
fa3efa6
f7f94a1
bfb3bd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Support adding tax details (corporate number) for Japan merchants (so can generate tax documents for consumption tax, aka VAT). |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { | |
Notice, | ||
TextControl, | ||
} from '@wordpress/components'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
import React, { useContext, useState } from 'react'; | ||
import CollapsibleBody from 'wcpay/additional-methods-setup/wizard/collapsible-body'; | ||
import WizardTaskItem from 'wcpay/additional-methods-setup/wizard/task-item'; | ||
|
@@ -22,8 +22,14 @@ import apiFetch from '@wordpress/api-fetch'; | |
import { VatError, VatFormOnCompleted, VatValidationResult } from '../../types'; | ||
import '../style.scss'; | ||
|
||
/** | ||
* These country-specific getters may belong on server. | ||
*/ | ||
const getVatPrefix = () => { | ||
switch ( wcpaySettings.accountStatus.country ) { | ||
case 'JP': | ||
// Corporate numbers are not prefixed. | ||
return ''; | ||
case 'GR': | ||
return 'EL '; | ||
case 'CH': | ||
|
@@ -33,6 +39,54 @@ const getVatPrefix = () => { | |
} | ||
}; | ||
|
||
const getVatTaxIDName = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The return value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is part of the reason why I would prefer to have separate dialogs for each region (as needed). Then the translator can translate as whole, and avoid concatenating translated strings (which is a localisation no-no). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the way it's done here is okay. We're not doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea it's shippable as is, but the amount of branching and substitutions is the problem, _() on _() is a symptom of that.
Exactly, whole strings (or UIs) would be better, my plan is next time we work on this we do that refactor. |
||
switch ( wcpaySettings.accountStatus.country ) { | ||
case 'JP': | ||
return __( 'Corporate Number', 'woocommerce-payments' ); | ||
default: | ||
return __( 'VAT Number', 'woocommerce-payments' ); | ||
} | ||
}; | ||
|
||
const getVatTaxIDRequirementHint = () => { | ||
switch ( wcpaySettings.accountStatus.country ) { | ||
case 'JP': | ||
// TODO do we need a note/legal requirement hint for Japan? | ||
return __( '', 'woocommerce-payments' ); | ||
default: | ||
// TODO this message is a little alarming and doesn't provide guidance for confused merchants. | ||
// What are the thresholds? | ||
// How do I register for a VAT number? | ||
// Idea: add a learn more link to our docs page, and link to relevant sources there. | ||
// https://woocommerce.com/document/woopayments/taxes/documents/ | ||
// Alternative - maybe this can be removed. | ||
return __( | ||
"If your sales exceed the VAT threshold for your country, you're required to register for a VAT Number.", | ||
'woocommerce-payments' | ||
); | ||
} | ||
}; | ||
|
||
const getVatTaxIDValidationHint = () => { | ||
switch ( wcpaySettings.accountStatus.country ) { | ||
case 'JP': | ||
return __( | ||
'A 13 digit number, for example 1234567890123.', | ||
'woocommerce-payments' | ||
); | ||
default: | ||
return __( | ||
'8 to 12 digits with your country code prefix, for example DE 123456789.', | ||
'woocommerce-payments' | ||
); | ||
} | ||
}; | ||
|
||
/** | ||
* A two-step "task" for obtaining merchant's tax details. | ||
* | ||
* @param {VatFormOnCompleted} props.onCompleted - Callback to provide tax details on submit. | ||
*/ | ||
export const VatNumberTask = ( { | ||
onCompleted, | ||
}: { | ||
|
@@ -95,17 +149,23 @@ export const VatNumberTask = ( { | |
}; | ||
|
||
return ( | ||
// Note: the VAT ID name is parameterised in strings below. | ||
// Long term, it might be better to implement a dedicated WizardTaskItem component for each tax region. | ||
<WizardTaskItem | ||
index={ 1 } | ||
title={ __( | ||
'Update your VAT information', | ||
'woocommerce-payments' | ||
title={ sprintf( | ||
__( | ||
/* translators: %$1$s: tax ID name, e.g. VAT Number, GST Number, Corporate Number */ | ||
'Set your %1$s', | ||
'woocommerce-payments' | ||
), | ||
getVatTaxIDName() | ||
) } | ||
className={ null } | ||
> | ||
<p className="wcpay-wizard-task__description-element"> | ||
{ __( | ||
'VAT information saved on this page will be applied to all of your account’s receipts.', | ||
"The information you provide here will be used for all of your account's tax documents.", | ||
'woocommerce-payments' | ||
) } | ||
</p> | ||
|
@@ -114,22 +174,22 @@ export const VatNumberTask = ( { | |
<CheckboxControl | ||
checked={ isVatRegistered } | ||
onChange={ setVatRegistered } | ||
label={ __( | ||
'I’m registered for a VAT number', | ||
'woocommerce-payments' | ||
) } | ||
help={ __( | ||
'If your sales exceed the VAT threshold for your country, you’re required to register for a VAT number.', | ||
'woocommerce-payments' | ||
label={ sprintf( | ||
__( | ||
/* translators: %$1$s: tax ID name, e.g. VAT Number, GST Number, Corporate Number */ | ||
"I'm registered for a %1$s", | ||
'woocommerce-payments' | ||
), | ||
getVatTaxIDName() | ||
) } | ||
help={ getVatTaxIDRequirementHint() } | ||
/> | ||
{ isVatRegistered && ( | ||
// Note: this TextControl is heavily parameterised to support different regions (VAT vs GST vs Corporate Number). | ||
// Long term, if we implement a dedicated WizardTaskItem component for each tax region, then this component will be simpler. | ||
<TextControl | ||
label={ __( 'VAT Number', 'woocommerce-payments' ) } | ||
help={ __( | ||
'This is 8 to 12 digits with your country code prefix, for example DE 123456789.', | ||
'woocommerce-payments' | ||
) } | ||
label={ getVatTaxIDName() } | ||
help={ getVatTaxIDValidationHint() } | ||
value={ vatNumber } | ||
onChange={ setVatNumber } | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note – I've changed the dialog title for two reasons:
VAT
, not all regions call itVAT
.Re (2)…
The dialog's purpose is to set various tax details – the tax/VAT number, and address details. It's a multi-step process, so I think this title is a clearer summary of both steps.