Skip to content

Commit

Permalink
populate purchace invoice and invoice lineitems table
Browse files Browse the repository at this point in the history
  • Loading branch information
NileshPant1999 committed Nov 17, 2023
1 parent 1069b5a commit 97d0113
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
3 changes: 1 addition & 2 deletions apps/accounting_exports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def create_accounting_export(expense_objects: List[Expense], fund_source: str, w

# Group expenses based on specified fields and fund_source
accounting_exports = _group_expenses(expense_objects, export_setting, fund_source)

fund_source_map = {
'PERSONAL': 'reimbursable',
'CCC': 'credit_card'
Expand All @@ -138,7 +137,7 @@ def create_accounting_export(expense_objects: List[Expense], fund_source: str, w
workspace_id=workspace_id,
fund_source=accounting_export['fund_source'],
description=accounting_export,
status='COMPLETE'
status='ENQUEUED'
)

# Add related expenses to the AccountingExport object
Expand Down
1 change: 1 addition & 0 deletions apps/fyle/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def import_expenses(workspace_id, accounting_export: AccountingExport, source_ac
last_synced_at = getattr(workspace, f"{fund_source_map.get(fund_source_key)}_last_synced_at", None)
fyle_credentials = FyleCredential.objects.get(workspace_id=workspace_id)

last_synced_at = None
platform = PlatformConnector(fyle_credentials)

expenses = platform.expenses.get(
Expand Down
2 changes: 1 addition & 1 deletion apps/sage300/exports/purchase_invoice/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def check_accounting_export_and_start_import(workspace_id: int, accounting_expo

print('accounting exports', accounting_exports)
for index, accounting_export_group in enumerate(accounting_exports):
accounting_export, _ = AccountingExport.objects.get_or_create(
accounting_export, _ = AccountingExport.objects.update_or_create(
workspace_id=accounting_export_group.workspace_id,
id=accounting_export_group.id,
defaults={
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.1.2 on 2023-11-07 11:11
# Generated by Django 4.1.2 on 2023-11-16 20:01

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -7,11 +7,20 @@
class Migration(migrations.Migration):

dependencies = [
('django_q', '0014_schedule_cluster'),
('workspaces', '0002_sage300credential_importsetting_fylecredential_and_more'),
]

operations = [
migrations.RenameField(
model_name='workspace',
old_name='ccc_last_synced_at',
new_name='credit_card_last_synced_at',
),
migrations.RenameField(
model_name='workspace',
old_name='last_synced_at',
new_name='reimbursable_last_synced_at',
),
migrations.RemoveField(
model_name='advancedsetting',
name='schedule_id',
Expand Down
8 changes: 5 additions & 3 deletions apps/workspaces/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ def run_import_export(workspace_id: int, export_mode = None):

# For Reimbursable Expenses
if export_settings.reimbursable_expenses_export_type:
queue_import_reimbursable_expenses(workspace_id=workspace_id)
queue_import_reimbursable_expenses(workspace_id=workspace_id, synchronous=True)
accounting_export = AccountingExport.objects.get(
workspace_id=workspace_id,
type='FETCHING_REIMBURSABLE_EXPENSES'
)

print('i am here ronadldo', accounting_export.status)
if accounting_export.status == 'COMPLETE':
accounting_export_ids = AccountingExport.objects.filter(
fund_source='PERSONAL', exported_at__isnull=True).values_list('id', flat=True)


print('accounting expdts', accounting_export_ids)
if len(accounting_export_ids):
is_expenses_exported = True

Expand All @@ -47,7 +49,7 @@ def run_import_export(workspace_id: int, export_mode = None):

# For Credit Card Expenses
if export_settings.credit_card_expense_export_type:
queue_import_credit_card_expenses(workspace_id=workspace_id)
queue_import_credit_card_expenses(workspace_id=workspace_id, synchronous=True)
accounting_export = AccountingExport.objects.get(
workspace_id=workspace_id,
type='FETCHING_CREDIT_CARD_EXPENSES'
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ django-request-logging==0.7.5
django-filter==21.1

# DjangoQ for running async tasks
django-q==1.3.9
django-q==1.3.4

# Read Database Credentials as URL
dj-database-url==0.5.0
Expand Down

0 comments on commit 97d0113

Please sign in to comment.