P05-02: 全費目と資金区分:表金・裏金、維持費未払い、仕入れ、人件費、元本、利息、税の帳簿への接続(原 P05-02 の完了の条件)
This commit is contained in:
@@ -65,6 +65,33 @@ func settle(period: Dictionary, economy: EconomyService) -> Dictionary:
|
||||
return {&"ok": true, &"replayed": false, &"receipt": receipt.duplicate(true), &"transaction_id": transaction_id}
|
||||
|
||||
|
||||
## Whole Gold that settling these closed periods would owe (arrears included),
|
||||
## planned with no cash; -1 if a period is invalid or already settled. Nothing changes.
|
||||
func preview_debt(periods: Array) -> int:
|
||||
var arrears := _arrears.duplicate()
|
||||
var fractions := _fractions.duplicate()
|
||||
var last_end := int(_receipts[-1].period.period_end) if not _receipts.is_empty() else -1
|
||||
var candidate := FacilityUpkeepSettlement.new()
|
||||
for raw: Variant in periods:
|
||||
if not raw is Dictionary:
|
||||
return -1
|
||||
var canonical := _parse_period(raw)
|
||||
if canonical.is_empty() or (last_end >= 0 and canonical.period_start != last_end):
|
||||
return -1
|
||||
candidate._arrears = arrears
|
||||
candidate._fractions = fractions
|
||||
var plan := candidate._plan(canonical, 0)
|
||||
if not plan[&"ok"]:
|
||||
return -1
|
||||
arrears = plan.arrears
|
||||
fractions = plan.fractions
|
||||
last_end = canonical.period_end
|
||||
var debt := 0
|
||||
for amount: int in arrears.values():
|
||||
debt += amount
|
||||
return debt
|
||||
|
||||
|
||||
func get_arrears_through(minute: int) -> int:
|
||||
var low := 0
|
||||
var high := _receipts.size()
|
||||
|
||||
Reference in New Issue
Block a user