P05-02: 全費目と資金区分:表金・裏金、維持費未払い、仕入れ、人件費、元本、利息、税の帳簿への接続(原 P05-02 の完了の条件)
This commit is contained in:
@@ -230,7 +230,7 @@ func _build_repayment_controls(style_button: Callable) -> void:
|
||||
loan_amount = LineEdit.new()
|
||||
loan_amount.name = "LoanRepaymentAmount"
|
||||
loan_amount.placeholder_text = "返済する元本(整数G)"
|
||||
loan_amount.tooltip_text = "残元本と手持ちを超えない整数額を入力"
|
||||
loan_amount.tooltip_text = "残元本と表金・裏金の合計を超えない整数額を入力"
|
||||
_loan_box.add_child(loan_amount)
|
||||
loan_amount.text_changed.connect(func(_text: String) -> void: _refresh_repayment_controls())
|
||||
loan_amount.text_submitted.connect(func(_text: String) -> void: submit_repayment(false))
|
||||
@@ -289,12 +289,14 @@ func _refresh_repayment_controls() -> void:
|
||||
var row := _loan_row(report)
|
||||
var remaining := int(row.get(&"outstanding_principal", 0))
|
||||
var cash := int(report.get(&"cash", 0))
|
||||
# A09: the front fund pays first and the hidden fund covers the rest in the same posting.
|
||||
var funds := int(report.get(&"available_funds", cash))
|
||||
var waiting := not (row.get(&"pending_command_ids", []) as Array).is_empty()
|
||||
var allowed := bool(report.get(&"available", false)) and bool(report.get(&"ledger_valid", false)) and not bool(report.get(&"terminal", false)) and remaining > 0 and not waiting
|
||||
var text := loan_amount.text.strip_edges()
|
||||
var amount := int(text) if text.is_valid_int() else 0
|
||||
repay_button.disabled = not allowed or amount <= 0 or amount > remaining or amount > cash
|
||||
repay_all_button.disabled = not allowed or remaining > cash
|
||||
repay_button.disabled = not allowed or amount <= 0 or amount > remaining or amount > funds
|
||||
repay_all_button.disabled = not allowed or remaining > funds
|
||||
loan_amount.editable = allowed
|
||||
if not bool(report.get(&"available", false)) or not bool(report.get(&"ledger_valid", false)):
|
||||
_loan_hint.text = "返済の帳簿を確認できません。"
|
||||
@@ -303,13 +305,13 @@ func _refresh_repayment_controls() -> void:
|
||||
elif loans.is_empty():
|
||||
_loan_hint.text = "借入はありません。"
|
||||
elif waiting:
|
||||
_loan_hint.text = "返済を受理済みです。次の時間更新で実行し、手持ちと残元本を再確認します。"
|
||||
_loan_hint.text = "返済を受理済みです。次の時間更新で実行し、表金・裏金と残元本を再確認します。"
|
||||
elif remaining == 0:
|
||||
_loan_hint.text = "この借入は完済しています。"
|
||||
else:
|
||||
_loan_hint.text = "手持ち %dGから元本を返済します。残元本 %dG。返済額は日次経費に含まれます。" % [cash, remaining]
|
||||
if remaining > cash: _loan_hint.text += "\n完済には手持ちが不足しています。"
|
||||
if not text.is_empty() and repay_button.disabled: _loan_hint.text += "\n残元本と手持ちを超えない正の整数額を入力してください。"
|
||||
_loan_hint.text = "表金 %dG・裏金 %dG(計 %dG)から元本を返済します。表金で足りない分は裏金から補填します。残元本 %dG。返済額は日次経費に含まれます。" % [cash, funds - cash, funds, remaining]
|
||||
if remaining > funds: _loan_hint.text += "\n完済には表金と裏金の合計が不足しています。"
|
||||
if not text.is_empty() and repay_button.disabled: _loan_hint.text += "\n残元本と表金・裏金の合計を超えない正の整数額を入力してください。"
|
||||
|
||||
|
||||
func submit_repayment(full: bool = false) -> void:
|
||||
@@ -318,8 +320,8 @@ func submit_repayment(full: bool = false) -> void:
|
||||
var remaining := int(row.get(&"outstanding_principal", 0))
|
||||
var text := loan_amount.text.strip_edges()
|
||||
var amount := remaining if full else (int(text) if text.is_valid_int() else 0)
|
||||
if not bool(report.get(&"ledger_valid", false)) or bool(report.get(&"terminal", false)) or row.is_empty() or not (row.get(&"pending_command_ids", []) as Array).is_empty() or amount <= 0 or amount > remaining or amount > int(report.get(&"cash", 0)):
|
||||
_set_repayment_result("返済できません。手持ち・残元本・返済待ちを確認してください。", false)
|
||||
if not bool(report.get(&"ledger_valid", false)) or bool(report.get(&"terminal", false)) or row.is_empty() or not (row.get(&"pending_command_ids", []) as Array).is_empty() or amount <= 0 or amount > remaining or amount > int(report.get(&"available_funds", report.get(&"cash", 0))):
|
||||
_set_repayment_result("返済できません。表金・裏金・残元本・返済待ちを確認してください。", false)
|
||||
_refresh_repayment_controls()
|
||||
return
|
||||
var key := StringName("ui.loan.repay.%d" % int(report[&"next_command_id"]))
|
||||
@@ -332,7 +334,7 @@ func submit_repayment(full: bool = false) -> void:
|
||||
var after := _loan_row(_loan_report())
|
||||
if result.is_success() and (after.get(&"pending_command_ids", []) as Array).has(int(result.command_id)):
|
||||
_loan_pending_command = int(result.command_id)
|
||||
_set_repayment_result("返済を受理しました。実行時に手持ちと残元本を確認します。", true)
|
||||
_set_repayment_result("返済を受理しました。実行時に表金・裏金と残元本を確認します。", true)
|
||||
else:
|
||||
_show_repayment_result(result)
|
||||
_refresh_repayment_controls()
|
||||
@@ -343,7 +345,7 @@ func _show_repayment_result(result: Variant) -> void:
|
||||
_set_repayment_result("元本 %dGを返済しました。残元本 %dG。" % [int(result.details.get(&"paid_principal", 0)), int(result.details.get(&"outstanding_principal", 0))], true)
|
||||
loan_amount.text = ""
|
||||
else:
|
||||
_set_repayment_result("返済を実行できませんでした。手持ちと残元本を確認してください。", false)
|
||||
_set_repayment_result("返済を実行できませんでした。表金・裏金と残元本を確認してください。", false)
|
||||
|
||||
|
||||
func _on_repayment_completed(result: Variant) -> void:
|
||||
|
||||
Reference in New Issue
Block a user