Add bank account templates and default invoice payment text.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-09-21 23:31:58 +03:30
co-authored by Cursor
parent 8465a29ce1
commit ff419603bf
19 changed files with 1316 additions and 107 deletions
+21 -2
View File
@@ -1,6 +1,7 @@
import { formatIrtInput, parseIrtInput } from '../utils/irtPrice'
import type {
InvoiceAccountInput,
InvoiceAccountTemplate,
InvoiceItemInput,
InvoiceItemTemplate,
InvoiceKeyPointInput,
@@ -32,6 +33,10 @@ export type DraftAccount = {
iban: string
}
/** Default free-text payment row shown on new invoice / template drafts. */
export const DEFAULT_PAYMENT_METHOD_TEXT =
'مبلغ ۱.۰۰۰.۰۰۰ تومان پیش پرداخت در تاریخ ۱۰-۱۰-۱۴۱۰ به صورت نقدی'
export function newKey() {
return `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
}
@@ -52,8 +57,12 @@ export function emptyDraftKeyPoint(): DraftKeyPoint {
return { key: newKey(), text: '' }
}
export function emptyDraftPaymentMethod(): DraftPaymentMethod {
return { key: newKey(), text: '' }
export function emptyDraftPaymentMethod(text = ''): DraftPaymentMethod {
return { key: newKey(), text }
}
export function defaultDraftPaymentMethods(): DraftPaymentMethod[] {
return [emptyDraftPaymentMethod(DEFAULT_PAYMENT_METHOD_TEXT)]
}
export function emptyDraftAccount(): DraftAccount {
@@ -76,6 +85,16 @@ export function draftItemFromItemTemplate(template: InvoiceItemTemplate): DraftL
}
}
export function draftAccountFromAccountTemplate(template: InvoiceAccountTemplate): DraftAccount {
return {
key: newKey(),
bankName: template.bankName,
accountHolderName: template.accountHolderName ?? '',
cardNumber: template.cardNumber ?? '',
iban: template.iban ?? '',
}
}
export function draftsFromInvoiceTemplate(template: InvoiceTemplate): {
name: string
topText: string