Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
CPA-294 Buyer Supplier model update
Browse files Browse the repository at this point in the history
- [x] Add `country_id` integer and `summary` JSON column in `country_buyer` table
- [x] Set buyer country id value when creating buyer during contract data import
- [x] Add `country_id` integer and `summary` JSON column in `country_supplier` table
- [x] Set supplier country id value when creating buyer during contract data import# Please enter the commit message for your changes. Lines starting
  • Loading branch information
Suyoj Man Tamrakar committed May 5, 2021
1 parent 9b25271 commit 36cf3ae
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
34 changes: 34 additions & 0 deletions country/migrations/0034_auto_20210505_1156.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.1.7 on 2021-05-05 11:56

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('country', '0033_merge_20210416_0530'),
]

operations = [
migrations.AddField(
model_name='buyer',
name='country',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='buyers', to='country.country'),
),
migrations.AddField(
model_name='buyer',
name='summary',
field=models.JSONField(null=True),
),
migrations.AddField(
model_name='supplier',
name='country',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='suppliers', to='country.country'),
),
migrations.AddField(
model_name='supplier',
name='summary',
field=models.JSONField(null=True),
),
]
4 changes: 4 additions & 0 deletions country/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class Supplier(models.Model):
verbose_name=_("Supplier name"), max_length=250, null=True, blank=True, db_index=True
)
supplier_address = models.CharField(verbose_name=_("Supplier address"), max_length=250, null=True, blank=True)
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="suppliers", null=True)
summary = models.JSONField(null=True)
objects = SupplierManager()

def __str__(self):
Expand All @@ -148,6 +150,8 @@ class Buyer(models.Model):
buyer_id = models.CharField(verbose_name=_("Buyer ID"), max_length=50, null=True)
buyer_name = models.CharField(verbose_name=_("Buyer name"), max_length=250, null=True, blank=True, db_index=True)
buyer_address = models.CharField(verbose_name=_("Buyer address"), max_length=250, null=True, blank=True)
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name="buyers", null=True)
summary = models.JSONField(null=True)
objects = BuyerManager()

def __str__(self):
Expand Down
2 changes: 2 additions & 0 deletions country/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def import_tender_from_batch_id(batch_id, country, currency):
supplier_id=supplier_id,
supplier_name=supplier_name,
supplier_address=supplier_address,
country=country_obj,
)
supplier_obj.save()
else:
Expand All @@ -280,6 +281,7 @@ def import_tender_from_batch_id(batch_id, country, currency):
buyer_id=buyer_id,
buyer_name=buyer_name,
buyer_address=buyer_address,
country=country_obj,
)
buyer_obj.save()
else:
Expand Down

0 comments on commit 36cf3ae

Please sign in to comment.