Skip to content

Commit

Permalink
fix: Typing and avoid setting status
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
marination committed Jun 17, 2024
1 parent 85bf41f commit 4fa49a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion banking/klarna_kosma_integration/test_kosma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 0 additions & 8 deletions banking/klarna_kosma_integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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,
Expand Down

0 comments on commit 4fa49a0

Please sign in to comment.