Remove estimated remaining decay, use audit values directly
Build and push image / build (push) Successful in 1m6s
Build and push image / build (push) Successful in 1m6s
Replace burn-rate estimation (linear decay between audits) with actual last audit values. Remaining is now always the last weigh-in value or original weight if no audits exist — no more speculative daily decay. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-13
@@ -206,28 +206,20 @@ export const helpers = {
|
||||
if (!cfg) return false;
|
||||
return this.daysSinceCheck(p, today) >= cfg.cadenceDays;
|
||||
},
|
||||
estimatedRemaining(p: Item, today = TODAY_STR): number {
|
||||
remaining(p: Item): number {
|
||||
if (p.status !== "active" && p.status !== "checked-out") return 0;
|
||||
if (p.kind === "discrete") {
|
||||
return p.countLastAudit ?? p.countOriginal;
|
||||
}
|
||||
const last = this.lastAudit(p);
|
||||
if (!last) return p.weight;
|
||||
const daysSinceBase = Math.max(
|
||||
0,
|
||||
Math.floor((+new Date(today) - +new Date(last.date)) / 86_400_000),
|
||||
);
|
||||
const expectedLifespan =
|
||||
p.type === "Flower" ? 35 : p.type === "Concentrate" ? 40 : 90;
|
||||
const dailyBurn = p.weight / expectedLifespan;
|
||||
return Math.max(0, last.value - dailyBurn * daysSinceBase);
|
||||
return last ? last.value : p.weight;
|
||||
},
|
||||
pctRemaining(p: Item, today = TODAY_STR): number {
|
||||
pctRemaining(p: Item): number {
|
||||
if (p.kind === "discrete") {
|
||||
const cur = p.countLastAudit ?? p.countOriginal;
|
||||
return p.countOriginal > 0 ? cur / p.countOriginal : 0;
|
||||
}
|
||||
const est = this.estimatedRemaining(p, today);
|
||||
return p.weight > 0 ? est / p.weight : 0;
|
||||
const rem = this.remaining(p);
|
||||
return p.weight > 0 ? rem / p.weight : 0;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user