增加铁路OCR金额字段安全诊断(07-28-travel-reimbursement-guide)
这个提交包含在:
@@ -73,6 +73,20 @@ function toNumberString(value) {
|
||||
return num.toFixed(2);
|
||||
}
|
||||
|
||||
function buildNumericFieldDiagnostics(value) {
|
||||
const present = value != null;
|
||||
const isString = typeof value === "string";
|
||||
const isNumber = typeof value === "number" && Number.isFinite(value);
|
||||
|
||||
return {
|
||||
present,
|
||||
isString,
|
||||
isNumber,
|
||||
nonEmpty: isString ? value.trim().length > 0 : isNumber,
|
||||
parseable: toNumberString(value) != null,
|
||||
};
|
||||
}
|
||||
|
||||
function addNumberStrings(...values) {
|
||||
const normalized = values.map((value) => toNumberString(value));
|
||||
if (normalized.some((value) => value == null)) {
|
||||
@@ -221,6 +235,12 @@ function normalizeElectronicTrainTicket(info) {
|
||||
taxAmount,
|
||||
totalAmount,
|
||||
buyerName: normalizeString(info?.Buyer),
|
||||
diagnostics: {
|
||||
trainAmountFields: {
|
||||
total: buildNumericFieldDiagnostics(info?.Total),
|
||||
fare: buildNumericFieldDiagnostics(info?.Fare),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户