PrintChecksCore
The main entry point for the PrintChecks core library.
Constructor
new PrintChecksCore(config?: PrintChecksCoreConfig)Configuration Options
interface PrintChecksCoreConfig {
// Storage adapter (defaults to LocalStorage)
storage?: StorageAdapter
// Storage options
storageOptions?: {
prefix?: string
encryption?: boolean
password?: string
}
// Auto-increment check numbers
autoIncrementCheckNumber?: boolean
// Auto-increment receipt numbers
autoIncrementReceiptNumber?: boolean
// Default currency
defaultCurrency?: Currency
// Enable debug logging
debug?: boolean
}Example
import { PrintChecksCore } from '@printchecks/core'
const printChecks = new PrintChecksCore({
autoIncrementCheckNumber: true,
defaultCurrency: 'USD',
debug: true
})Services
PrintChecksCore provides four service instances:
| Service | Description |
|---|---|
checks | Check management (CheckService) |
vendors | Vendor management (VendorService) |
bankAccounts | Bank account management (BankAccountService) |
receipts | Receipt management (ReceiptService) |
Check Methods
createCheck()
Create a new check.
async createCheck(data: Partial<CheckData>): Promise<Check>Example:
const check = await printChecks.createCheck({
checkNumber: '1001',
date: new Date().toLocaleDateString(),
amount: 1250.00,
payTo: 'Acme Corporation',
memo: 'Invoice #12345',
bankAccountId: 'account-1'
})getCheck()
Get a check by ID.
async getCheck(id: string): Promise<Check | null>getChecks()
Get checks with optional filters.
async getChecks(filters?: CheckFilters): Promise<Check[]>Filters:
interface CheckFilters {
status?: CheckStatus
vendorId?: string
bankAccountId?: string
fromDate?: Date
toDate?: Date
minAmount?: number
maxAmount?: number
searchTerm?: string
}Example:
const checks = await printChecks.getChecks({
bankAccountId: 'account-1',
minAmount: 100,
maxAmount: 1000
})updateCheck()
Update a check.
async updateCheck(id: string, updates: Partial<CheckData>): Promise<Check>deleteCheck()
Delete a check.
async deleteCheck(id: string): Promise<void>markCheckAsPrinted()
Mark a check as printed.
async markCheckAsPrinted(id: string): Promise<Check>voidCheck()
Void a check.
async voidCheck(id: string, reason?: string): Promise<Check>duplicateCheck()
Duplicate a check with a new check number.
async duplicateCheck(id: string, newCheckNumber?: string): Promise<Check>getNextCheckNumber()
Get the next check number.
async getNextCheckNumber(): Promise<string>Vendor Methods
createVendor()
Create a new vendor.
async createVendor(data: VendorData): Promise<Vendor>getVendor()
Get a vendor by ID.
async getVendor(id: string): Promise<Vendor | null>getVendors()
Get all vendors with optional filters.
async getVendors(filters?: VendorFilters): Promise<Vendor[]>updateVendor()
Update a vendor.
async updateVendor(id: string, updates: Partial<VendorData>): Promise<Vendor>deleteVendor()
Delete a vendor.
async deleteVendor(id: string): Promise<void>searchVendors()
Search vendors by name.
async searchVendors(searchTerm: string): Promise<Vendor[]>getFavoriteVendors()
Get all favorite vendors.
async getFavoriteVendors(): Promise<Vendor[]>toggleVendorFavorite()
Toggle vendor favorite status.
async toggleVendorFavorite(id: string): Promise<Vendor>Bank Account Methods
createBankAccount()
Create a new bank account.
async createBankAccount(data: BankAccountData): Promise<BankAccount>getBankAccount()
Get a bank account by ID.
async getBankAccount(id: string): Promise<BankAccount | null>getBankAccounts()
Get all bank accounts.
async getBankAccounts(filters?: BankAccountFilters): Promise<BankAccount[]>updateBankAccount()
Update a bank account.
async updateBankAccount(id: string, updates: Partial<BankAccountData>): Promise<BankAccount>deleteBankAccount()
Delete a bank account.
async deleteBankAccount(id: string): Promise<void>getDefaultBankAccount()
Get the default bank account.
async getDefaultBankAccount(): Promise<BankAccount | null>setDefaultBankAccount()
Set a bank account as default.
async setDefaultBankAccount(id: string): Promise<BankAccount>Receipt Methods
createReceipt()
Create a new receipt.
async createReceipt(data: Partial<ReceiptData>): Promise<Receipt>getReceipt()
Get a receipt by ID.
async getReceipt(id: string): Promise<Receipt | null>getReceipts()
Get all receipts.
async getReceipts(filters?: ReceiptFilters): Promise<Receipt[]>updateReceipt()
Update a receipt.
async updateReceipt(id: string, updates: Partial<ReceiptData>): Promise<Receipt>deleteReceipt()
Delete a receipt.
async deleteReceipt(id: string): Promise<void>addLineItem()
Add a line item to a receipt.
async addLineItem(receiptId: string, itemData: LineItemData): Promise<Receipt>updateLineItem()
Update a line item.
async updateLineItem(
receiptId: string,
itemId: string,
updates: Partial<LineItemData>
): Promise<Receipt>removeLineItem()
Remove a line item.
async removeLineItem(receiptId: string, itemId: string): Promise<Receipt>Analytics Methods
getCheckStatistics()
Get check statistics.
async getCheckStatistics(): Promise<{
total: number
printed: number
void: number
draft: number
totalAmount: number
}>getAllStatistics()
Get all statistics.
async getAllStatistics(): Promise<{
checks: CheckStatistics
vendors: VendorStatistics
bankAccounts: BankAccountStatistics
receipts: ReceiptStatistics
}>Data Management Methods
exportData()
Export all data.
async exportData(): Promise<{
version: string
exportDate: string
data: {
checks: CheckData[]
vendors: VendorData[]
bankAccounts: BankAccountData[]
receipts: ReceiptData[]
}
}>Example:
const data = await printChecks.exportData()
const json = JSON.stringify(data, null, 2)
// Download as file
const blob = new Blob([json], { type: 'application/json' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `printchecks-backup-${new Date().toISOString()}.json`
a.click()importData()
Import data from backup.
async importData(data: {
checks?: CheckData[]
vendors?: VendorData[]
bankAccounts?: BankAccountData[]
receipts?: ReceiptData[]
}): Promise<{
checks: { success: number; failed: number }
vendors: { success: number; failed: number }
bankAccounts: { success: number; failed: number }
receipts: { success: number; failed: number }
}>clearAllData()
Clear all data (use with caution!).
async clearAllData(): Promise<void>Encryption Methods
enableEncryption()
Enable encryption with a password.
async enableEncryption(password: string): Promise<void>disableEncryption()
Disable encryption.
async disableEncryption(password: string): Promise<void>changeEncryptionPassword()
Change encryption password.
async changeEncryptionPassword(oldPassword: string, newPassword: string): Promise<void>Utility Methods
getStorage()
Get the storage adapter instance (for advanced use cases).
getStorage(): StorageAdapterwaitForInitialization()
Wait for storage initialization to complete (required when using encryption).
async waitForInitialization(): Promise<void>Example:
const printChecks = new PrintChecksCore({
storageOptions: {
encryption: true,
password: 'my-password'
}
})
await printChecks.waitForInitialization()
// Now ready to use