Skip to content

Commit f6c97ae

Browse files
fix: [M3-10619] - PDF generation fix (#12955)
* PDF generation fix * Revert whole file * PDF generation fix --------- Co-authored-by: Jaalah Ramos <[email protected]>
1 parent 260546b commit f6c97ae

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

packages/manager/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export const App = withDocumentTitleProvider(
2020
window.location.pathname === '/oauth/callback' ||
2121
window.location.pathname === '/admin/callback';
2222

23+
const { isLoading } = useInitialRequests();
24+
const { areFeatureFlagsLoading } = useSetupFeatureFlags();
25+
2326
if (isAuthCallback) {
2427
return (
2528
<ErrorBoundaryFallback>
@@ -29,9 +32,6 @@ export const App = withDocumentTitleProvider(
2932
);
3033
}
3134

32-
const { isLoading } = useInitialRequests();
33-
const { areFeatureFlagsLoading } = useSetupFeatureFlags();
34-
3535
if (isLoading || areFeatureFlagsLoading) {
3636
return <SplashScreen />;
3737
}

packages/manager/src/features/Billing/PdfGenerator/PdfGenerator.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,22 +229,27 @@ export const printInvoice = async (
229229
taxes && taxes?.date ? dateConversion(taxes.date) : Infinity;
230230

231231
/**
232-
* Tax data is served from LaunchDarkly feature flags and displayed on invoices.
233-
* Country-level tax IDs (like EU VAT, Japanese JCT, etc.) are always displayed
234-
* when available, regardless of invoice date.
232+
* Users who have identified their country as one of the ones targeted by
233+
* one of our tax policies will have a `taxes` with at least a .date.
234+
* Customers with no country, or from a country we don't have a tax policy
235+
* for, will have a `taxes` of {}, and the following logic will skip them.
235236
*
236-
* Provincial/state-level tax IDs still use date filtering to determine when
237-
* they should be applied based on local tax policy implementation dates.
237+
* If taxes.date is defined, and the invoice we're about to print is after
238+
* that date, we want to add the customer's tax ID to the invoice.
238239
*
239-
* The source of truth for all tax data is LaunchDarkly, with examples:
240+
* If in addition to the above, taxes is defined, it means
241+
* we have a corporate tax ID for the country and should display that in the left
242+
* side of the header.
240243
*
241-
* EU VAT: Shows both EU VAT number and Switzerland VAT for B2B customers
242-
* Japanese JCT: Shows Japan JCT tax ID and QI Registration number
243-
* US/CA: Shows federal tax IDs and state-specific tax IDs when applicable
244+
* The source of truth for all tax banners is LaunchDarkly, but as an example,
245+
* as of 2/20/2020 we have the following cases:
246+
*
247+
* VAT: Applies only to EU countries; started from 6/1/2019 and we have an EU tax id
248+
* - [M3-8277] For EU customers, invoices will include VAT for B2C transactions and exclude VAT for B2B transactions. Both VAT numbers will be shown on the invoice template for EU countries.
249+
* GMT: Applies to both Australia and India, but we only have a tax ID for Australia.
244250
*/
245251
const hasTax = !taxes?.date ? true : convertedInvoiceDate > TaxStartDate;
246-
// Country-level tax IDs are always displayed when available
247-
const countryTax = taxes?.country_tax;
252+
const countryTax = hasTax ? taxes?.country_tax : undefined;
248253
const provincialTax = hasTax
249254
? taxes?.provincial_tax_ids?.[account.state]
250255
: undefined;

0 commit comments

Comments
 (0)