Skip to content

Commit

Permalink
Fix: journal entry amounts (#157)
Browse files Browse the repository at this point in the history
* Fix: journal entry amounts

* fix tests

* Fix test run

---------

Co-authored-by: GitHub Actions <integrations@fylehq.com>
  • Loading branch information
ruuushhh and GitHub Actions committed Aug 14, 2024
1 parent dc9dc05 commit ed5bcdb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- uses: actions/checkout@v2
- name: Bring up Services and Run Tests
run: |
docker-compose -f docker-compose-pipeline.yml build
docker-compose -f docker-compose-pipeline.yml up -d
docker-compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --junit-xml=test-reports/report.xml --cov-report=xml --cov-fail-under=70
docker compose -f docker-compose-pipeline.yml build
docker compose -f docker-compose-pipeline.yml up -d
docker compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --junit-xml=test-reports/report.xml --cov-report=xml --cov-fail-under=70
echo "STATUS=$(cat pytest-coverage.txt | grep 'Required test' | awk '{ print $1 }')" >> $GITHUB_ENV
echo "FAILED=$(cat test-reports/report.xml | awk -F'=' '{print $5}' | awk -F' ' '{gsub(/"/, "", $1); print $1}')" >> $GITHUB_ENV
- name: Upload coverage reports to Codecov with GitHub Action
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
runs-on: ubuntu-latest
environment: CI Environment
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
- name: Bring up Services and Run Tests
run: |
docker-compose -f docker-compose-pipeline.yml build
docker-compose -f docker-compose-pipeline.yml up -d
docker-compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --junit-xml=test-reports/report.xml --cov-report=xml --cov-fail-under=95
docker compose -f docker-compose-pipeline.yml build
docker compose -f docker-compose-pipeline.yml up -d
docker compose -f docker-compose-pipeline.yml exec -T api pytest tests/ --cov --junit-xml=test-reports/report.xml --cov-report=xml --cov-fail-under=95
echo "STATUS=$(cat pytest-coverage.txt | grep 'Required test' | awk '{ print $1 }')" >> $GITHUB_ENV
echo "FAILED=$(cat test-reports/report.xml | awk -F'=' '{print $5}' | awk -F' ' '{gsub(/"/, "", $1); print $1}')" >> $GITHUB_ENV
- name: Upload coverage reports to Codecov with GitHub Action
Expand Down
4 changes: 2 additions & 2 deletions apps/business_central/exports/journal_entry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_or_update_object(self, accounting_export: AccountingExport, _: Advanc
journal_entry_object, _ = JournalEntry.objects.update_or_create(
accounting_export= accounting_export,
defaults={
'amount': sum([expense.amount for expense in expenses]) * -1,
'amount': sum([expense.amount for expense in expenses]),
'document_number': document_number,
'accounts_payable_account_id': accounts_payable_account_id,
'account_id': account_id,
Expand Down Expand Up @@ -119,7 +119,7 @@ def create_or_update_object(self, accounting_export: AccountingExport, advance_s
journal_entry_id = journal_entry.id,
expense_id=lineitem.id,
defaults={
'amount': lineitem.amount,
'amount': lineitem.amount * -1,
'account_id': account_id,
'account_type': account_type,
'document_number': document_number,
Expand Down
24 changes: 7 additions & 17 deletions tests/test_business_central/test_models.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import pytest
from fyle_accounting_mappings.models import EmployeeMapping, ExpenseAttribute, Mapping, MappingSetting

from apps.business_central.models import (
JournalEntry,
JournalEntryLineItems,
PurchaseInvoice,
PurchaseInvoiceLineitems
)
from fyle_accounting_mappings.models import (
EmployeeMapping,
Mapping,
MappingSetting,
ExpenseAttribute
)
from apps.workspaces.models import AdvancedSetting, ExportSetting
from apps.accounting_exports.models import AccountingExport, Expense
from apps.business_central.exports.accounting_export import AccountingDataExporter
from apps.business_central.models import JournalEntry, JournalEntryLineItems, PurchaseInvoice, PurchaseInvoiceLineitems
from apps.workspaces.models import AdvancedSetting, ExportSetting


def test_create_or_update_journal_entry_1(
Expand All @@ -40,7 +30,7 @@ def test_create_or_update_journal_entry_1(

journal_entry = JournalEntry.objects.first()
assert journal_entry.accounting_export.workspace.id == 1
assert journal_entry.amount == -50
assert journal_entry.amount == 50


def test_create_or_update_journal_entry_2(
Expand Down Expand Up @@ -76,7 +66,7 @@ def test_create_or_update_journal_entry_2(

journal_entry = JournalEntry.objects.first()
assert journal_entry.accounting_export.workspace.id == 1
assert journal_entry.amount == -50
assert journal_entry.amount == 50


def test_create_or_update_journal_entry_3(
Expand Down Expand Up @@ -116,7 +106,7 @@ def test_create_or_update_journal_entry_3(

journal_entry = JournalEntry.objects.first()
assert journal_entry.accounting_export.workspace.id == 1
assert journal_entry.amount == -50
assert journal_entry.amount == 50


def test_create_or_update_journal_entry_line_items(
Expand Down Expand Up @@ -151,7 +141,7 @@ def test_create_or_update_journal_entry_line_items(

assert len(journal_line_items) == 1
assert journal_line_items[0].journal_entry.accounting_export.workspace.id == 1
assert journal_line_items[0].journal_entry.amount == -50
assert journal_line_items[0].journal_entry.amount == 50


def test_create_or_update_purchase_invoice(
Expand Down

0 comments on commit ed5bcdb

Please sign in to comment.