@nietzsci/zarith-templates
v0.3.2
Published
POS Native Core industry receipt templates (beauty / refund / batch close / retail / kitchen)
Readme
@nietzsci/zarith-templates
5 套行业小票模板(BB365 主用 + 通用扩展演示)。
模板清单
| id | 函数 | 用途 |
|---|---|---|
| beauty_sale_v1 | beautyServiceTemplate | 美业服务单(BB365 主用) |
| refund_v1 | refundTemplate | 退款单(含可选签名位) |
| batch_close_v1 | batchCloseTemplate | 批结日报(含按卡品牌汇总) |
| retail_sale_v1 | retailTemplate | 零售通用销售单(含找零 + 会员积分) |
| kitchen_ticket_v1 | kitchenTemplate | 餐饮厨房单(大字号 + 辣度标记 + 蜂鸣) |
用法
import { beautyServiceTemplate } from '@nietzsci/zarith-templates';
const builder = beautyServiceTemplate({
storeName: 'BB365 美业沙龙',
orderId: 'SO-001',
timestamp: new Date(),
staffName: '小美',
services: [{ name: '美甲基础款', duration: 60, price: 25.0 }],
subtotal: 25.0,
total: 25.0,
paymentMethod: 'card',
cardBrand: 'VISA',
cardLast4: '1234',
});
// 模板返回 ReceiptBuilder,业务方可继续 chain
builder.feed(1).barcode('SO-001');
await pos.print.receipt({ dsl: builder.build() });设计原则
- 每个模板都返回
ReceiptBuilder(不是DslRoot),让业务方还能继续 chain - 强类型 input:每个模板有自己的 data interface
- 合理默认:纸宽默认 80mm,可传
paperWidth: 58切换 - 不预设语言:所有文案在模板内部硬编码(v1 不做 i18n,v1.x 后做)
npm 安装
本包已公开发布在 npm(@nietzsci/zarith-templates,0.1.1),直接安装即可(运行时依赖 @nietzsci/zarith-receipt,需一并安装):
npm i @nietzsci/zarith-templates @nietzsci/zarith-receipt