@firela/parser-cn
v0.1.2
Published
Chinese payment parser implementations (Alipay, WeChat Pay) for financial file formats
Downloads
78
Maintainers
Readme
@firela/parser-cn
Chinese payment and bank statement parsers for FireLa.
Installation
npm install @firela/parser-cnPeer Dependencies
This package requires the following peer dependencies:
npm install chrono-node csv-parse iconv-lite jschardetSupported Formats
Payment Parsers
| Parser | Format | Description |
|--------|--------|-------------|
| AlipayMobileParser | CSV | 支付宝 App 账单 (Alipay mobile app) |
| AlipayWebParser | CSV | 支付宝网页版账单 (Alipay web portal) |
| AlipayYuebaoParser | CSV | 余额宝账单 (Yu'e Bao/Alipay fund) |
Bank Parsers
| Parser | Format | Description |
|--------|--------|-------------|
| CcbDebitParser | CSV | 建设银行借记卡 (CCB debit card) |
| CmbcCreditParser | CSV | 民生银行信用卡 (CMBC credit card) |
Usage
import { AlipayMobileParser, CcbDebitParser } from '@firela/parser-cn';
// Identify and parse Alipay Mobile CSV
const alipayParser = new AlipayMobileParser();
const buffer = fs.readFileSync('alipay_bill.csv');
if (alipayParser.identify(buffer)) {
const result = alipayParser.parse(buffer);
if (result.success) {
console.log(result.data.transactions);
// => RawTransaction[] with AlipayCustomFields
}
}
// Parse CCB Debit statement
const ccbParser = new CcbDebitParser();
if (ccbParser.identify(buffer)) {
const result = ccbParser.parse(buffer);
if (result.success) {
console.log(result.data.transactions);
// => RawTransaction[] with BankCustomFields
}
}Output Format
All parsers return RawTransaction objects with parser-specific custom fields:
interface RawTransaction {
date: Date;
payee: string;
amount: Decimal;
currency: string;
direction: 'in' | 'out';
description: string;
customFields: AlipayCustomFields | BankCustomFields;
}License
MIT
