
    si                         d Z ddlZddlmZ ddlmZmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ  G d de      Z G d de      Z G d de      Zy)z9
This page handles the cbv methods for payroll dashboard
    N)Any)FSumValue)reverse)timezone)gettext_lazy)DepartmentViewFilter)
Department)HorillaListView)ContractFilter)Contractc                   r     e Zd ZdZeZeZdZdZ	de
ddf fdZ fdZ ed      d	f ed
      dfgZdZ xZS )DashboardDepartmentPayslipz0
    list view for total department payslip
    FkwargsreturnNc                 R    t        |   di | t        d      | _        d| _        y )Nzdashboard-department-chartdashboadDepartment )super__init__r   
search_urlview_idselfr   	__class__s     9/var/www/python-projects/worksol/payroll/cbv/dashboard.pyr   z#DashboardDepartmentPayslip.__init__   s'    "6"!">?+    c                 r   | j                   j                  j                  d      }|j                  d      d   }|j                  d      d   }t        j
                  t        |         }t        | !         j                  ||      j                  t        d      t        d      t        |            }|S )	NmonthYearField-r      )?employeeworkinformation__employee_id__payslip__start_date__year@employeeworkinformation__employee_id__payslip__start_date__month6employeeworkinformation__employee_id__payslip__net_pay2employeeworkinformation__department_id__department)total_net_paydepartment_idmonth)requestGETgetsplitcalendar
month_nameintr   get_querysetfilterannotater   r   r   )r   
month_yearcurrent_yearcurrent_monthr/   querysetr   s         r   r1   z'DashboardDepartmentPayslip.get_queryset#   s    \\%%))*:;
!'',Q/"((-a0((]);<
G VP\Q^   X!L   TUM*   	 r   r   r(   zTotal Net Payr'   z
                onclick="window.location.href='/payroll/view-payslip/?department={department_id}&month={month}&department={department_id}'"
                )__name__
__module____qualname____doc__r   modelr
   filter_classshow_filter_tagsbulk_select_optionr   r   r1   _columns	row_attrs__classcell__r   s   @r   r   r      sa     E'L, , ,
2 
</*	
?	_-G
Ir   r   c                        e Zd ZdZdeddf fdZeZeZ	dZ
dZdZdZ fdZ ed	      d
f ed      dfgZd
diZdZ xZS )DashboardContractList2
    list view for contract ending this month
    r   r   Nc                 D    t        |   di | t        d      | _        y )Nzdashboard-contract-endingr   r   r   r   r   r   s     r   r   zDashboardContractList.__init__J   s     "6"!"=>r   Fz"cbv/dashboard/contract_ending.htmlc                    t         
|          }| j                  j                  j	                  d      }t        j                         }|j                  }|j                  }|j                  d      d   }|j                  d      d   }t        |      t        |      f}||f}	||	k  r|}|}|j                  t        |      t        |            }|S )Nr    r!   r   r"   contract_end_date__monthcontract_end_date__yearr   r1   r*   r+   r,   r   nowyearr)   r-   r0   r2   r   r7   r4   current_dater5   r6   rP   r)   input_month_yearcurrent_month_yearr   s             r   r1   z"DashboardContractList.get_querysetU   s    7')\\%%))*:;
||~#(($**$Q'  %a(Is5z2*M:00!ED??%(ZT # 
 r   r   contract_namezEnding Datecontract_end_date]
                              style="width:200px !important;"
                              
                hx-get='{contracts_detail}?instance_ids={ordered_ids}'
                hx-target="#genericModalBody"
                data-target="#genericModal"
                data-toggle="oh-modal-toggle"
                r8   r9   r:   r;   r   r   r   r<   r   r=   r>   r?   template_nameshow_toggle_formr1   r@   rA   header_attrsrB   rC   rD   s   @r   rF   rF   E   s~    ? ? ? E!L8M( 
:(	
=	./G 	 "L
Ir   rF   c                        e Zd ZdZdeddf fdZeZeZ	dZ
dZdZdZ fdZ ed	      d
f ed      dfgZd
diZdZ xZS )DashboardContractListExpiredrG   r   r   Nc                 D    t        |   di | t        d      | _        y )Nzdashboard-contract-expiredr   rI   r   s     r   r   z%DashboardContractListExpired.__init__   s     "6"!">?r   Fz#cbv/dashboard/contract_expired.htmlc                    t         
|          }| j                  j                  j	                  d      }t        j                         }|j                  }|j                  }|j                  d      d   }|j                  d      d   }t        |      t        |      f}||f}	||	k\  r|dk(  rd}|dz
  }n|dz
  }|}|j                  t        |      t        |            }|S )Nr    r!   r   r"      rK   rN   rQ   s             r   r1   z)DashboardContractListExpired.get_queryset   s    7')\\%%))*:;
||~#(($**$Q'  %a(Is5z2*M:11!#a'%)#??%(ZT # 
 r   r   rU   zExpired DaterV   rW   rX   rY   rD   s   @r   r^   r^   z   s    @ @ @ E!L9M. 
:(	
>	/0G 	 "L
Ir   r^   )r;   r.   typingr   django.db.modelsr   r   r   django.urlsr   django.utilsr   django.utils.translationr	   r@   base.filtersr
   base.modelsr   horilla_views.generic.cbv.viewsr   payroll.filtersr   payroll.models.modelsr   r   rF   r^   r   r   r   <module>rl      sV      * *  ! 6 - " ; * *. .b2O 2j5? 5r   