
    siP'                     8   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z
 ddlmZmZ ddlmZmZmZmZmZ ddlmZ dd	lmZ  eed
       e ed      d
       G d de                    Z eed
       e ed      d
       G d de                    Z eed
       e ed      d
       G d de                    Z eed
       e ed      d
       G d de                    Z eed
       e ed      d
       G d de                    Zy)z*
this page handles cbv of allowances page
    )Any)reversereverse_lazy)method_decorator)gettext_lazy)login_requiredpermission_required)HorillaCardViewHorillaDetailedViewHorillaListViewHorillaNavViewTemplateView)AllowanceFilter)	Allowancedispatch)namezpayroll.view_allowance)permc                       e Zd ZdZdZy)AllowanceViewPagez
    for interview page
    z#cbv/allowances/allowances_home.htmlN)__name__
__module____qualname____doc__template_name     :/var/www/python-projects/worksol/payroll/cbv/allowances.pyr   r      s     :Mr   r   c                   ~    e Zd ZdZg dZeZeZde	ddf fdZ
 ed      df ed	      d
f ed      df ed      df ed      df ed      df ed      df ed      df ed      df ed      dfg
Zg dZddddZdZd Zd! ed"      d#fd$ ed%      d&fd' ed(      d)fd* ed+      d,fgZde	f fd-Z fd.Z xZS )/AllowanceListViewz
    list view of the page
    )specific_employeesexclude_employees
is_taxableis_fixedamountbased_onratekwargsreturnNc                    t        |   di | d| _        t        d      | _        | j
                  j                  j                  d      s%| j
                  j                  j                  d      rd| _        y d | _        y )Nallowance_idallowances-list-viewzpayroll.change_allowancezpayroll.delete_allowanceget_allowance_actionsr   )	super__init__view_idr   
search_urlrequestuserhas_permaction_methodselfr'   	__class__s     r   r.   zAllowanceListView.__init__5   sk    "6"%!"89<<%%&
\\''(BC!8D!%Dr   r   titleSpecific Employeesget_specific_employeesExcluded Employeesget_exclude_employeesz
Is Taxableget_is_taxable_displayzIs Condition Basedget_is_condition_based	Conditioncondition_based_displayzIs Fixedget_is_fixedAmountr$   zBased Onget_based_on_displayRater&   ))r   r8   )r9   r:   )r;   r<   )rB   r$   zA
                style="width:200px !important;"
                za
                                style="width:200px !important;"
                                )r8   r:   r<   
                hx-get='{allowance_detail_view}?instance_ids={ordered_ids}'
                hx-target="#genericModalBody"
                data-target="#genericModal"
                data-toggle="oh-modal-toggle"
                %taxable-{is_taxable} fixed-{is_fixed}taxable--dotTaxable
            onclick="
                $('#applyFilter').closest('form').find('[name=is_taxable]').val('true');
                $('[name=is_fixed]').val('unknown');
                $('#applyFilter').click();
            "
            non-taxable--dotNon Taxable
            onclick="$('#applyFilter').closest('form').find('[name=is_taxable]').val('false');
            $('[name=is_fixed]').val('unknown');
            $('#applyFilter').click();
            "
            
fixed--dotFixed
            onclick="$('#applyFilter').closest('form').find('[name=is_fixed]').val('true');
            $('[name=is_taxable]').val('unknown');
            $('#applyFilter').click();
            "
            not-fixed--dot	Not Fixed
            onclick="$('#applyFilter').closest('form').find('[name=is_fixed]').val('false');
            $('[name=is_taxable]').val('unknown');
                $('#applyFilter').click();
            "
            c                 H    t        |   di |}d| j                  _        |S )Nallowance_divr   )r-   get_context_datar1   rT   )r6   r'   contextr7   s      r   rU   z"AllowanceListView.get_context_data   s&    '*4V4%4"r   c                 H    t         |          }|j                  d      }|S z:
        Returns a filtered queryset of allowance
        T)only_show_under_employeer-   get_querysetexcluder6   querysetr7   s     r   r[   zAllowanceListView.get_queryset   *    
 7')##T#Br   )r   r   r   r   bulk_update_fieldsr   modelr   filter_classr   r.   _columnssortby_mappingheader_attrs	row_attrsrow_status_classrow_status_indicationsrU   r[   __classcell__r7   s   @r   r   r   !   sa    E"L	& 	& 	& 
;!	
	 ":;	
	 "9:	
<23	
	 ":;	
;23	
:'	
8h	
:./	
6FGN#$"$
LI ? iL
	
 m		
 gJ		
 kN		
A*X 
 r   r   c                   V     e Zd ZdZdeddf fdZ ed      Z e       Z	dZ
dZd	Z xZS )
AllowanceNavViewz
    nav bar of the page
    r'   r(   Nc                     t        |   di | t        d      | _        dt	        d       d| _        ddt        d      ddd	d
