update excel
This commit is contained in:
@@ -438,11 +438,23 @@ def management_poultry(request):
|
||||
def hatching_excel(request):
|
||||
filterset_class = PoultryHatchingFilterSet
|
||||
unknown = True if 'unknown' in request.GET else False
|
||||
poultry_hatch = PoultryHatching.objects.filter(archive=False,
|
||||
allow_hatching='pending',
|
||||
trash=False,unknown=unknown).select_related('poultry',
|
||||
if 'all_active_and_archive' in request.GET:
|
||||
poultry_hatch = PoultryHatching.objects.filter(
|
||||
trash=False).select_related('poultry',
|
||||
'poultry__user').order_by(
|
||||
'-chicken_age')
|
||||
elif 'unknown' in request.GET:
|
||||
poultry_hatch = PoultryHatching.objects.filter(unknown=True,
|
||||
trash=False).select_related('poultry',
|
||||
'poultry__user').order_by(
|
||||
'-chicken_age')
|
||||
else:
|
||||
poultry_hatch = PoultryHatching.objects.filter(archive=False,
|
||||
allow_hatching='pending',
|
||||
trash=False).select_related('poultry',
|
||||
'poultry__user').order_by(
|
||||
'-chicken_age')
|
||||
|
||||
filterset_fields = [
|
||||
'poultry__user__first_name',
|
||||
'poultry__user__last_name',
|
||||
@@ -580,8 +592,8 @@ def hatching_excel(request):
|
||||
red_font = Font(color="C00000", bold=True)
|
||||
|
||||
header_list = [
|
||||
'تعداد فارم فعال',
|
||||
'تعداد فارم دارای زنجیره فعال',
|
||||
'تعداد فارم ها',
|
||||
'تعداد جوجه ریزی ها',
|
||||
'مجموع جوجه ریزی',
|
||||
'مجموع تلفات دامپزشک(قطعه)',
|
||||
'مجموع تلفات اتحادیه(قطعه)',
|
||||
@@ -739,7 +751,7 @@ def hatching_excel(request):
|
||||
year=poultry_hatching.predicate_date.year
|
||||
) if poultry_hatching.predicate_date else '-'
|
||||
date1 = datetime.datetime.strptime(str(poultry_hatching.date), '%Y-%m-%d %H:%M:%S')
|
||||
age = (datetime.datetime.now() - date1).days + 1
|
||||
age = poultry_hatching.chicken_age
|
||||
|
||||
creator = '-'
|
||||
if poultry_hatching.registrar:
|
||||
@@ -753,6 +765,10 @@ def hatching_excel(request):
|
||||
if poultry_hatching.violation == True:
|
||||
farm_state = 'متخلف' + ' ' + '(مانده در سالن بیش از حد مجاز)'
|
||||
violation += 1
|
||||
elif poultry_hatching.archive == True:
|
||||
farm_state = 'بایگانی شده'
|
||||
elif poultry_hatching.unknown == True:
|
||||
farm_state = 'تعیین تکمیل نشده'
|
||||
if poultry_hatching.chain_company:
|
||||
chain_company = poultry_hatching.chain_company.name
|
||||
all_chain_company += 1
|
||||
@@ -849,7 +865,7 @@ def hatching_excel(request):
|
||||
poultry_hatching.killed_quantity,
|
||||
poultry_hatching.total_killed_weight,
|
||||
poultry_hatching.left_over,
|
||||
f'{int(poultry_hatching.left_over * 100 / poultry_hatching.quantity)}%',
|
||||
f'{int(poultry_hatching.left_over * 100 / poultry_hatching.quantity) if poultry_hatching.quantity else 0}%',
|
||||
left_over_ninty_percent,
|
||||
poultry_hatching.total_commitment,
|
||||
poultry_hatching.governmental_quantity,
|
||||
@@ -974,9 +990,10 @@ def hatching_excel(request):
|
||||
export_killed_weight_final = filtered_poultry_hatch.aggregate(
|
||||
total_quantity=Sum('export_killed_weight')).get(
|
||||
'total_quantity', 0) or 0
|
||||
poultry = Poultry.objects.filter(id__in=filtered_poultry_hatch.values_list('poultry', flat=True).distinct())
|
||||
value_header_list = [
|
||||
len(poultry),
|
||||
len(filtered_poultry_hatch),
|
||||
all_chain_company,
|
||||
all_poultry_hatching_quantity,
|
||||
all_losses,
|
||||
all_direct_losses,
|
||||
@@ -1376,8 +1393,8 @@ def archive_hatching_excel(request):
|
||||
cell.alignment = Alignment(horizontal='center', vertical='center')
|
||||
|
||||
header_list = [
|
||||
'تعداد فارم فعال',
|
||||
'تعداد فارم دارای زنجیره فعال',
|
||||
'تعداد فارم ها',
|
||||
'تعداد جوجه ریزی ها',
|
||||
'مجموع جوجه ریزی',
|
||||
'مجموع تلفات دامپزشک(قطعه)',
|
||||
'مجموع تلفات اتحادیه(قطعه)',
|
||||
@@ -1626,10 +1643,10 @@ def archive_hatching_excel(request):
|
||||
accepted_real_quantity_final = bar_complete_with_kill_house.aggregate(
|
||||
total_quantity=Sum('accepted_real_quantity')).get(
|
||||
'total_quantity', 0) or 0
|
||||
|
||||
poultry = Poultry.objects.filter(id__in=filtered_poultry_hatch.values_list('poultry', flat=True).distinct())
|
||||
value_header_list = [
|
||||
len(poultry),
|
||||
len(filtered_poultry_hatch),
|
||||
all_chain_company,
|
||||
all_poultry_hatching_quantity,
|
||||
all_losses,
|
||||
all_direct_losses,
|
||||
|
||||
Reference in New Issue
Block a user