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

Add support for Japan to the tax details modal #8974

Merged
merged 27 commits into from
Jul 25, 2024

Conversation

haszari
Copy link
Contributor

@haszari haszari commented Jun 18, 2024

Fixes #8926

Changes proposed in this Pull Request

This PR changes the tax details modal so it works well for merchants in Japan, alongside existing VAT merchants in EU and UK.

Prior to this PR, the modal assumes VAT and various other details of the flow are tailored to the currently-supported tax regions:

  • Use of "VAT" throughout
  • Specific hints for formatting of the VAT number
  • Business address details are powered by the validation API (at least for some regions, e.g. UK)

To make the modal work for Japan, I've generalised it a little, by parameterising all the data/copy/content that is region-specific:

  • The name of the tax ID is factored out (e.g. VAT number vs Corporate Number; in future GST number).
  • The name of the tax is factored out (e.g. VAT vs Consumption Tax; in future GST).
  • The validation hint is customisable per region.

I've made some other changes so things are clear and accurate

  • Generalised the title, and made it more friendly/clear - now Set your tax details (covers all tasks - id and address).
  • Fixed mention of receipts to tax documents, more consistent with rest of the UI and documentation.
here's what's changed, in visual form

In the first screenshot, I've highlighted the non-essential stuff I've changed.

Step Old - UK New - UK New – Japan
Open modal Existing UK 1 New UK 1 JP 1
Bad tax ID † Existing UK 2 - invalid VAT ID New UK 2 - invalid JP 2 - invalid ID
Confirm details Existing UK 3 - enter details, valid ID New UK 3 - details JP 3 - valid, enter details

@rogermattic keen for your feedback on this, if you see anything amiss please comment!

† Note: The error message for a bad corporate number / Japan tax ID is currently incorrect. I've made server changes to allow us to customise these error messages, I'm proposing doing that in a follow up PR to keep this PR moving.

this is arguably a temporary fix

IMO this dialog is quite convoluted and complex, since each region is subtly different.

Long term, I think we should implement separate modals/components for each region, with a similar interface, and have one outer conditional for region. I didn't undertake that on this PR because I wanted a relatively quick and low-risk fix.

Why: If each region's UI is self-contained, it's easier to review and test, or customise the flow if needed. Also IMO it's not good practice to translate substrings such as VAT number, it's better to translate whole sentences (or ideally whole modal/UI).

Next time we add a new region, or do any work, let's consider that approach. Reviewers: keen for feedback on this aspect specifically.

Testing instructions

Note you'll need to test this with a store with account country that supports tax docs. Ideally, test with different accounts to see UI for different countries. Tip: if you set wcpay_accounts[].deleted to a date in the past, you can onboard a new account. Or switch between accounts by setting wcpay_accounts[].deleted=NULL` on the account you want to use.

  1. Set up tax docs so you have a document to view at Payments > Documents. Fake one up with this CLI command:
    • wp wcpay add_document_for_account [account_id] vat_invoice --mode=test --period_from="2024-04-01 00:00:00" --period_to="2024-04-30 23:59:59"
    • Or can use wp wcpay backfill_merchant_vat_invoices
  2. If you've added VAT id / tax information previously, clear it out so you can see the modal:
  3. Go to Payments > Documents.
  4. Click Download for a tax doc row.
  5. See modal.
  6. Test adding valid and invalid tax info.
  7. Test downloading the generated tax doc – confirm the merchant details are correct.

  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

  • Link to testing instructions from release testing doc following these instructions : not requesting GlobalStep testing, will need Japan store onboarded to test with, better to just test ourselves
  • Add or update critical flows and testing instructions for critical flows, if applicable. not affecting a critical flow; tax docs is a secondary feature
  • Add what's changed (description, screenshot, demo videos etc.) to the release announcement post, if applicable.

@botwoo
Copy link
Collaborator

botwoo commented Jun 18, 2024

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 8974 or branch name fix/8926-localise-vat-details-modal in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: bfb3bd1
  • Build time: 2024-07-25 03:00:24 UTC

Note: the build is updated when a new commit is pushed to this PR.

Copy link
Contributor

github-actions bot commented Jun 18, 2024

Size Change: +60 B (0%)

Total Size: 1.33 MB

