Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions packages/manager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

- Informational notice about capturing an image from a Linode in a distributed compute region ([#10544](https://github.com/linode/manager/pull/10544))
- Volume & Images landing pages search and filtering ([#10570](https://github.com/linode/manager/pull/10570))
- Standard Tax Rate for JP ([#10606](https://github.com/linode/manager/pull/10606))
- B2B Tax ID for EU ([#10606](https://github.com/linode/manager/pull/10606))

### Changed:

Expand Down
8 changes: 8 additions & 0 deletions packages/manager/src/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import type { NoticeVariant } from 'src/components/Notice/Notice';
export interface TaxDetail {
qi_registration?: string;
tax_id: string;
tax_ids?: Record<
'B2B' | 'B2C',
{
tax_id: string;
tax_name: string;
}
>;
tax_info?: string;
tax_name: string;
}

Expand Down
37 changes: 25 additions & 12 deletions packages/manager/src/features/Billing/PdfGenerator/PdfGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import {
Account,
Invoice,
InvoiceItem,
Payment,
} from '@linode/api-v4/lib/account';
import axios from 'axios';
import jsPDF from 'jspdf';
import { splitEvery } from 'ramda';

import { ADDRESSES } from 'src/constants';
import { reportException } from 'src/exceptionReporting';
import { FlagSet, TaxDetail } from 'src/featureFlags';
import { formatDate } from 'src/utilities/formatDate';

import { getShouldUseAkamaiBilling } from '../billingUtils';
import AkamaiLogo from './akamai-logo.png';
import {
PdfResult,
createFooter,
createInvoiceItemsTable,
createInvoiceTotalsTable,
Expand All @@ -27,7 +19,15 @@ import {
pageMargin,
} from './utils';

import type { PdfResult } from './utils';
import type { Region } from '@linode/api-v4';
import type {
Account,
Invoice,
InvoiceItem,
Payment,
} from '@linode/api-v4/lib/account';
import type { FlagSet, TaxDetail } from 'src/featureFlags';

const baseFont = 'helvetica';

Expand Down Expand Up @@ -98,17 +98,29 @@ const addLeftHeader = (
doc.setFont(baseFont, 'normal');

if (countryTax) {
addLine(`${countryTax.tax_name}: ${countryTax.tax_id}`);
const { tax_id, tax_ids, tax_name } = countryTax;

addLine(`${tax_name}: ${tax_id}`);

if (tax_ids?.B2B) {
const { tax_id: b2bTaxId, tax_name: b2bTaxName } = tax_ids.B2B;
addLine(`${b2bTaxName}: ${b2bTaxId}`);
}
}
/**
* M3-7847 Add Akamai's Japanese QI System ID to Japanese Invoices.
* [M3-7847, M3-8008] Add Akamai's Japanese QI System ID to Japanese Invoices.
* Since LD automatically serves Tax data based on the user's
* we can check on qi_registration field to render QI Registration.
* */
if (countryTax && countryTax.qi_registration) {
const line = `QI Registration # ${countryTax.qi_registration}`;
addLine(line);
const qiRegistration = `QI Registration # ${countryTax.qi_registration}`;
addLine(qiRegistration);
}

if (countryTax?.tax_info) {
addLine(countryTax.tax_info);
}

if (provincialTax) {
addLine(`${provincialTax.tax_name}: ${provincialTax.tax_id}`);
}
Expand Down Expand Up @@ -248,6 +260,7 @@ export const printInvoice = async (
* as of 2/20/2020 we have the following cases:
*
* VAT: Applies only to EU countries; started from 6/1/2019 and we have an EU tax id
* - [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.
* GMT: Applies to both Australia and India, but we only have a tax ID for Australia.
*/
const hasTax = !taxes?.date ? true : convertedInvoiceDate > TaxStartDate;
Expand Down