提交
This commit is contained in:
1 parent
b9ff9c9d67
commit
44749ae716
87 files changed
+35089
-21918
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { describe, it } from 'node:test'
|
||||
import {
|
||||
CRM_INVOICE_PASTE_SAMPLE_ANQING,
|
||||
CRM_INVOICE_PASTE_SAMPLE_JIANGFENG,
|
||||
parseCrmInvoicePaste,
|
||||
mergeInvoiceRemark
|
||||
} from './crm-invoice-paste-recognize'
|
||||
|
||||
describe('parseCrmInvoicePaste · 安庆山峡样例', () => {
|
||||
it('maps core fields and packs extra into remarkParts', () => {
|
||||
const r = parseCrmInvoicePaste(CRM_INVOICE_PASTE_SAMPLE_ANQING)
|
||||
assert.equal(r.companyName, '安庆市山峡化工有限公司')
|
||||
assert.equal(r.taxNo, '9134080006084212XH')
|
||||
assert.equal(r.bankName, '中国建设银行安庆分行城中支行')
|
||||
assert.equal(r.bankAccount, '34050168860800000121')
|
||||
assert.equal(r.companyAddress, '安徽省安庆市高新区霞虹路5号')
|
||||
assert.equal(r.phoneFax, '0556-5348918')
|
||||
assert.ok(r.filledCount >= 6)
|
||||
assert.ok(r.remarkParts.some((p) => p.includes('银行行号') && p.includes('105368000056')))
|
||||
assert.ok(r.remarkParts.some((p) => p.includes('邮编') && p.includes('246000')))
|
||||
assert.ok(r.remarkParts.some((p) => p.includes('邮寄') && p.includes('汪璇')))
|
||||
// 邮寄块内地址不得覆盖单位地址
|
||||
assert.equal(r.companyAddress, '安徽省安庆市高新区霞虹路5号')
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseCrmInvoicePaste · 江峰生物样例', () => {
|
||||
it('handles spaced labels, spaced account, and 地址及电话', () => {
|
||||
const r = parseCrmInvoicePaste(CRM_INVOICE_PASTE_SAMPLE_JIANGFENG)
|
||||
assert.equal(r.companyName, '安徽江峰生物科技有限公司')
|
||||
assert.equal(r.taxNo, '91340200MA8PYJNB8X')
|
||||
assert.equal(r.bankName, '中国建设银行芜湖经开区支行')
|
||||
assert.equal(r.bankAccount, '34050167880800002481')
|
||||
assert.ok((r.companyAddress || '').includes('安徽省芜湖市'))
|
||||
assert.ok(!(r.companyAddress || '').includes('0553'))
|
||||
assert.equal(r.phoneFax, '0553-5201019')
|
||||
assert.ok(r.remarkParts.some((p) => p.includes('银行行号') && p.includes('105362050066')))
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseCrmInvoicePaste · 边界', () => {
|
||||
it('returns empty filledCount for blank text', () => {
|
||||
const r = parseCrmInvoicePaste(' \n ')
|
||||
assert.equal(r.filledCount, 0)
|
||||
assert.ok(r.warnings.length > 0)
|
||||
})
|
||||
|
||||
it('does not treat 名称 inside unrelated prose without colon as company', () => {
|
||||
const r = parseCrmInvoicePaste('请查收开票资料,谢谢')
|
||||
assert.equal(r.filledCount, 0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('mergeInvoiceRemark', () => {
|
||||
it('appends new parts without duplicating existing', () => {
|
||||
const next = mergeInvoiceRemark('已有备注', ['银行行号:105', '邮编:246000'])
|
||||
assert.equal(next, '已有备注;银行行号:105;邮编:246000')
|
||||
const again = mergeInvoiceRemark(next, ['银行行号:105', '邮寄:张三'])
|
||||
assert.equal(again, '已有备注;银行行号:105;邮编:246000;邮寄:张三')
|
||||
})
|
||||
|
||||
it('returns existing when parts empty', () => {
|
||||
assert.equal(mergeInvoiceRemark('x', []), 'x')
|
||||
assert.equal(mergeInvoiceRemark('', ['a']), 'a')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user