Filename Size Change
release/woocommerce-payments/dist/index.js 296 kB +60 B (0%)
ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.08 kB
release/woocommerce-payments/assets/css/admin.rtl.css 1.08 kB
release/woocommerce-payments/assets/css/success.css 173 B
release/woocommerce-payments/assets/css/success.rtl.css 173 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 2.08 kB
release/woocommerce-payments/dist/blocks-checkout.css 2.08 kB
release/woocommerce-payments/dist/blocks-checkout.js 61.1 kB
release/woocommerce-payments/dist/bnpl-announcement-rtl.css 528 B
release/woocommerce-payments/dist/bnpl-announcement.css 529 B
release/woocommerce-payments/dist/bnpl-announcement.js 20.8 kB
release/woocommerce-payments/dist/cart-block.js 16.1 kB
release/woocommerce-payments/dist/cart.js 5.67 kB
release/woocommerce-payments/dist/checkout-rtl.css 600 B
release/woocommerce-payments/dist/checkout.css 600 B
release/woocommerce-payments/dist/checkout.js 31.7 kB
release/woocommerce-payments/dist/express-checkout-rtl.css 235 B
release/woocommerce-payments/dist/express-checkout.css 235 B
release/woocommerce-payments/dist/express-checkout.js 13.9 kB
release/woocommerce-payments/dist/index-rtl.css 39.1 kB
release/woocommerce-payments/dist/index.css 39 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.08 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 3.41 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 60.5 kB
release/woocommerce-payments/dist/multi-currency.css 3.41 kB
release/woocommerce-payments/dist/multi-currency.js 55.5 kB
release/woocommerce-payments/dist/order-rtl.css 730 B
release/woocommerce-payments/dist/order.css 730 B
release/woocommerce-payments/dist/order.js 42.7 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.35 kB
release/woocommerce-payments/dist/payment-gateways.css 1.35 kB
release/woocommerce-payments/dist/payment-gateways.js 39.2 kB
release/woocommerce-payments/dist/payment-request-rtl.css 235 B
release/woocommerce-payments/dist/payment-request.css 235 B
release/woocommerce-payments/dist/payment-request.js 13.5 kB
release/woocommerce-payments/dist/plugins-page-rtl.css 386 B
release/woocommerce-payments/dist/plugins-page.css 386 B
release/woocommerce-payments/dist/plugins-page.js 20.1 kB
release/woocommerce-payments/dist/product-details-rtl.css 397 B
release/woocommerce-payments/dist/product-details.css 398 B
release/woocommerce-payments/dist/product-details.js 11.3 kB
release/woocommerce-payments/dist/settings-rtl.css 11.2 kB
release/woocommerce-payments/dist/settings.css 11.1 kB
release/woocommerce-payments/dist/settings.js 223 kB
release/woocommerce-payments/dist/subscription-edit-page.js 703 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 524 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 20.2 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 730 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 120 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 19.3 kB
release/woocommerce-payments/dist/tokenized-payment-request-rtl.css 235 B
release/woocommerce-payments/dist/tokenized-payment-request.css 235 B
release/woocommerce-payments/dist/tokenized-payment-request.js 14.3 kB
release/woocommerce-payments/dist/tos-rtl.css 235 B
release/woocommerce-payments/dist/tos.css 235 B
release/woocommerce-payments/dist/tos.js 21.8 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 6.08 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 235 B
release/woocommerce-payments/dist/woopay-express-button.css 235 B
release/woocommerce-payments/dist/woopay-express-button.js 23.9 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.5 kB
release/woocommerce-payments/dist/woopay.css 4.47 kB
release/woocommerce-payments/dist/woopay.js 70.9 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 625 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 814 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.46 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.02 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-admin-create-user.rtl.css 198 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.css 625 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.js 20 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-login.rtl.css 626 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/jetpack-sso-users.js 392 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 584 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.css 215 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-admin-create-user.js 521 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.css 721 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-login.js 412 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/src/sso/jetpack-sso-users.js 520 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 159 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.36 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.6 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.36 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.04 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 294 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 408 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.59 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 301 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 746 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 574 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 414 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 543 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.78 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.84 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 545 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.7 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 507 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 358 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 428 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 782 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.09 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.26 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 391 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.04 kB

compressed-size-action

