From 4fa49a0b51781ee2fb57e5f459f12ab120efc3b9 Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 17 Jun 2024 17:27:22 +0200 Subject: [PATCH] fix: Typing and avoid setting status - Adjust types - In ERPNext from v15, the status is auto set on saving based on the unallocated amount. So we avoid setting it ourselves and change the test accordingly --- .../bank_reconciliation_tool_beta.py | 5 +++-- banking/klarna_kosma_integration/test_kosma.py | 2 +- banking/klarna_kosma_integration/utils.py | 8 -------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/banking/klarna_kosma_integration/doctype/bank_reconciliation_tool_beta/bank_reconciliation_tool_beta.py b/banking/klarna_kosma_integration/doctype/bank_reconciliation_tool_beta/bank_reconciliation_tool_beta.py index d768664b..d7ff69a7 100644 --- a/banking/klarna_kosma_integration/doctype/bank_reconciliation_tool_beta/bank_reconciliation_tool_beta.py +++ b/banking/klarna_kosma_integration/doctype/bank_reconciliation_tool_beta/bank_reconciliation_tool_beta.py @@ -1,6 +1,7 @@ # Copyright (c) 2023, ALYF GmbH and contributors # For license information, please see license.txt import json +from datetime import datetime from typing import Union import frappe @@ -71,8 +72,8 @@ def get_bank_transactions( def create_journal_entry_bts( bank_transaction_name: str, reference_number: str = None, - reference_date: str = None, - posting_date: str = None, + reference_date: str | datetime.date = None, + posting_date: str | datetime.date = None, entry_type: str = None, second_account: str = None, mode_of_payment: str = None, diff --git a/banking/klarna_kosma_integration/test_kosma.py b/banking/klarna_kosma_integration/test_kosma.py index 4cc4f228..cab27498 100644 --- a/banking/klarna_kosma_integration/test_kosma.py +++ b/banking/klarna_kosma_integration/test_kosma.py @@ -186,7 +186,7 @@ def test_transactions_creation(self): self.assertEqual(get_count("Bank Transaction"), 17) self.assertEqual(test_transn_doc.withdrawal, 3242.29) self.assertEqual(test_transn_doc.deposit, 0.0) - self.assertEqual(test_transn_doc.status, "Settled") + self.assertEqual(test_transn_doc.status, "Unreconciled") self.assertEqual(test_transn_doc.date, getdate("2022-12-03")) self.assertEqual(test_transn_doc.bank_party_name, "Hans Mustermann") self.assertEqual(test_transn_doc.bank_party_iban, "DE18000000006636981175") diff --git a/banking/klarna_kosma_integration/utils.py b/banking/klarna_kosma_integration/utils.py index 9a027036..aa7b0181 100644 --- a/banking/klarna_kosma_integration/utils.py +++ b/banking/klarna_kosma_integration/utils.py @@ -262,13 +262,6 @@ def new_bank_transaction(account: str, transaction: Dict) -> bool: debit = 0 if is_credit else float(amount) credit = float(amount) if is_credit else 0 - state_map = { - "PROCESSED": "Settled", - "PENDING": "Pending", - "CANCELED": "Settled", # TODO: is this status ok ? Should we even consider making cancelled/failed records - "FAILED": "Settled", - } - status = state_map[transaction.get("state")] transaction_id = transaction.get("transaction_id") if not transaction_id and transaction.get("state") == "PENDING": @@ -283,7 +276,6 @@ def new_bank_transaction(account: str, transaction: Dict) -> bool: { "doctype": "Bank Transaction", "date": getdate(transaction.get("value_date") or transaction.get("date")), - "status": status, "bank_account": account, "deposit": credit, "withdrawal": debit,