实现报销材料连续预览(07-27-yang-jun-reimbursement-readiness)
这个提交包含在:
@@ -0,0 +1,22 @@
|
||||
const SAFE_DOCUMENT_CATEGORIES = new Set([
|
||||
"vat_invoice",
|
||||
"full_vat_invoice",
|
||||
"electronic_train_ticket",
|
||||
]);
|
||||
|
||||
function normalizeSafeMetaString(value, maxLength = 64) {
|
||||
if (typeof value !== "string") return null;
|
||||
const normalized = value.trim();
|
||||
return normalized ? normalized.slice(0, maxLength) : null;
|
||||
}
|
||||
|
||||
function mapInvoiceDocumentMeta(invoice) {
|
||||
const result = invoice?.ocr_result?.result_json;
|
||||
const category = normalizeSafeMetaString(result?.documentCategory);
|
||||
return {
|
||||
documentCategory: SAFE_DOCUMENT_CATEGORIES.has(category) ? category : null,
|
||||
documentSubtype: normalizeSafeMetaString(result?.documentSubtype),
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { mapInvoiceDocumentMeta };
|
||||
在新工单中引用
屏蔽一个用户