update for wage
This commit is contained in:
@@ -2568,12 +2568,13 @@ class POSMachineForLiveStockTransactionsSerializer(serializers.ModelSerializer):
|
||||
|
||||
|
||||
class POSDeviceSessionForInspectionSerializer(serializers.ModelSerializer):
|
||||
pos = POSMachineForInspectionsSerializer(read_only=True)
|
||||
lat = serializers.FloatField(source='lot', read_only=True)
|
||||
lng = serializers.FloatField(read_only=True)
|
||||
guilds_name = serializers.CharField(source='pos.guild.guilds_name', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = POSDeviceSession
|
||||
fields = ['key', 'name', 'pos', 'version', 'session_last_seen_date', 'lng', 'lot']
|
||||
|
||||
fields = ['lat', 'lng', 'guilds_name']
|
||||
|
||||
class POSMachineForServerSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
@@ -4001,18 +4002,42 @@ class TotalWageInformationSerializer(serializers.ModelSerializer):
|
||||
except:
|
||||
user = SystemUserProfile.objects.get(key=self.context.get('request').GET['key'])
|
||||
kill_house = KillHouse.objects.filter(kill_house_operator__user=user, trash=False).first()
|
||||
# if date1:
|
||||
# finance_info = get_finance_info(kill_house, date1, date2)
|
||||
# slaughter_transactions = InternalTransaction.objects.filter(
|
||||
# Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), date__date__gte=date1,
|
||||
# date__date__lte=date2, status='completed',
|
||||
# trash=False)
|
||||
#
|
||||
# else:
|
||||
# finance_info = get_finance_info(kill_house)
|
||||
# slaughter_transactions = InternalTransaction.objects.filter(
|
||||
# Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), status='completed',
|
||||
# trash=False)
|
||||
if date1:
|
||||
finance_info = get_finance_info(kill_house, date1, date2)
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), date__date__gte=date1,
|
||||
date__date__lte=date2, status='completed',
|
||||
trash=False)
|
||||
if kill_house.killer and kill_house.type == 'public':
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
kill_house=kill_house,parent_kill_house=kill_house, date__date__gte=date1,
|
||||
date__date__lte=date2, status='completed',
|
||||
trash=False)
|
||||
else:
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), date__date__gte=date1,
|
||||
date__date__lte=date2, status='completed',
|
||||
trash=False)
|
||||
|
||||
else:
|
||||
finance_info = get_finance_info(kill_house)
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), status='completed',
|
||||
trash=False)
|
||||
if kill_house.killer and kill_house.type == 'public':
|
||||
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
kill_house=kill_house,parent_kill_house=kill_house, status='completed',
|
||||
trash=False)
|
||||
else:
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), status='completed',
|
||||
trash=False)
|
||||
|
||||
total_paid_wage += slaughter_transactions.aggregate(total=Sum('amount'))[
|
||||
'total'] or 0
|
||||
|
||||
@@ -1502,6 +1502,7 @@ class DispenserInformationViewSet(viewsets.ModelViewSet):
|
||||
dispenser_info.dispenser.save()
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class RepresentativeViewSet(viewsets.ModelViewSet):
|
||||
queryset = Representative.objects.all()
|
||||
permission_classes = [TokenHasReadWriteScope]
|
||||
@@ -2045,8 +2046,8 @@ class GuildsViewSet(viewsets.ModelViewSet):
|
||||
if 'psp_pos' in request.GET:
|
||||
base_queryset = (
|
||||
Guilds.objects.filter(trash=False, active=True, has_inquiry=True)
|
||||
.select_related('user', 'address__city')
|
||||
.values(
|
||||
.select_related('user', 'address__city')
|
||||
.values(
|
||||
'key',
|
||||
'guilds_name',
|
||||
'guilds_id',
|
||||
@@ -2167,8 +2168,8 @@ class GuildsViewSet(viewsets.ModelViewSet):
|
||||
steward = Guilds.objects.select_related('user').get(user=user, active=True, trash=False)
|
||||
base_queryset = (
|
||||
Guilds.objects.filter(trash=False, active=True)
|
||||
.select_related('user', 'address__city')
|
||||
.values(
|
||||
.select_related('user', 'address__city')
|
||||
.values(
|
||||
'key',
|
||||
'guilds_name',
|
||||
'steward',
|
||||
@@ -2270,8 +2271,8 @@ class GuildsViewSet(viewsets.ModelViewSet):
|
||||
if all:
|
||||
base_queryset = (
|
||||
Guilds.objects
|
||||
.filter(trash=False, active=True).select_related('user', 'address__city')
|
||||
.values(
|
||||
.filter(trash=False, active=True).select_related('user', 'address__city')
|
||||
.values(
|
||||
'key',
|
||||
'guilds_name',
|
||||
'steward',
|
||||
@@ -3880,8 +3881,8 @@ class StewardFreeBarInformationViewSet(viewsets.ModelViewSet):
|
||||
steward = Guilds.objects.get(user=user, active=True, trash=False)
|
||||
product = RolesProducts.objects.get(key=request.data['product_key'], trash=False)
|
||||
request.data.pop('product_key')
|
||||
dispenser = request.data.pop('dispenser',None)
|
||||
representative = request.data.pop('representative',None)
|
||||
dispenser = request.data.pop('dispenser', None)
|
||||
representative = request.data.pop('representative', None)
|
||||
try:
|
||||
image = request.data['bar_image']
|
||||
request.data.pop('bar_image')
|
||||
@@ -4187,8 +4188,8 @@ class StewardFreeSaleBarInformationViewSet(viewsets.ModelViewSet):
|
||||
buyer = OutProvinceCarcassesBuyer.objects.get(key=request.data.pop('buyer_key', None), trash=False)
|
||||
date = datetime.strptime(str(request.data['date']), '%Y-%m-%d').date()
|
||||
production_date = datetime.strptime(str(request.data['production_date']), '%Y-%m-%d').date()
|
||||
dispenser = request.data.pop('dispenser',None)
|
||||
representative = request.data.pop('representative',None)
|
||||
dispenser = request.data.pop('dispenser', None)
|
||||
representative = request.data.pop('representative', None)
|
||||
date = datetime(year=date.year, month=date.month, day=date.day, hour=now_time.hour,
|
||||
minute=now_time.minute,
|
||||
second=now_time.second)
|
||||
@@ -4686,8 +4687,8 @@ class StewardAllocationViewSet(viewsets.ModelViewSet):
|
||||
now = datetime.now()
|
||||
now_time = now.time()
|
||||
production_date = None
|
||||
dispenser = request.data.pop('dispenser',None)
|
||||
representative = request.data.pop('representative',None)
|
||||
dispenser = request.data.pop('dispenser', None)
|
||||
representative = request.data.pop('representative', None)
|
||||
date = datetime.strptime(str(request.data['date']), '%Y-%m-%d').date()
|
||||
|
||||
date = datetime(year=date.year, month=date.month, day=date.day, hour=now_time.hour,
|
||||
@@ -5521,10 +5522,11 @@ class InProvinceAllocationDashboardViewSet(viewsets.ModelViewSet):
|
||||
else:
|
||||
filters['steward__user__city'] = user.city
|
||||
if allocations_type == 'Steward':
|
||||
allocations = StewardAllocation.objects.filter(Q(steward__isnull=False)|Q(guilds__isnull=False),**filters)
|
||||
allocations = StewardAllocation.objects.filter(Q(steward__isnull=False) | Q(guilds__isnull=False),
|
||||
**filters)
|
||||
else:
|
||||
|
||||
allocations = StewardAllocation.objects.filter(**filters)
|
||||
allocations = StewardAllocation.objects.filter(**filters)
|
||||
if value and search == 'filter':
|
||||
if value != 'undefined' and value.strip():
|
||||
allocations = allocations.filter(
|
||||
@@ -5908,9 +5910,9 @@ class InProvinceAllocationViewSet(viewsets.ModelViewSet):
|
||||
else:
|
||||
filters['steward__user__city'] = user.city
|
||||
|
||||
|
||||
if allocations_type == 'Steward':
|
||||
allocations = StewardAllocation.objects.filter(Q(steward__isnull=False)|Q(guilds__isnull=False),**filters).order_by('-date')
|
||||
allocations = StewardAllocation.objects.filter(Q(steward__isnull=False) | Q(guilds__isnull=False),
|
||||
**filters).order_by('-date')
|
||||
else:
|
||||
allocations = StewardAllocation.objects.filter(**filters).order_by('-date')
|
||||
if value and search == 'filter':
|
||||
@@ -11505,11 +11507,11 @@ class RejectedRequestsViewSet(viewsets.ModelViewSet):
|
||||
'rejected_position': 'financial',
|
||||
'rejected_position_farsi': 'مالی',
|
||||
'province_operator': n.kill_house_assignment.kill_house_check.
|
||||
province_kill_request.province_request.province_operator_system.user.fullname,
|
||||
province_kill_request.province_request.province_operator_system.user.fullname,
|
||||
'kill_house': n.kill_house_assignment.kill_house_check.province_kill_request
|
||||
.kill_request.kill_house.name,
|
||||
.kill_request.kill_house.name,
|
||||
'city_operator': n.kill_house_assignment.kill_house_check.province_kill_request
|
||||
.province_request.city_request_Poultry.city_operator_system.user.fullname,
|
||||
.province_request.city_request_Poultry.city_operator_system.user.fullname,
|
||||
'modify_date': n.modify_date,
|
||||
'reason_message': n.message,
|
||||
'value': self.serializer_class(value).data
|
||||
@@ -19240,6 +19242,37 @@ def get_gate_way_payer_info(request):
|
||||
status=status.HTTP_200_OK
|
||||
|
||||
)
|
||||
# elif role == 'KillHouse':
|
||||
# total_unpaid_wage = 0
|
||||
# total_paid_wage = 0
|
||||
# real_free_sale_wage = 0
|
||||
# kill_house_kill_requests_wage = 0
|
||||
# # wage_type = WageType.objects.filter(en_name='province-kill-request').first()
|
||||
# # total_check_wage = wage_type.amount
|
||||
# kill_house = KillHouse.objects.filter(kill_house_operator__user=user, trash=False).first()
|
||||
# total_unpaid_wage = get_finance_info(kill_house)['total_price']
|
||||
#
|
||||
# slaughter_transactions = InternalTransaction.objects.filter(
|
||||
# Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), status='completed',
|
||||
# trash=False)
|
||||
#
|
||||
# total_paid_wage += slaughter_transactions.aggregate(total=Sum('amount'))[
|
||||
# 'total'] or 0
|
||||
#
|
||||
# return Response(
|
||||
# {
|
||||
# "role": role,
|
||||
# "user_key": user.key,
|
||||
# "name": kill_house.name,
|
||||
# "fullname": user.fullname,
|
||||
# "mobile": user.mobile,
|
||||
# "city": user.city.name,
|
||||
# "province": user.province.name,
|
||||
# "total_amount": total_unpaid_wage - (total_paid_wage + kill_house.off)
|
||||
# },
|
||||
# status=status.HTTP_200_OK
|
||||
#
|
||||
# )
|
||||
elif role == 'KillHouse':
|
||||
total_unpaid_wage = 0
|
||||
total_paid_wage = 0
|
||||
@@ -19249,10 +19282,14 @@ def get_gate_way_payer_info(request):
|
||||
# total_check_wage = wage_type.amount
|
||||
kill_house = KillHouse.objects.filter(kill_house_operator__user=user, trash=False).first()
|
||||
total_unpaid_wage = get_finance_info(kill_house)['total_price']
|
||||
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), status='completed',
|
||||
trash=False)
|
||||
if kill_house.killer and kill_house.type == 'public':
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
kill_house=kill_house, parent_kill_house=kill_house, status='completed',
|
||||
trash=False)
|
||||
else:
|
||||
slaughter_transactions = InternalTransaction.objects.filter(
|
||||
Q(kill_house=kill_house) | Q(parent_kill_house=kill_house), status='completed',
|
||||
trash=False)
|
||||
|
||||
total_paid_wage += slaughter_transactions.aggregate(total=Sum('amount'))[
|
||||
'total'] or 0
|
||||
@@ -19271,6 +19308,7 @@ def get_gate_way_payer_info(request):
|
||||
status=status.HTTP_200_OK
|
||||
|
||||
)
|
||||
|
||||
else:
|
||||
total_unpaid_wage = 0
|
||||
total_paid_wage = 0
|
||||
@@ -20171,11 +20209,13 @@ class CombinedPosProductsViewSet(viewsets.ModelViewSet):
|
||||
queryset = self.get_queryset(validation_device, version)
|
||||
serializer = self.get_serializer(queryset, many=True, context={'validation_device': validation_device})
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class NewCombinedPosProductsViewSet(viewsets.ModelViewSet):
|
||||
permission_classes = [AllowAny]
|
||||
serializer_class = NewCombinedPosProductSerializer
|
||||
|
||||
def get_queryset(self, pos, version,role):
|
||||
def get_queryset(self, pos, version, role):
|
||||
if role == 'KillHouse':
|
||||
kill_house = KillHouse.objects.filter(kill_house_operator__user=pos.owner).first()
|
||||
roles_products = RolesProducts.objects.filter(kill_house=kill_house, trash=False)
|
||||
@@ -20208,7 +20248,7 @@ class NewCombinedPosProductsViewSet(viewsets.ModelViewSet):
|
||||
validation_device = validator.validation_pos()
|
||||
version = request.headers.get('device-version')
|
||||
role = request.headers.get('device-role')
|
||||
queryset = self.get_queryset(validation_device, version,role)
|
||||
queryset = self.get_queryset(validation_device, version, role)
|
||||
serializer = self.get_serializer(queryset, many=True, context={'validation_device': validation_device})
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
|
||||
@@ -22828,8 +22868,8 @@ class AppSegmentationViewSet(viewsets.ModelViewSet):
|
||||
guild = None
|
||||
kill_house = None
|
||||
quota = None
|
||||
dispenser = request.data.pop('dispenser',None)
|
||||
representative = request.data.pop('representative',None)
|
||||
dispenser = request.data.pop('dispenser', None)
|
||||
representative = request.data.pop('representative', None)
|
||||
product = RolesProducts.objects.get(key=request.data['product_key'], trash=False)
|
||||
if product.guild:
|
||||
guild = product.guild
|
||||
@@ -24541,7 +24581,7 @@ class PoultryAndHatchingForPoultryScience(GenericAPIView):
|
||||
elif role == 'CityPoultry':
|
||||
city_poultry = CityPoultry.objects.get(user=user, trash=False)
|
||||
hatching = hatching.filter(
|
||||
poultry__address__city=city_poultry.city
|
||||
poultry__address__city=city_poultry.address.city
|
||||
)
|
||||
else:
|
||||
hatching = hatching
|
||||
@@ -25950,9 +25990,14 @@ class StewardRemainWeightViewSet(GenericAPIView):
|
||||
production_date__isnull=False,
|
||||
steward_warehouse=True
|
||||
)
|
||||
input_allocations_vals = allocations_vals.filter(Q(to_guilds=steward,to_steward__isnull=True) | Q(to_steward=steward,to_guilds__isnull=True),receiver_state='accepted').values('production_date__date', 'date__date', 'quota', 'real_weight_of_carcasses', 'receiver_state')
|
||||
output_allocations_vals = allocations_vals.filter(Q(guilds=steward,steward__isnull=True) | Q(steward=steward,guilds__isnull=True),receiver_state__in=('accepted','pending')).values('production_date__date', 'date__date', 'quota', 'real_weight_of_carcasses', 'receiver_state')
|
||||
|
||||
input_allocations_vals = allocations_vals.filter(
|
||||
Q(to_guilds=steward, to_steward__isnull=True) | Q(to_steward=steward, to_guilds__isnull=True),
|
||||
receiver_state='accepted').values('production_date__date', 'date__date', 'quota',
|
||||
'real_weight_of_carcasses', 'receiver_state')
|
||||
output_allocations_vals = allocations_vals.filter(
|
||||
Q(guilds=steward, steward__isnull=True) | Q(steward=steward, guilds__isnull=True),
|
||||
receiver_state__in=('accepted', 'pending')).values('production_date__date', 'date__date', 'quota',
|
||||
'real_weight_of_carcasses', 'receiver_state')
|
||||
|
||||
free_bar_vals = list(StewardFreeBarInformation.objects.filter(
|
||||
steward=steward,
|
||||
@@ -26020,19 +26065,17 @@ class StewardRemainWeightViewSet(GenericAPIView):
|
||||
w = a['real_weight_of_carcasses'] or 0
|
||||
q = a['quota']
|
||||
if a[date_field] not in input_alloc_daily:
|
||||
input_alloc_daily[a[date_field]] = {'governmental': 0, 'free': 0}
|
||||
input_alloc_daily[a[date_field]] = {'governmental': 0, 'free': 0}
|
||||
input_alloc_daily[a[date_field]][q] += w
|
||||
|
||||
|
||||
for a in output_allocations_vals:
|
||||
date_field = 'production_date__date'
|
||||
w = a['real_weight_of_carcasses'] or 0
|
||||
q = a['quota']
|
||||
if a[date_field] not in output_alloc_daily:
|
||||
output_alloc_daily[a[date_field]] = {'governmental': 0, 'free': 0}
|
||||
output_alloc_daily[a[date_field]] = {'governmental': 0, 'free': 0}
|
||||
output_alloc_daily[a[date_field]][q] += w
|
||||
|
||||
|
||||
free_bar_daily = {}
|
||||
for f in free_bar_vals:
|
||||
d = f['date__date']
|
||||
|
||||
Reference in New Issue
Block a user