数据库设备账单的模板列用法

  研究了一天,我这个代码小白总算搞出自己想要的效果啦,不发出来太浪费了

参考

  image

  设备账单 (eryi.love)

  ‍

使用效果

  image

计算实际使用日期
.action{$deadline := index . "弃用" }
.action{if empty $deadline}
.action{$today:= (div (now.Sub .购入).Hours 24)}
.action{$today}
.action{else}
.action{$today:= (div (.弃用.Sub .购入).Hours 24)}
.action{$today}
.action{end}
日均价格

  保留 2 位小数点

.action{$deadline := index . "弃用" }
.action{if empty $deadline}
.action{$today:= (divf (now.Sub .购入).Hours 24)}
.action{$money:= (divf .花费 $today)}
.action{$money:= round $money 2}
.action{$money}
.action{else}
.action{$a:= index . "花费" }
.action{$b:= index . "回血" }
.action{$result:= sub $a $b}
.action{$today:= (divf (.弃用.Sub .购入).Hours 24)}
.action{$money:= (divf $result $today)}
.action{$money:= round $money 2}
.action{$money}
.action{end}

  提前预知到了弃用后没写回血的情况并修复了 bug

.action{$deadline := index . "弃用" }
.action{$a:= index . "花费" }
.action{$b:= index . "回血" }
.action{if empty $deadline}
.action{$today:= (divf (now.Sub .购入).Hours 24)}
.action{$money:= (divf .花费 $today)}
.action{$money:= round $money 2}
.action{$money}
.action{else}
.action{if empty $b}
.action{$today:= (divf (.弃用.Sub .购入).Hours 24)}
.action{$money:= (divf .花费 $today)}
.action{$money:= round $money 2}
.action{$money}
.action{else}
.action{$result:= sub $a $b}
.action{$today:= (divf (.弃用.Sub .购入).Hours 24)}
.action{$money:= (divf $result $today)}
.action{$money:= round $money 2}
.action{$money}
.action{end}
.action{end}
  • 思源笔记

    思源笔记是一款隐私优先的个人知识管理系统,支持完全离线使用,同时也支持端到端加密同步。

    融合块、大纲和双向链接,重构你的思维。

    18802 引用 • 70343 回帖 • 1 关注
1 操作
102420Dinner 在 2024-04-01 20:39:04 更新了该帖

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...