BETA测试运营中 — 部分功能和商品尚未开放。
实战DEV

依据跟着日期一起来 — 截止日看板不存的东西

2026-06 我们刊了一篇税务截止日看板的文章。那篇没说日期是哪来的。这次我们自己做了 — 这块看板一个截止日都不存。只拿着规则每次现算,被周末顺延的日子它就说被顺延了。

makemind2026年8月17日

先说明。 2026 年 6 月,本刊登过一篇某会计事务所截止日看板的文章。本文中出现的人和商家并不真实存在。我们汇集了许多现场实际运转的方式,构成了虚构的人物,人物说的话也是编的。以下是按那个形状自己做的,客户和申报项目都是编的。

这个领域的难点不是算术。而是规则和日期是两回事,可事务所总是把规则那一边弄丢。

假设表格里有个单元格写着 2026-04-27。读它的人没有办法知道:这是法定期限、是因为周末而顺延的日子,还是抄去年表时打错的。

所以这块看板一个截止日都不存。

它存的是规则

/// A filing obligation, as a rule rather than a date.
class Duty {
  const Duty(this.client, this.name, this.dayOfMonth, this.monthOf, this.note);

  /// Statutory day of the month.
  final int dayOfMonth;

  /// Which month it lands in, relative to the period being filed.
  final int monthOf;
}

没有日期。只有「几月几号」这条规则。画面上出现的日期,每次都从那条规则算出来。

而且验证会确认这一点。如果画面上的截止日以字符串形式存在于源码里,就判失败。

board = s.call("board.today")
assert all(r["rule"] for r in board["rows"]), "every row must say which rule produced it"

这个检查真的抓到了东西。 第一次跑就失败了,原因是我在文档注释里当例子写的 2026-04-27。这是误报 — 那是注释,不是被存下来的日期。

可是在修它的时候,顺带揪出了一个真的。状态响应里硬写着 'today': '2026-04-20' 这个字符串,而这个值和代码上方的 _today 是必须一致的两处。

// Derived, not typed twice. Two places that must agree eventually
// disagree.
'today': _fmt(_today),

检查抓到的是注释,但既然去看了,就把真的那个修了。检查会误报,和检查没用,是两回事。

被周末顺延了,就说被顺延了

这个领域的招牌陷阱。人人都知道的规则,表格却总是忘。

/// Shift a statutory date off a weekend, and say that you did.
///
/// This is the rule everyone knows and every spreadsheet forgets. Returning
/// the shift as text rather than silently moving the date is the whole point:
/// "25th, moved to Monday" is checkable, "27th" is not.

运行日志。

2026-03-31 D-20  Fairfield   Corporate tax        [day 31 of month 3]
2026-04-10 D-10  Brightwater  Withholding — March  [day 10 of month 4]
2026-04-10 D-10  Northgate    Withholding — March  [day 10 of month 4]
2026-04-27 D7    Brightwater  VAT — Q1   [day 25 of month 4 · statutory 25th fell on Saturday]
2026-04-27 D7    Fairfield   VAT — Q1   [day 25 of month 4 · statutory 25th fell on Saturday]
2026-04-30 D10   Northgate    Local income tax     [day 30 of month 4]

04-25 确实是周六,所以顺延到 04-27,而理由就挂在方括号里。 也请注意:没有被顺延的行同样带着自己的规则 — 只解释被顺延的、其余只留一个日期,那么有规则的行和没规则的行在画面上就分不出来了。

验证两边都看。

assert any("fell on" in r["rule"] for r in board["rows"]), "a weekend shift must be marked in the rule"
截止看板 · 2026-04-20 —— 逾期 3、一周内 2。每行都带着生成该日期的规则,两条因周末顺延的也写明了这一点
截止看板 · 2026-04-20 —— 逾期 3、一周内 2。每行都带着生成该日期的规则,两条因周末顺延的也写明了这一点

缩到一个客户,规则照样跟着。

只看一家客户 —— 规则不变,只是行数少了
只看一家客户 —— 规则不变,只是行数少了

此内容需要开发者或更高等级

登录并升级您的方案即可继续阅读。

查看方案