Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(billing): 补充个人版开票盖章说明和多语言邮件模板
nana39cfa0e09c0f
diff --git a/apps/desktop/src/renderer/features/billing/BillingPage.tsx b/apps/desktop/src/renderer/features/billing/BillingPage.tsxindex 7e748c1ff8..fe508b0a57 100644--- a/apps/desktop/src/renderer/features/billing/BillingPage.tsx+++ b/apps/desktop/src/renderer/features/billing/BillingPage.tsx@@ -13,7 +13,7 @@ import {RefreshCcw,X,} from 'lucide-react';-import { useTranslation } from 'react-i18next';+import { Trans, useTranslation } from 'react-i18next';import { useSearchParams } from 'react-router-dom';import { Button } from '@/components/ui/button';@@ -1969,6 +1969,7 @@ function InvoiceRequestDialog({application: 'Cindy',paymentMethod,amount: formatMoney(order.amount, order.currency, billingLocale),+ invoiceTitleHint: t('billing.orders.invoice.invoiceTitleHint'),});return { subject, body };};@@ -2061,6 +2062,17 @@ function InvoiceRequestDialog({{descriptionAfterEmail}</p>+ <p className="mt-3 text-12 leading-5 text-[var(--confirm-desc)]">+ <Trans+ i18n={i18n}+ t={t}+ i18nKey="billing.orders.invoice.personalInvoicePolicy"+ components={{+ strong: <strong className="font-semibold text-[var(--confirm-title)]" />,+ }}+ />+ </p>+<div className="mt-4 divide-y divide-[var(--border-default)] overflow-hidden rounded-xl border border-[var(--border-default)]"><InvoiceInfoRowlabel={t('billing.orders.invoice.fields.orderId')}diff --git a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsxindex 1a0fe848d4..4b314e7931 100644--- a/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx+++ b/apps/desktop/src/renderer/features/billing/__tests__/BillingPage.test.tsx@@ -2,16 +2,30 @@import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';import { beforeEach, describe, expect, it, vi } from 'vitest';+import { createInstance } from 'i18next';import type {BillingPaymentOrder,BillingSubscription,BillingSubscriptionPortalResult,} from '../../../../shared/billing';-const i18n = {- language: 'en',- resolvedLanguage: 'en' as string | undefined,-};+import en from '../../../i18n/locales/en/common.json';+import ja from '../../../i18n/locales/ja/common.json';+import ko from '../../../i18n/locales/ko/common.json';+import zhCN from '../../../i18n/locales/zh-CN/common.json';+import zhTW from '../../../i18n/locales/zh-TW/common.json';++const invoiceLocales = { en, ja, ko, 'zh-CN': zhCN, 'zh-TW': zhTW };++const i18n = createInstance();+void i18n.init({+ lng: 'en',+ initAsync: false,+ interpolation: { escapeValue: false },+ resources: Object.fromEntries(+ Object.entries(invoiceLocales).map(([locale, resource]) => [locale, { translation: resource }]),+ ),+});const uiMocks = vi.hoisted(() => ({clipboardWriteText: vi.fn(),@@ -63,23 +77,15 @@ vi.mock('react-i18next', async (importOriginal) => ({'billing.providers.stripe': 'stripe',};if (providerLabels[key]) return providerLabels[key];- if (key === 'billing.orders.invoice.emailBody') {- return [- 'Hello,',- '',- 'I would like to request an invoice for the following order:',- '',- '────────────────────',- `Order ID: ${params?.orderId ?? ''}`,- 'Application: Cindy',- 'Payment method: Scan to pay',- 'Invoice amount: CN¥33.00',- 'Invoice title: ',- 'Contact person: ',- 'Phone number: ',- 'Email: ',- '────────────────────',- ].join('\n');+ if (+ [+ 'billing.orders.invoice.personalInvoicePolicy',+ 'billing.orders.invoice.invoiceTitleHint',+ 'billing.orders.invoice.emailSubject',+ 'billing.orders.invoice.emailBody',+ ].includes(key)+ ) {+ return i18n.t(key, params);}return params ? `${key}:${JSON.stringify(params)}` : key;},@@ -129,7 +135,8 @@ vi.mock('qrcode', () => ({import { BillingPage } from '../BillingPage';import * as QRCode from 'qrcode';-beforeEach(() => {+beforeEach(async () => {+ await i18n.changeLanguage('en');Object.defineProperty(navigator, 'clipboard', {configurable: true,value: { writeText: uiMocks.clipboardWriteText },@@ -158,8 +165,6 @@ async function selectSubscriptionManagementAction(action: string) {describe('BillingPage remote catalog rendering', () => {beforeEach(() => {- i18n.language = 'en';- i18n.resolvedLanguage = 'en';Object.assign(checkout.state, {open: false,kind: null,@@ -3316,6 +3321,68 @@ describe('BillingPage order history', () => {expect(mailBody).toContain('Invoice title: ');});+ it.each(Object.entries(invoiceLocales))(+ 'shows the policy in the dialog and places title instructions beside the email field for %s',+ async (locale, resources) => {+ await i18n.changeLanguage(locale);+ install([order({ orderId: 'o-company-reimbursement' })]);+ const openExternal = vi.mocked(window.electronAPI.openExternal);+ openExternal+ .mockResolvedValueOnce({ success: false })+ .mockResolvedValueOnce({ success: true });+ uiMocks.confirm.mockResolvedValueOnce(true);+ const policy = resources.billing.orders.invoice.personalInvoicePolicy.replace(+ /<\/?strong>/g,+ '',+ );+ if (locale === 'zh-CN') {+ expect(policy).toBe(+ 'Cindy 个人版充值默认开具个人抬头发票,抬头可填写姓名或“个人”。如需开具企业抬头发票用于公司报销,请提供加盖公司公章的报销说明,并在说明中注明开票抬头。',+ );+ }++ render(<BillingPage />);+ fireEvent.click(await screen.findByRole('button', { name: 'billing.orders.invoice.action' }));+ const dialog = await screen.findByRole('alertdialog');+ const policyParagraph = within(dialog).getByText(+ (_, element) => element?.tagName === 'P' && element.textContent === policy,+ );+ expect(policyParagraph.querySelectorAll('strong')).toHaveLength(2);+ if (locale === 'zh-CN') {+ expect(+ Array.from(policyParagraph.querySelectorAll('strong'), (node) => node.textContent),+ ).toEqual(['个人抬头发票', '加盖公司公章的报销说明']);+ }+ fireEvent.click(screen.getByRole('button', { name: 'billing.orders.invoice.sendAction' }));++ await waitFor(() => expect(openExternal).toHaveBeenCalledTimes(2));+ const mailto = new URL(openExternal.mock.calls[0][0] as string);+ const gmail = new URL(openExternal.mock.calls[1][0] as string);+ const body = mailto.searchParams.get('body');+ const { fields, invoiceTitleHint } = resources.billing.orders.invoice;+ expect(body).toContain(`\n${invoiceTitleHint}\n\n`);+ expect(body).not.toContain(policy);+ const titlePosition = body!.indexOf(fields.invoiceTitle);+ const hintPosition = body!.indexOf(invoiceTitleHint);+ expect(titlePosition).toBeGreaterThan(body!.indexOf('o-company-reimbursement'));+ expect(hintPosition).toBeGreaterThan(titlePosition);+ expect(hintPosition).toBeLessThan(body!.indexOf(fields.contact));+ if (locale === 'zh-CN') {+ expect(body).toContain(+ '发票抬头:\n填写说明:个人抬头请填写姓名或“个人”;如需企业抬头用于公司报销,请随邮件附上加盖公司公章、注明开票抬头的报销说明。',+ );+ }+ expect(body).toContain('o-company-reimbursement');+ expect(body).not.toContain('{{');+ expect(body).not.toContain('<strong>');+ expect(gmail.searchParams.get('body')).toBe(body);+ const subject = mailto.searchParams.get('subject');+ expect(subject).toContain('o-company-reimbursement');+ expect(subject).not.toContain('{{');+ expect(gmail.searchParams.get('su')).toBe(subject);+ },+ );+it('opens a prefilled Gmail compose page when the mail app cannot be opened', async () => {install([order({ orderId: 'o-gmail-fallback' })]);const openExternal = vi.mocked(window.electronAPI.openExternal);diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex b7954160ac..496186194f 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -14438,7 +14438,9 @@"description": "Please email the following information to {{email}} to request an invoice.","requiredInfo": "Please include these details in your email:","emailSubject": "Invoice request for order {{orderId}}",- "emailBody": "Hello,\n\nI would like to request an invoice for the following order:\n\n────────────────────\nOrder ID: {{orderId}}\nApplication: {{application}}\nPayment method: {{paymentMethod}}\nInvoice amount: {{amount}}\nInvoice title: \nContact person: \nPhone number: \nEmail: \n────────────────────\n\nThank you.",+ "personalInvoicePolicy": "Invoices for Cindy Personal top-ups are issued in <strong>an individual’s name</strong> by default. You can use your name or “Individual” as the invoice title. If you need an invoice in your company’s name for expense reimbursement, provide <strong>a reimbursement statement bearing the company’s official stamp</strong> and specifying the invoice title.",+ "invoiceTitleHint": "Instructions: For an individual invoice, enter your name or “Individual”. For an invoice in your company’s name for expense reimbursement, attach a reimbursement statement bearing the company’s official stamp and specifying the invoice title.",+ "emailBody": "Hello,\n\nI would like to request an invoice for the following order:\n\n────────────────────\nOrder ID: {{orderId}}\nApplication: {{application}}\nPayment method: {{paymentMethod}}\nInvoice amount: {{amount}}\nInvoice title: \n{{invoiceTitleHint}}\n\nContact person: \nPhone number: \nEmail: \n────────────────────\n\nThank you.","sendAction": "Send Invoice Request","emailCopied": "Support email copied","emailCopyFailed": "Support email wasn’t copied — try again",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 10a643e4c8..e339bccad0 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -14386,7 +14386,9 @@"description": "請求書の発行を申請するには、以下の情報を {{email}} までメールでお送りください。","requiredInfo": "メールには以下の情報を記載してください:","emailSubject": "注文 {{orderId}} の請求書発行申請",- "emailBody": "こんにちは。\n\n以下の注文について請求書の発行を申請します。\n\n────────────────────\n注文 ID:{{orderId}}\nアプリケーション:{{application}}\n支払い方法:{{paymentMethod}}\n請求金額:{{amount}}\n請求書宛名:\n担当者名:\n電話番号:\nメールアドレス:\n────────────────────\n\nよろしくお願いいたします。",+ "personalInvoicePolicy": "Cindy個人版へのチャージでは、原則として<strong>個人宛ての請求書</strong>を発行します。宛名には氏名または「個人」を記載できます。会社の経費精算のために企業名義の請求書が必要な場合は、<strong>会社の公印を押印した経費精算説明書</strong>をご提出いただき、説明書に請求書の宛名を明記してください。",+ "invoiceTitleHint": "記入方法:個人宛ての場合は、氏名または「個人」を記載してください。会社の経費精算のために企業名義で発行する場合は、会社の公印を押印し、請求書の宛名を明記した経費精算説明書をメールに添付してください。",+ "emailBody": "こんにちは。\n\n以下の注文について請求書の発行を申請します。\n\n────────────────────\n注文 ID:{{orderId}}\nアプリケーション:{{application}}\n支払い方法:{{paymentMethod}}\n請求金額:{{amount}}\n請求書宛名:\n{{invoiceTitleHint}}\n\n担当者名:\n電話番号:\nメールアドレス:\n────────────────────\n\nよろしくお願いいたします。","sendAction": "請求書の申請を送信","emailCopied": "サポートメールアドレスをコピーしました","emailCopyFailed": "サポートメールアドレスをコピーできませんでした。もう一度お試しください。",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 1d15eafb99..2e13d7be12 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -14386,7 +14386,9 @@"description": "세금계산서 발급을 신청하려면 다음 정보를 {{email}}로 보내 주세요.","requiredInfo": "이메일에 다음 정보를 포함해 주세요:","emailSubject": "주문 {{orderId}} 세금계산서 발급 신청",- "emailBody": "안녕하세요.\n\n다음 주문에 대한 세금계산서 발급을 신청합니다.\n\n────────────────────\n주문 ID: {{orderId}}\n애플리케이션: {{application}}\n결제 수단: {{paymentMethod}}\n발행 금액: {{amount}}\n청구서 제목: \n담당자: \n전화번호: \n이메일: \n────────────────────\n\n감사합니다.",+ "personalInvoicePolicy": "Cindy 개인용 충전 시 기본적으로 <strong>개인 명의의 세금계산서</strong>가 발급됩니다. 발급 명의는 성명 또는 “개인”으로 기재할 수 있습니다. 회사 경비 정산을 위해 기업 명의의 세금계산서가 필요한 경우, <strong>회사 직인이 날인된 경비 정산 설명서</strong>를 제출하고 설명서에 발급 명의를 명시해 주세요.",+ "invoiceTitleHint": "작성 안내: 개인 명의의 경우 성명 또는 “개인”을 기재해 주세요. 회사 경비 정산을 위해 기업 명의로 발급받으려면, 회사 직인이 날인되고 발급 명의가 명시된 경비 정산 설명서를 이메일에 첨부해 주세요.",+ "emailBody": "안녕하세요.\n\n다음 주문에 대한 세금계산서 발급을 신청합니다.\n\n────────────────────\n주문 ID: {{orderId}}\n애플리케이션: {{application}}\n결제 수단: {{paymentMethod}}\n발행 금액: {{amount}}\n청구서 제목: \n{{invoiceTitleHint}}\n\n담당자: \n전화번호: \n이메일: \n────────────────────\n\n감사합니다.","sendAction": "세금계산서 신청 보내기","emailCopied": "고객센터 이메일을 복사했습니다","emailCopyFailed": "고객센터 이메일을 복사하지 못했습니다. 다시 시도해 주세요.",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex be3e49dc92..7b5062682b 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -14386,7 +14386,9 @@"description": "请将以下信息发送至客服邮箱 {{email}},以申请开具发票。","requiredInfo": "邮件中请提供以下信息:","emailSubject": "申请开具订单 {{orderId}} 的发票",- "emailBody": "您好,\n\n我想申请开具以下订单的发票:\n\n────────────────────\n订单号:{{orderId}}\n应用:{{application}}\n支付方式:{{paymentMethod}}\n开票金额:{{amount}}\n发票抬头:\n联系人:\n联系电话:\n邮箱:\n────────────────────\n\n谢谢。",+ "personalInvoicePolicy": "Cindy 个人版充值默认开具<strong>个人抬头发票</strong>,抬头可填写姓名或“个人”。如需开具企业抬头发票用于公司报销,请提供<strong>加盖公司公章的报销说明</strong>,并在说明中注明开票抬头。",+ "invoiceTitleHint": "填写说明:个人抬头请填写姓名或“个人”;如需企业抬头用于公司报销,请随邮件附上加盖公司公章、注明开票抬头的报销说明。",+ "emailBody": "您好,\n\n我想申请开具以下订单的发票:\n\n────────────────────\n订单号:{{orderId}}\n应用:{{application}}\n支付方式:{{paymentMethod}}\n开票金额:{{amount}}\n发票抬头:\n{{invoiceTitleHint}}\n\n联系人:\n联系电话:\n邮箱:\n────────────────────\n\n谢谢。","sendAction": "发送开票申请","emailCopied": "客服邮箱已复制","emailCopyFailed": "复制客服邮箱失败,请重试",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 4cb59a903a..2d02bb9a40 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -14386,7 +14386,9 @@"description": "請將以下資訊寄送至客服信箱 {{email}},以申請開立發票。","requiredInfo": "郵件中請提供以下資訊:","emailSubject": "申請開立訂單 {{orderId}} 的發票",- "emailBody": "您好,\n\n我想申請開立以下訂單的發票:\n\n────────────────────\n訂單號:{{orderId}}\n應用程式:{{application}}\n付款方式:{{paymentMethod}}\n開票金額:{{amount}}\n發票抬頭:\n聯絡人:\n聯絡電話:\n信箱:\n────────────────────\n\n謝謝。",+ "personalInvoicePolicy": "Cindy 個人版儲值預設開立<strong>個人抬頭發票</strong>,抬頭可填寫姓名或「個人」。如需開立企業抬頭發票用於公司報銷,請提供<strong>加蓋公司公章的報銷說明</strong>,並在說明中註明開票抬頭。",+ "invoiceTitleHint": "填寫說明:個人抬頭請填寫姓名或「個人」;如需企業抬頭用於公司報銷,請隨郵件附上加蓋公司公章、註明開票抬頭的報銷說明。",+ "emailBody": "您好,\n\n我想申請開立以下訂單的發票:\n\n────────────────────\n訂單號:{{orderId}}\n應用程式:{{application}}\n付款方式:{{paymentMethod}}\n開票金額:{{amount}}\n發票抬頭:\n{{invoiceTitleHint}}\n\n聯絡人:\n聯絡電話:\n信箱:\n────────────────────\n\n謝謝。","sendAction": "寄送開票申請","emailCopied": "客服信箱已複製","emailCopyFailed": "複製客服信箱失敗,請再試一次",