feat(watcher): add BRI QRIS parsing and rules

Implement parsing for BRI QRIS transactions, including direct and forwarded message handling. Update rules to recognize QRIS success messages and adjust spending record mapping accordingly. Enhance tests to cover new functionality.
This commit is contained in:
2026-09-13 23:28:59 +07:00
parent 1b880ed554
commit 0fa0ed3380
9 changed files with 266 additions and 6 deletions
+28
View File
@@ -8,6 +8,8 @@ import {
} from "../src/lib/email.js";
import { matchRule } from "../src/handlers/match-rule.js";
import {
briQrisDirectBody,
briQrisForwardedBody,
briTransferDirectBody,
briTransferForwardedBody,
grabBody,
@@ -156,6 +158,32 @@ describe("matchRule", () => {
assert.equal(result.pass.rule.kind, "bri.transfer.success");
});
it("matches direct BRI QRIS", async () => {
const result = await matchRule({
messageId: "bri-qris-direct",
log: silentLog,
message: {
from: "Bank BRI <BankBRI@bri.co.id>",
subject: "Pembelian QRIS Berhasil",
body: briQrisDirectBody,
},
});
assert.equal(result.pass.rule.kind, "bri.qris.success");
});
it("matches forwarded BRI QRIS via original header", async () => {
const result = await matchRule({
messageId: "1a09b9031c233407",
log: silentLog,
message: {
from: "Nasyarobby Putra <nsrb@bu.edu>",
subject: "Fwd: Pembelian QRIS Berhasil",
body: briQrisForwardedBody,
},
});
assert.equal(result.pass.rule.kind, "bri.qris.success");
});
it("breaks on unknown from/subject", async () => {
const result = await matchRule({
messageId: "x",