
    siA!                        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
mZ d dl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y)    )Any)reverse)method_decorator)gettext_lazy)login_requiredpermission_required)HorillaCardViewHorillaListViewHorillaNavViewTemplateView)DeductionFilter)	Deductiondispatch)namezpayroll.view_deduction)permc                       e Zd ZdZy)DeductionViewzcbv/deduction/deduction.htmlN)__name__
__module____qualname__template_name     9/var/www/python-projects/worksol/payroll/cbv/deduction.pyr   r      s	     3Mr   r   c                   V     e Zd ZdZdeddf fdZ ed      ZdZ e	       Z
dZd	Z xZS )
DeductionNavz
    Nav bar
    kwargsreturnNc                     t        |   di | t        d      | _        dt        d       d| _        ddt        d      ddd	d
t        d      ddg| _        y )Ndeduction-view-listz 
                          href=zcreate-deductionz
                          listzlist-outlinezF
                            title='List'
                            )typeiconurlattrscardzgrid-outlinezdeduction-view-cardzF
                            title='Card'
                            r   )super__init__r   
search_urlcreate_attrs
view_typesselfr   	__class__s     r   r(   zDeductionNav.__init__    s    "6"!"78!  '(: ;< =
 &45 	 &45 	
r   
Deductionszcbv/deduction/filter.htmlformz#listContainer)r   r   r   __doc__r   r(   _	nav_titlefilter_body_templater   filter_instancefilter_form_context_namesearch_swap_target__classcell__r.   s   @r   r   r      s@    
 
 
2 ,I6%'O%)r   r   c                   T    e Zd ZdZeZeZg dZde	ddf fdZ
dZd ed	      d
fd ed      dfd ed      dfg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d%d%d&Zg d'Z fd(Z xZS ))DeductionListViewz%
    list view for deduction tab
    )specific_employeesexclude_employees	is_pretaxis_fixedamountbased_onrater   r   Nc                    t        |   di | d| _        | j                  j                  j                  d      s%| j                  j                  j                  d      rd| _        nd | _        t        d      | _        y )Ndeduct-containerzpayroll.change_deductiondeduct_actionsr    r   )	r'   r(   view_idrequestuserhas_permaction_methodr   r)   r,   s     r   r(   zDeductionListView.__init__T   sk    "6")<<%%&
\\''(BC!1D!%D!"78r   a  
                {diff_cell}
                hx-get='{deduction_detail_view}?instance_ids={ordered_ids}'
                hx-target="#genericModalBody"
                data-target="#genericModal"
                data-toggle="oh-modal-toggle"
                pretax--dotPretax
            onclick="
                $('#applyFilter').closest('form').find('[name=is_pretax]').val('true');
                $('[name=is_fixed]').val('unknown').change();
                $('#applyFilter').click();
            "
            
fixed--dotFixed
            onclick="
                $('#applyFilter').closest('form').find('[name=is_fixed]').val('true');
                $('[name=is_pretax]').val('unknown').change();
                $('#applyFilter').click();

            "
            not-fixed--dot	Not Fixed
            onclick="
                $('#applyFilter').closest('form').find('[name=is_fixed]').val('false');
                $('[name=is_pretax]').val('unknown').change();
                $('#applyFilter').click();

            "
            r   titleSpecific Employeesspecific_employees_colExcluded Employeesexcluded_employees_colz	Is Pretaxget_is_pretax_displayzIs Condition Basedget_is_condition_based_display	Conditioncondition_bsed_colzIs Fixedget_is_fixed_displayAmountr@   zBased Onget_based_on_displayRaterB   zD
                  style="width:180px !important;
                  )rT   rX   ))r   rT   )rU   rV   )rW   rX   )r^   r@   c                 D    t         |          }|j                  d      S NT)only_show_under_employeer'   get_querysetexcluder-   querysetr.   s     r   re   zDeductionListView.get_queryset   s$    7')>>r   )r   r   r   r1   r   modelr   filter_classbulk_update_fieldsr   r(   	row_attrsr2   row_status_indicationscolumnsheader_attrssortby_mappingre   r8   r9   s   @r   r;   r;   @   s1    E"L	9 	9 	9I hK
	
 gJ	
 kN	
1$R 
;!	
	 ":;	
	 ":;	
;01	
	 "BC	
;-.	
:./	
8h	
:./	
6FG#	LN? ?r   r;   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 ed      dfd ed      dfd ed      dfgZdZ ed      dd ed      ddgZdZ xZS )DeductionCardViewz
    card view
    r   r   Nc                 2    t        |   di | d| _        y )NrD   r   )r'   r(   rF   r,   s     r   r(   zDeductionCardView.__init__   s    "6")r   c                 H    t         |          }|j                  d      }|S rb   rd   rg   s     r   re   zDeductionCardView.get_queryset   s(    7')##T#Br   
get_avatarz{title}zvAmount : <br> {amount_col} <br> Is Pretax : {get_is_pretax_display} <br> One Time deduction : {get_one_time_deduction})	image_srcrT   subtitlerK   rL   rM   rN   rO   rP   rQ   rR   rS   z
                hx-get='{deduction_detail_view}?instance_ids={ordered_ids}'
                data-toggle="oh-modal-toggle"
                data-target="#genericModal"
                hx-target="#genericModalBody"
                Editzr
            class="oh-dropdown__link"
            onclick="window.location.href='{get_update_url}' "
            )actionr%   Deletea  
                    onclick="event.stopPropagation()"
                    hx-get="{get_delete_url}?model=payroll.Deduction&pk={pk}"
                    data-toggle="oh-modal-toggle"
                    data-target="#deleteConfirmation"
                    hx-target="#deleteConfirmationBody"
                    class="oh-dropdown__link"
                    style="cursor: pointer;"

                    
   )r   r   r   r1   r   ri   r   rj   r   r(   re   detailsr2   card_status_indications
card_attrsactionsrecords_per_pager8   r9   s   @r   rr   rr      s     E"L* * * " MG hK
	
 gJ	
 kN	
1$LJ i	
 k		
G. r   rr   N)typingr   django.urlsr   django.utils.decoratorsr   django.utils.translationr   r2   horilla_views.cbv_methodsr   r   horilla_views.generic.cbv.viewsr	   r
   r   r   payroll.filtersr   payroll.models.modelsr   r   r   r;   rr   r   r   r   <module>r      s     4 6 I  , + .z2%+CD:V3L 3 W 33
 .z2%+CD:V"*> "* W 3"*J .z2%+CD:Vm? m? W 3m?` .z2%+CD:Vb b W 3br   