t        d      ddg| _        y )Nr+   z#
                            href="zcreate-allowancez"
                            listzlist-outlinezF
                            title='List'
                            )typeiconurlattrscardzgrid-outlineallowances-card-viewzF
                            title='Card'
                            r   )r-   r.   r   r0   r   create_attrs
view_typesr5   s     r   r.   zAllowanceNavView.__init__   s    "6"!"89!##/0B#C"D E  &56 	 &56 	
r   
Allowancesz$cbv/allowances/allowance_filter.htmlformz#listContainer)r   r   r   r   r   r.   rc   	nav_titler   filter_instancefilter_body_templatefilter_form_context_namesearch_swap_targetrj   rk   s   @r   rm   rm      s@    
 
 
6 ,I%'OA%)r   rm   c                        e Zd ZdZeZeZdeddf fdZ	 fdZ
ddd	d
ZdZdZd ed      dfd ed      dfd ed      dfd ed      dfgZ ed      dd ed      ddgZ xZS )AllowancesCardViewz 
    card view for the page
    r'   r(   Nc                 R    t        |   di | t        d      | _        d| _        y )Nru   allowance_cardr   )r-   r.   r   r0   r/   r5   s     r   r.   zAllowancesCardView.__init__   s'    "6"!"89'r   c                 H    t         |          }|j                  d      }|S rX   rZ   r]   s     r   r[   zAllowancesCardView.get_queryset   r_   r   
get_avatarz{title}ztAmount : {based_on_amount} <br> One Time Allowance : {one_time_date_display} <br> Taxable : {get_is_taxable_display})	image_srcr8   subtitlerE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   Editzr
            class="oh-dropdown__link"
            onclick="window.location.href='{get_update_url}' "
            )actionrs   Deletea-  
                    class="oh-dropdown__link"
                    hx-get="{get_delete_url}?model=payroll.Allowance&pk={pk}"
                    data-toggle="oh-modal-toggle"
                    data-target="#deleteConfirmation"
                    hx-target="#deleteConfirmationBody"
                )r   r   r   r   r   ra   r   rb   r   r.   r[   details
card_attrscard_status_classrc   card_status_indicationsactionsrj   rk   s   @r   r   r      s     E"L( ( (
 " KGJ @ iL
	
 m		
 gJ		
 kN		
A*\ i	
 k		
Gr   r   c                       e Zd ZdZeZ ed      ZddddZ ed      df ed	      d
f ed      df ed      df ed      df ed      dfgZ	dZ
y)AllowanceDetailViewz$
    detail view for allowances
    Detailsr8    r   )r8   r   avatarrH   r=   zOne Time Allowanceone_time_date_displayzCondition Basedr@   rB   based_on_amountzHas Maximum Limitcust_allowance_max_limitzAllowance Eligibilityallowance_eligibilityallowance_detail_actionsN)r   r   r   r   r   ra   rc   r8   headerbodyr4   r   r   r   r   r   7  s     EiLE F 
9/0	
	 "9:	
	89	
8'(	
	!;<	
"	#%<=D /Mr   r   N)r   typingr   django.urlsr   r   django.utils.decoratorsr   django.utils.translationr   rc   horilla_views.cbv_methodsr   r	   horilla_views.generic.cbv.viewsr
   r   r   r   r   payroll.filtersr   payroll.models.modelsr   r   r   rm   r   r   r   r   r   <module>r      sT    - 4 6 I  , + .z2%+CD:V: : W 3: .z2%+CD:V  W 3D .z2%+CD:V$*~ $* W 3$*N .z2%+CD:Vd d W 3dN .z2%+CD:V/- / W 3/r   