diff --git a/.idea/Rasaddam_Backend.iml b/.idea/Rasaddam_Backend.iml
index 9e31677..168bde0 100644
--- a/.idea/Rasaddam_Backend.iml
+++ b/.idea/Rasaddam_Backend.iml
@@ -14,7 +14,7 @@
-
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index e547571..f1b70db 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/apps/herd/management/commands/fix_rancher_full_name_on_transaction.py b/apps/herd/management/commands/fix_rancher_full_name_on_transaction.py
new file mode 100644
index 0000000..333b254
--- /dev/null
+++ b/apps/herd/management/commands/fix_rancher_full_name_on_transaction.py
@@ -0,0 +1,25 @@
+from django.core.management.base import BaseCommand
+
+from apps.warehouse.models import InventoryQuotaSaleTransaction
+
+
+class Command(BaseCommand):
+ help = "Fix Ranchers FullName on Transactions"
+
+ def handle(self, *args, **kwargs):
+ self.stdout.write("🔄 Bulk updating ranchers...")
+
+ trans_list = []
+ transactions = InventoryQuotaSaleTransaction.objects.all()
+ for trans in transactions:
+ if trans.rancher:
+ trans.rancher_fullname = trans.rancher.first_name + " " + trans.rancher.last_name if trans.rancher.last_name else ""
+ print(trans.rancher_fullname)
+ trans_list.append(trans)
+
+ self.stdout.write(" Bulk updating ranchers started...")
+ InventoryQuotaSaleTransaction.objects.bulk_update(trans_list, fields=['rancher_fullname'])
+
+ self.stdout.write(self.style.SUCCESS(
+ f"✅ Done! {0} set to True, {0} set to False"
+ ))
diff --git a/apps/herd/management/commands/fix_rancher_name.py b/apps/herd/management/commands/fix_rancher_name.py
new file mode 100644
index 0000000..7fae88f
--- /dev/null
+++ b/apps/herd/management/commands/fix_rancher_name.py
@@ -0,0 +1,28 @@
+from django.core.management.base import BaseCommand
+
+from apps.herd.models import Rancher
+
+
+class Command(BaseCommand):
+ help = "Fix Ranchers FirstName & LastName On Ranching Farm"
+
+ def handle(self, *args, **kwargs):
+ self.stdout.write("🔄 Bulk updating ranchers...")
+
+ ranchers_list = []
+ ranchers = Rancher.objects.all()
+ for rancher in ranchers:
+ if rancher.ranching_farm:
+ if not rancher.first_name or not rancher.last_name:
+ split_ranching_farm = rancher.ranching_farm.split(" ")
+ rancher.first_name = split_ranching_farm[0]
+ rancher.last_name = " ".join(split_ranching_farm[1:]) if len(split_ranching_farm) >= 2 else None
+ ranchers_list.append(rancher)
+ print(rancher.first_name, "--->", rancher.last_name)
+
+ self.stdout.write(" Bulk updating ranchers started...")
+ Rancher.objects.bulk_update(ranchers_list, fields=['first_name', 'last_name'])
+
+ self.stdout.write(self.style.SUCCESS(
+ f"✅ Done! {0} set to True, {0} set to False"
+ ))
diff --git a/apps/pos_device/services/services.py b/apps/pos_device/services/services.py
index e2fae84..c92d739 100644
--- a/apps/pos_device/services/services.py
+++ b/apps/pos_device/services/services.py
@@ -133,7 +133,6 @@ def agency_organization_pos_info(
"agency": True,
"default_account": True
})
-
return pos_sharing_list
return None
return None
diff --git a/apps/pos_device/web/api/v1/viewsets/device.py b/apps/pos_device/web/api/v1/viewsets/device.py
index 7e01021..778585e 100644
--- a/apps/pos_device/web/api/v1/viewsets/device.py
+++ b/apps/pos_device/web/api/v1/viewsets/device.py
@@ -113,12 +113,12 @@ class DeviceViewSet(BaseViewSet, SoftDeleteMixin, viewsets.ModelViewSet, AdminFi
organization = get_organization_by_user(request.user)
devices = self.get_queryset(
visibility_by_org_scope=True
- ) if organization.free_visibility_by_scope else self.get_queryset()
+ )
# filter by Jihad & admin of system
if organization.type.key == 'J':
queryset = devices.filter(assignment__client__organization__province=organization.province)
- elif not organization.type.key == 'ADM':
+ elif organization.type.key == 'PSP':
queryset = apply_visibility_filter_by_org_type(devices, organization)
else:
queryset = devices
diff --git a/apps/product/services/services.py b/apps/product/services/services.py
index 97216fa..67eb2c9 100644
--- a/apps/product/services/services.py
+++ b/apps/product/services/services.py
@@ -27,6 +27,7 @@ def quota_live_stock_allocation_info(quota: Quota) -> typing.Any:
""" information of quota live stock allocations """
allocations = quota.livestock_allocations.select_related('livestock_type')
+ print(allocations)
if allocations:
allocations_list = [{