Skip to content

Commit

Permalink
✨ (utils): 添加支付类型判断功能
Browse files Browse the repository at this point in the history
在 `Html.js` 中新增 `isPaymentType` 函数,用于判断支付类型并返回匹配的账单类型。同时更新 `index.js` 以导出该函数。
  • Loading branch information
AnkioTomas committed Dec 25, 2024
1 parent dcc814b commit 0103f92
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/utils/Html.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BillType } from 'common/BillType.js';

export function stripHtml(html) {
return html.replace(/<[^>]*>/g, '');
}
Expand Down Expand Up @@ -34,3 +36,24 @@ export function splitShop(shopItem, _shopName, split) {
return { shopName, shopItem };
}

export function isPaymentType (type, words) {
let matchType = BillType.Income;
let matchTypeName = type;
let _words = [
'支付',
'消费',
'支出',
'抵扣'
];
if (words) {
_words.push(...words);
}
for (let i = 0; i < _words.length; i++) {
if (type.indexOf(_words[i]) !== -1) {
matchType = BillType.Expend;
break;
}
}
return { matchType, matchTypeName };
}

3 changes: 2 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BillType } from './BillType.js';
import { Currency, transferCurrency } from './Currency.js';
import { findNonEmptyString, stripHtml,splitShop } from './Html.js';
import { findNonEmptyString, isPaymentType, splitShop, stripHtml } from './Html.js';
import { formatDate, isTimeInRange } from './Time.js';
import { toDoubleFloat, toFloat } from './Number.js';
import { RuleObject } from './RuleObject.js';
Expand All @@ -23,4 +23,5 @@ export {
AliTools,
splitSms,
parseWechat,
isPaymentType
};

0 comments on commit 0103f92

Please sign in to comment.