@@ -24,7 +24,7 @@ const VatFormModal = ( {
} ): JSX.Element | null => {
return isModalOpen ? (
<Modal
title={ __( 'VAT details', 'woocommerce-payments' ) }
title={ __( 'Set your tax details', 'woocommerce-payments' ) }
Copy link
Contributor Author

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:

  1. Remove VAT, not all regions call it VAT.
  2. Generalise, higher level title.

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.

@haszari haszari changed the title Fix/8926 localise vat details modal Add support for Japan to the tax details modal Jul 22, 2024
@haszari haszari marked this pull request as ready for review July 22, 2024 01:55
@haszari haszari requested a review from a team July 22, 2024 01:58
@haszari
Copy link
Contributor Author

haszari commented Jul 22, 2024

Covered with tests

FYI this is ready for review, but I still need to fix up the e2e tests. Reviewers please let me know if you have suggestions for scenarios to e2e test!

@haszari
Copy link
Contributor Author

haszari commented Jul 24, 2024

Note for reviewers: there are a bunch of tests that need updating/fixing, I'm in progress on this :)

Feedback or suggestions for improving the tests is welcome!

Copy link
Contributor

@shendy-a8c shendy-a8c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and tested well.

Thank you for the screenshots. They help to identify what are the changes in the UI.

My notes:

  • The wp wcpay add_document_for_account command from the testing instructions did not work for me. I had to add --date parameter.
wp wcpay add_document_for_account {account_id} vat_invoice --mode=test --date="2024-07-24" --period_from="2023-01-01 00:00:00" --period_to="2024-07-31 23:59:59"
  • There is a linter issue that needs to be fixed.

  • I tested using US, UK, and JP store.

  • Do you plan to resolve some of the TODOs in this PR?

  • Acknowledging that GST is mentioned in some of the comments but it's not returned in getVatTaxIDName() because GST, according to ChatGPT, for India, Australia, Canada, New Zealand.

  • I tested that the hint returned by getVatTaxIDValidationHint() for JP works, ie entering 1234567890123 passes the validation.

I didn't think too much about e2e test but if it's not straight forward, better to do in a separate PR. Not sure if setting certain country is easy in e2e test.

@@ -33,6 +39,54 @@ const getVatPrefix = () => {
}
};

const getVatTaxIDName = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value of getVatTaxIDName() is the return value of __() but I see it will be fed into another __(). I was concerned that the string will be double-translated, but I think it will not because it's considered as a parameter for the 2nd __() call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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).

Copy link
Contributor

Choose a reason for hiding this comment

The 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 {phrase1} {tax number} {phrase2} we're instead doing Set your %s (where %s is tax_number) which is exactly how that link recommends doing it.
While whole strings would be better, this approach is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

While whole strings would be better, this approach is fine.

Exactly, whole strings (or UIs) would be better, my plan is next time we work on this we do that refactor.

Copy link
Contributor

@brucealdridge brucealdridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested the happy path for JP 🇯🇵 and everything looks good.

The code changes look good to me. When I saw the warning about substrings inside translated strings I was concerned, but the approach here is sensible and good to merge.

@haszari
Copy link
Contributor Author

haszari commented Jul 25, 2024

Thanks @brucealdridge @shendy-a8c ! I'm working on the e2e tests now, I think I can get that sorted, and will also tidy up linter and todos/comments before merge. [Moved back to In progress]

@haszari
Copy link
Contributor Author

haszari commented Jul 25, 2024

  • Tests are sorted now ✅
  • Comments & todos tidied 📝

Acknowledging that GST is mentioned in some of the comments but it's not returned in getVatTaxIDName() because GST, according to ChatGPT, for India, Australia, Canada, New Zealand.

That's by design, a hint for anyone working on this in future to not assume "VAT". We don't yet support tax docs in any "GST" regions (as of right now).

Merging 🚢

@haszari haszari added this pull request to the merge queue Jul 25, 2024
@haszari
Copy link
Contributor Author

haszari commented Jul 25, 2024

Add what's changed (description, screenshot, demo videos etc.) to the release announcement post, if applicable.

I have the ball, will follow up & add to What's New.

Merged via the queue into develop with commit 652b676 Jul 25, 2024
23 checks passed
@haszari haszari deleted the fix/8926-localise-vat-details-modal branch July 25, 2024 03:16
lovo-h pushed a commit that referenced this pull request Aug 1, 2024
Co-authored-by: Rua Haszard <rua@automattic.com>
Co-authored-by: Shendy <73803630+shendy-a8c@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use generic language for VAT/GST in VAT details form to reduce confusion in non-VAT regions (e.g. Japan)
4 participants