Skip to content

Commit

Permalink
Merge pull request #144 from alyf-de/fix-143
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra authored Jan 2, 2025
2 parents ee053db + 3399ed3 commit f21ece0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/server-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
name: Server

on:
schedule:
- cron: "42 4 * * *"
push:
branches:
- version-14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,25 +430,38 @@ def get_linked_payments(
from_reference_date,
to_reference_date,
)
return subtract_allocations(gl_account, matching)
subtract_allocations(gl_account, matching)

return matching


def subtract_allocations(gl_account, vouchers):
"Look up & subtract any existing Bank Transaction allocations"
copied = []
"""Look up & subtract any existing Bank Transaction allocations.
For example, assume `vouchers` contains a Payment Entry of 300 that already
has 100 allocated to some Bank Transaction. This function will subtract 100
from the Payment Entry's outstanding amount, so that the remaining amount
for reconciliation will be 200.
This does not affect "unpaid" vouchers (e.g. unpaid invoices) since they
are never directly allocated to a Bank Transaction.
"""
rows = get_total_allocated_amount([
(voucher.get("doctype"), voucher.get("name"))
for voucher in vouchers
])

if not rows:
return

for voucher in vouchers:
rows = get_total_allocated_amount(voucher.get("doctype"), voucher.get("name"))
amount = None
for row in rows:
if row["gl_account"] == gl_account:
amount = row["total"]
break

if amount:
voucher["paid_amount"] -= amount

copied.append(voucher)
return copied
for (doctype, name), values in rows.items():
if doctype != voucher.get("doctype") or name != voucher.get("name"):
continue

for value in values:
if value["gl_account"] == gl_account:
voucher["paid_amount"] -= value["total"]


def check_matching(
Expand Down
8 changes: 0 additions & 8 deletions banking/klarna_kosma_integration/test_kosma.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ def test_transactions_creation(self):
def test_bank_consent_set_get(self):
from banking.klarna_kosma_integration.utils import (
get_consent_data,
get_consent_start_date,
)
from erpnext.accounts.utils import get_fiscal_year

session_data = session_response.session_data
create_session_doc(session_data, session_response.flow_data)
Expand All @@ -227,12 +225,6 @@ def test_bank_consent_set_get(self):
self.assertEqual(consent_id, consent_response.get("consent_id"))
self.assertEqual(consent_token, consent_response.get("consent_token"))

start_date = get_consent_start_date(session_data.get("session_id_short"))
current_fiscal_year = get_fiscal_year(nowdate(), as_dict=True)

# check if consent start date is start of fiscal year
self.assertEqual(getdate(start_date), current_fiscal_year.year_start_date)


def get_formatted_consent():
return {
Expand Down

0 comments on commit f21ece0

Please sign in to comment.