
    h
                        S SK r S SKJr  S SKJr  S SKJrJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJrJr  S S	KJr  S S
KJrJr  SSKJrJrJrJrJrJrJrJrJrJ r   S SK!J"r"  S SK#J$r$J%r%J&r&  S SKJ'r'  S SK#J(r(J)r)  S SKJ*r*   " S S\\	5      r+ " S S\\	5      r, " S S\\	5      r- " S S\\	5      r. " S S\\	5      r/ " S S\\	5      r0 " S S\\	5      r1 " S  S!\\	5      r2 " S" S#\\	5      r3 " S$ S%\\	5      r4 " S& S'\\	5      r5 " S( S)\\	5      r6g)*    N)IntegerField)JsonResponse)renderredirect)View)messages)LoginRequiredMixin)CoalesceCast)Program_Types)TeamVendors   )
Alloted_TargetsExpenditureIncomesHRExpenditureEquipmentExpenditureTravelExpenditureIECExpenditureAccommodationExpenditureMiscellaneousExpenditureOfficeExpenditure)States)SumFValue)Projects)
FloatFieldExpressionWrapper)Roundc                        \ rS rSrS rS rSrg)AddIncomeView   c                     [         R                  R                  5       n[        R                  R                  5       n[	        USX#S.5      $ )Nzadd-income.html)statesprogram_types)r   objectsallr   r   )selfrequestr&   r'   s       ./var/www/html/DEMO/finance_department/views.pygetAddIncomeView.get   s;    ##%%--113g0f2fgg    c           	      H
    [        5       nUR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul	        UR                  R                  S5      Ul
        UR                  R                  S	5      Ul        UR                  R                  S
5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        SUR0                  ;   a   UR0                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul         UR                  R                  S5      Ul!        UR                  R                  S5      Ul"        URG                  5         URH                  (       a  / nUR                  RK                  S 5      nUR                  RK                  S!5      n[M        U5       H+  u  pgURO                  [Q        URH                  XuU   S"95        M-     [S        U5      (       a  [P        RT                  RW                  U5        [X        RZ                  " US#5        []        S$5      $ [X        R^                  " US%5        []        S$5      $ ! [`         a  n[c        U5         S nAg S nAff = f)&Nincome_typedonation_typedonoremailmobile	aadhar_nopan_nosanction_amountreceived_amounthuman_resourcecamp_expensestraining_expensesequipment_expensestravel_expensesmaterial_expencesadministrative_expensesaccommodation_expensesmonitoring_expensesmiscellaneous_expensesno_of_installmentsmode_of_paymentproof_of_evidencepayment_dateprogram_typeproject
start_dateend_datestatedistrictaddressmessagetarget_namestarget_numbers	income_idtarget_nametarget_number$Team member registered successfully.IncomesViewz-Something went wrong. Please try again later.)2r   POSTr-   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   FILESrF   rG   program_type_id
project_idrJ   rK   state_iddistrict_idrN   rO   saveidgetlist	enumerateappendr   lenr(   bulk_creater   successr   error	Exceptionprint)	r*   r+   incometargetsrP   rQ   indexnamees	            r,   postAddIncomeView.post   s   3	YF!(!1!1-!@F#*<<#3#3O#DF "<<++G4FL"<<++G4FL#LL,,X6FM&||//<F$\\--h7FM%,\\%5%56G%HF"%,\\%5%56G%HF"$+LL$4$45E$FF!#*<<#3#3O#DF '.||'7'78K'LF$(/(8(89M(NF%%,\\%5%56G%HF"'.||'7'78K'LF$-4\\-=-=>W-XF*,3LL,<,<=U,VF))0)9)9:O)PF&,3LL,<,<=U,VF)(/(8(89M(NF%%,\\%5%56G%HF""gmm3+2==+<+<=P+Q("),,"2"2>"BF%,\\%5%5n%EF" ' 0 0 ;F ' 0 0 >F%ll..z:FO%ll..w7FO!(!1!1*!=F$\\--i8FN$\\--i8FNKKMyy&||33NC!(!5!56F!G#,\#:KENN'FIITrwcxy $; w<<#++77@  *PQ..w(WX.. 	!HH	s   ST  !T 
T!TT! N__name__
__module____qualname____firstlineno__r-   rn   __static_attributes__rp   r/   r,   r#   r#      s    h4r/   r#   c                        \ rS rSrS rS rSrg)EditIncomeViewS   c                 N    [         R                  R                  5       n[        R                  R                  5       n[        R                  R                  US9n[        USX4US.5      $ ! [        R                   a%    [        R                  " US5        [        S5      s $ f = f)Nr_   zedit-income.html)r&   r'   ri   :Income error Something went wrong. Please try again later.rW   )r   r(   r)   r   r   r-   r   DoesNotExistr   rf   r   )r*   r+   r_   r&   r'   ri   s         r,   r-   EditIncomeView.getU   s    	+^^'')F)11557M__((b(1F'#56w}7~## 	+NN7$`aM**	+s   A(A+ +6B$#B$c           	      
    [         R                  R                  US9nUR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul	        UR                  R                  S5      Ul
        UR                  R                  S	5      Ul        UR                  R                  S
5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        SUR2                  ;   a   UR2                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul         UR                  R                  S5      Ul!        UR                  R                  S5      Ul"        UR                  R                  S 5      Ul#        URI                  5         [J        R                  RM                  US!9RO                  5         / nUR                  RQ                  S"5      nUR                  RQ                  S#5      n[S        U5       H+  u  pxURU                  [K        URV                  XU   S$95        M-     [Y        U5      (       a  [J        R                  R[                  U5        [\        R^                  " US%5        [a        S&5      $ ! [         Rb                   a%    [\        Rd                  " US'5        [a        S&5      s $ f = f)(Nr{   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   )rS   rP   rQ   rR   rV   rW   r|   )3r   r(   r-   rX   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rY   rF   rG   rZ   r[   rJ   rK   r\   r]   rN   rO   r^   r   filterdeleter`   ra   rb   r_   rc   rd   r   re   r   r}   rf   )	r*   r+   r_   ri   rj   rP   rQ   rk   rl   s	            r,   rn   EditIncomeView.post`   s   1	+__((b(1F!(!1!1-!@F#*<<#3#3O#DF "<<++G4FL"<<++G4FL#LL,,X6FM&||//<F$\\--h7FM%,\\%5%56G%HF"%,\\%5%56G%HF"$+LL$4$45E$FF!#*<<#3#3O#DF '.||'7'78K'LF$(/(8(89M(NF%%,\\%5%56G%HF"'.||'7'78K'LF$-4\\-=-=>W-XF*,3LL,<,<=U,VF))0)9)9:O)PF&,3LL,<,<=U,VF)(/(8(89M(NF%%,\\%5%56G%HF""gmm3+2==+<+<=P+Q("),,"2"2>"BF%,\\%5%5n%EF" ' 0 0 ;F ' 0 0 >F%ll..z:FO%ll..w7FO!(!1!1*!=F$\\--i8FN$\\--i8FNKKM##**r*:AACG"<<//?L$\\112BCN(6#		ns_tu  7 7||''33G<W&LMM**## 	+NN7$`aM**	+s   T
T 6UUrp   Nrq   rp   r/   r,   rx   rx   S   s    +2+r/   rx   c                       \ rS rSrS rSrg)rW      c           
         [         R                  R                  5       n[        R                  R                  5       nSUR                  ;   a?  UR                  S   S:w  a,  UR                  S   nUR                  UR                  S   S9nOSnSUR                  ;   a?  UR                  S   S:w  a,  UR                  S   nUR                  UR                  S   S9nOSnSUR                  ;   a?  UR                  S   S:w  a,  UR                  S   nUR                  UR                  S   S9nOSn[        USX2XFUS	.5      $ )
Nr1   All)r1   r2   )r2   rH   )rZ   zincomes.html)incomesr'   r1   rH   r2   )r   r(   r)   r   GETr   r   )r*   r+   r'   r   r1   r2   rH   s          r,   r-   IncomesView.get   s-   %--113//%%'GKK'GKK,F%,O!++m4Knn7;;}3MnNGK gkk)gkk/.Je.S#KK8MnnW[[5QnRG!M W[[(W[[-HE-Q";;~6Lnnw{{>7RnSG Lg~G  wB  uB  0C  D  	Dr/   rp   Nrr   rs   rt   ru   r-   rv   rp   r/   r,   rW   rW      s    Dr/   rW   c                       \ rS rSrS rSrg)IncomeChartView   c                     [         R                  R                  S5      R                  [	        S5      S9R                  S5      nU Vs/ s H  nUS   =(       d    SUS   S.PM     nn[        SU0SS	9$ s  snf )
Nr1   r9   )total_incomeUnknownr   rl   yincome_resultFsafe)r   r(   valuesannotater   order_byr   )r*   r+   income_countsitemr   s        r,   r-   IncomeChartView.get   s     OOVM"X3'8#9X:Xm$	 	 &
% -(5ID<PQ% 	 

 ]
 	
s   	A5rp   Nr   rp   r/   r,   r   r      s    r/   r   c                       \ rS rSrS rSrg)
IncomeView   c                      [         R                  R                  US9n[        USSU05      $ ! [         R                   a    [        S5      s $ f = f)Nr{   zincome.htmlri   r   )r   r(   r-   r   r}   r   r*   r+   r_   ri   s       r,   r-   IncomeView.get   sR    	*__((b(1F'=8f2EFF## 	*L))	*   +. AArp   Nr   rp   r/   r,   r   r      s    *r/   r   c                        \ rS rSrS rS rSrg)AddExpenditureView   c                     [         R                  R                  5       n[        R                  R                  5       n[        R                  R                  5       n[        USX#US.5      $ )Nzadd-expenditure.html)projectsteam_membersvendors)r   r(   r)   r   r   r   )r*   r+   r   r   r   s        r,   r-   AddExpenditureView.get   s]    ##'')||'')//%%'g5X  {B  8C  D  	Dr/   c                    [        5       nUR                  R                  S5      nX2l        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul	        UR                  R                  S5      (       a   UR                  R                  S5      Ul        UR                  R                  S	5      (       a   UR                  R                  S	5      Ul        UR                  R                  S
5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR)                  5         UR*                  (       Ga  [-        5       nUR*                  Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      (       a  UR                  R                  S5      OSUl        UR                  R                  S5      Ul        UR)                  5         [=        5       nUR*                  Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul         UR                  R                  S5      Ul!        UR                  R                  S5      Ul"        UR                  R                  S5      Ul#        UR                  R                  S5      Ul$        UR)                  5         [K        5       nUR*                  Ul        UR                  R                  S5      Ul&        UR                  R                  S5      Ul'        UR                  R                  S 5      Ul(        UR                  R                  S!5      Ul)        UR                  R                  S"5      Ul*        UR                  R                  S#5      Ul+        UR)                  5         / nUR                  RY                  S$5      nUR                  RY                  S%5      n	UR                  RY                  S&5      n
UR                  RY                  S'5      nUR                  RY                  S(5      nUR                  RY                  S)5      nUR                  RY                  S*5      nUR                  RY                  S+5      n[[        U5       HE  u  nnUR]                  [_        UR*                  UU	U   U
U   UU   UU   UU   UU   UU   S,9	5        MG     [a        U5      (       a  [^        Rb                  Re                  U5        [g        5       nUR*                  Ul        UR                  R                  S-5      Ul4        UR                  R                  S.5      Ul5        UR                  R                  S/5      Ul6        UR                  R                  S05      Ul7        UR                  R                  S15      Ul8        UR                  R                  S25      Ul9        UR                  R                  S35      Ul:        UR                  R                  S45      Ul;        UR                  R                  S55      Ul<        UR)                  5         [{        5       nUR*                  Ul        UR                  R                  S65      Ul>        UR                  R                  S75      Ul?        UR                  R                  S85      Ul@        UR                  R                  S95      UlA        UR                  R                  S:5      UlB        UR                  R                  S;5      UlC        UR                  R                  S<5      UlD        UR                  R                  S=5      UlE        UR)                  5         [        5       nUR*                  Ul        UR                  R                  S>5      UlG        UR                  R                  S?5      UlH        UR                  R                  S@5      UlI        UR                  R                  SA5      UlJ        UR                  R                  SB5      UlK        UR                  R                  SC5      UlL        UR                  R                  SD5      UlM        UR                  R                  SE5      UlN        UR)                  5         [        R                  " USF5        [        SG5      $ )HNexpence_datesector_of_expencerI   administrative_expensepayment_typepayment_statusassetsother_invoiceother_payment_proofadvancedescriptionother_payment_modemember_or_vendorteamvendorr7   r:   hr_expence_date	hr_amount
hr_sectionhr_tds_deductionr   hr_tds_deduction_dateequipment_expence_dateequipment_amountequipment_sectionequipment_supplier_nameequipment_tds_deductionequipment_tds_deduction_dateoffice_expence_dateoffice_expence_amountoffice_expence_sectionoffice_expence_supplier_nameoffice_expence_tds_deduction!office_expence_tds_deduction_datetravel_expence_date	departurearrivalmode_of_traveltravel_amounttravel_sectiontravel_tds_deductiontravel_tds_deduction_date	expenditure_idr   r   r   r   r   r   r   r   iec_expence_dater   quantityrate
iec_amountiec_sectioniec_remarksiec_tds_deductioniec_tds_deduction_dateaccommodation_expence_dateaccommodation_check_inaccommodation_check_out
no_of_daysaccommodation_amountaccommodation_sectionaccommodation_tds_deduction accommodation_tds_deduction_datemiscellaneous_expence_datemiscellaneous_othermiscellaneous_remarksmiscellaneous_amountmiscellaneous_sectionmiscellaneous_tds_deduction miscellaneous_tds_deduction_datemiscellaneous_descriptionzExpenditure added successfully.ExpendituresView)Rr   rX   r-   r   r   r[   r   r   r   r   rY   r   r   r   r   r   r   	member_id	vendor_idr7   r^   r_   r   r   r:   r   r   r   r   r   r   r   r   r   r   r   r   r   r   office_amountoffice_sectionoffice_supplier_nameoffice_tds_deductionoffice_tds_deduction_dater`   ra   rb   r   rc   r(   rd   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   re   r   )r*   r+   expenditurer   hr	equipmentofficetravel_expencesexpence_dates
departuresarrivalsmode_of_travelstravel_amountstravel_sectionstds_deductionstds_deduction_datesrk   travel_dateiecaccomodationmiscellaneouss                        r,   rn   AddExpenditureView.post   s   !m||''7#/ (/(8(89L(M%!(!1!1)!<-4\\-=-=>V-W*#*<<#3#3N#C %,\\%5%56F%G"$\\--h7==_--(/(9(9/(JK%==233.5mm.?.?@U.VK+%ll..y9"),,"2"2="A)0)9)9:N)O&'.||'7'78J'K$ ' 0 0 8 ' 0 0 :$\\--h7>>>B +B ' 0 01A BB!(!1!12C!DB"<<++K8BL#LL,,\:BMJQ,,JZJZ[mJnJn',,"2"23E"FtuB'.||'7'78O'PB$GGI,.I'2~~I$/6||/?/?@X/YI,)0)9)9:L)MI&*1,,*:*:;N*OI'070@0@AZ0[I-070@0@AZ0[I-5<\\5E5EFd5eI2NN&(F$/NNF!)0)9)9:O)PF&#*<<#3#34K#LF $+LL$4$45M$NF!*1,,*:*:;Y*ZF'*1,,*:*:;Y*ZF'/6||/?/?@c/dF,KKM O#LL001FGM --k:J||++I6H%ll223CDO$\\11/BN%ll223CDO$\\112HIN"),,"6"67R"S&/&>"{&&%)4.9$.u$5"*5/)8)?(6u(=)8)?/=e/D4G4N
 '? ?##!))55oF !"C!,C#*<<#3#34F#GC ||''/CH"<<++J7CL||''/CH$\\--l;CN%ll..}=CO%ll..}=CO$+LL$4$45H$IC!)0)9)9:R)SC&HHJ35L*5..L'6=ll6F6FGc6dL329,,2B2BC[2\L/3:<<3C3CD]3^L0&-ll&6&6|&DL#070@0@AW0XL-181A1ABY1ZL.7>||7G7GHe7fL4<CLL<L<LMo<pL946M+6>>M(7>||7G7GHd7eM4070@0@AV0WM-29,,2B2BCZ2[M/181A1ABX1YM.29,,2B2BCZ2[M/8?8H8HIf8gM5=D\\=M=MNp=qM:6=ll6F6FGb6cM3 "CD*++r/   rp   Nrq   rp   r/   r,   r   r      s    Dx,r/   r   c                       \ rS rSrS rSrg)r   iT  c                    [         R                  R                  5       n[        R                  R	                  [        [        [        S[        5       5      5      [        S5      [        5       S9[        [        [        S[        5       5      [        S[        5       5      -  S-  5      [        S5      [        5       S9S9R	                  [        [        [        [        S5      [        5       5      [        S5      [        5       S9[        [        [        S5      [        5       5      [        S5      [        5       S9-   [        [        [        S[        5       5      5      [        S5      [        5       S9-   [        [        [        S	5      [        5       5      [        S5      [        5       S9-   [        [        [        S
5      [        5       5      [        S5      [        5       S9-   [        [        [        S5      [        5       5      [        S5      [        5       S9-   [        [        [        S5      [        5       5      [        S5      [        5       S9-   [        5       S9[        [        [        [        S5      [        5       5      [        S5      [        5       S9[        [        [        S5      [        5       5      [        S5      [        5       S9-  S-  [        [        [        S5      [        5       5      [        S5      [        5       S9[        [        [        S5      [        5       5      [        S5      [        5       S9-  S-  -   [        S5      -   [        [        [        S	5      [        5       5      [        S5      [        5       S9[        [        [        S5      [        5       5      [        S5      [        5       S9-  S-  -   [        [        [        S
5      [        5       5      [        S5      [        5       S9[        [        [        S5      [        5       5      [        S5      [        5       S9-  S-  -   [        [        [        S5      [        5       5      [        S5      [        5       S9[        [        [        S5      [        5       5      [        S5      [        5       S9-  S-  -   [        [        [        S5      [        5       5      [        S5      [        5       S9[        [        [        S5      [        5       5      [        S5      [        5       S9-  S-  -   [        5       S9S9R	                  [        [        S5      [        S5      -
  [        S5      -
  [        5       S9S9nSUR                  ;   a?  UR                  S   S:w  a,  UR                  S   nUR                  UR                  S   S9nOSnSUR                  ;   a?  UR                  S   S:w  a,  UR                  S   nUR                  UR                  S   S9nOSnSUR                  ;   a?  UR                  S   S:w  a,  UR                  S   nUR                  UR                  S   S9nOSn[        US X4XVUS!.5      $ )"Ntravel__travel_amountg        )output_fieldtravel__travel_tds_deductiong      Y@)travel_total_amounttravel_total_tdshr__hr_amountequipment__equipment_amountiec__iec_amount#accommodation__accommodation_amount#miscellaneous__miscellaneous_amountoffice__office_amounthr__hr_tds_deduction"equipment__equipment_tds_deductionr  iec__iec_tds_deduction*accommodation__accommodation_tds_deduction*miscellaneous__miscellaneous_tds_deductionoffice__office_tds_deduction)total_amount	total_tdsr  r   r  )
net_amountr   r   )r   r   )r   rI   )r[   zexpenditures.html)expendituresr   r   rI   r   )r   r(   r)   r   r   r
   r   r   r   r   r    r   r   r   r   )r*   r+   r   r  r   r   rI   s          r,   r-   ExpendituresView.getV  s   ##'')"**33 (T2I:<-X)Y[`ad[et~  uA  !B%c,jl;3Z\BCEJK' Sz
6 4 
 (*a0*,?sZdZfga =>
MuUXzhrhtuvT"9:<HI5QT:dndpqr a 12JLA5:\f\hij a EF
UW\]`Wapzp|}	~
 a EF
UW\]`Wapzp|}~ a 78*,Gsblbnop (\	 ($q1:<@%*[e[gha 67Fc
akamnoqvw $q!>?NPUVYPZisiuva DEz|TV[\_V`oyo{|} @EEF $%& $q!23Z\BE#J]g]ija 89:<H%PS*cmcopqsxy	z $q!FGVX]^aXbq{q}~a LMz|\^cdg^h  xB  xD  EE HMMN $q!FGVX]^aXbq{q}~a LMz|\^cdg^h  xB  xD  EE HMMN" $q!89:<H%PS*cmcopa >?NPUVYPZisiuvwy~#@& (\)  !
B ((.!AiL01[>A'\  
O 	\ '++-'++>Q2RV[2[ ',? @'..7;;ObCc.dL %#w{{2w{{C[7\`e7e%,[[1I%J"'..TlHm.nL%*"#I(>%(Gkk),G'..GKK	<R.SLGg2l  Yo  S[  5\  ]  	]r/   rp   Nr   rp   r/   r,   r   r   T  s	    B]r/   r   c                       \ rS rSrS rSrg)ExpenditureChartViewi  c           	      \	   [         R                  R                  5       n[        R                  R                  5       n[        R                  R                  5       n[
        R                  R                  5       n[        R                  R                  5       n[        R                  R                  5       n[        R                  R                  5       nSUR                  ;   a  UR                  S   S:w  a  UR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nSUR                  ;   a  UR                  S   S:w  a  UR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nSUR                  ;   a  UR                  S   S:w  a  UR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  UR                  S   S9nUR                  [        S5      S	9S   =(       d    S
nUR                  [        S5      S9S   =(       d    S
nUR                  [        S5      S9S   =(       d    S
nUR                  [        S5      S9S   =(       d    S
nUR                  [        S5      S9S   =(       d    S
nUR                  [        S5      S9S   =(       d    S
nUR                  [        S5      S9S   =(       d    S
nSUS.SUS.SUS.SUS.SUS.SUS.SUS./n	[        SU	0S S!9$ )"Nr   r   )expenditure__sector_of_expencer   )#expenditure__administrative_expenserI   )expenditure__project_idr   )r   r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r   z	HR Amountr   zEquipment AmountzTravel Amountz
IEC AmountzAccomodation AmountzMiscellaneous AmountzOffice AmountamountsFr   )r   r(   r)   r   r   r   r   r   r   r   r   	aggregater   r   )
r*   r+   r   r   r   r   r   r   r   r%  s
             r,   r-   ExpenditureChartView.get  s#    "))--/	/77;;=)11557#++//1
7??CCE7??CCE)11557'++-'++>Q2RV[2[!(('++ViJj(kI/66X_XcXcdwXx6y*11SZS^S^_rSs1tM#**GKKXkLl*mJ#7#>#>`g`k`kl  aA#>  $B #7#>#>`g`k`kl  aA#>  $B )00RYR]R]^qRr0sM#w{{2w{{C[7\`e7e!((w{{[sOt(uI/66]d]h]h  jB  ^C6   D*11X_XcXcd|X}1~M#**QXQ\Q\]uQv*wJ#7#>#>elepep  rJ  fK#>  $L #7#>#>elepep  rJ  fK#>  $L )00W^WbWbc{W|0}M#I(>%(G!((7;;yCY(ZI/66QXQ\Q\]fQg6h*11GKKXaLb1cM#**W[[QZE[*\J#7#>#>Y`YdYdenYo#>#p #7#>#>Y`YdYdenYo#>#p )007;;W`Ka0bM''C4D'EkRWVW	+55M_I`5abtuzyz%//O@T/UVefkjk))s<7H)I,W\[\
3==UXYoUp=q  sI   J   O  NO3==UXYoUp=q  sI   J   O  NO%//O@T/UVefkjk "	2(0@A%];"*5+3GH,4HI%];
 Y0u==r/   rp   Nr   rp   r/   r,   r   r     s    8>r/   r   c                        \ rS rSrS rS rSrg)EditExpenditureViewi  c           	         [         R                  R                  5       n[        R                  R	                  US9n[
        R                  R                  5       n[        R                  R                  5       n[        USX4XVS.5      $ )Nr{   zedit-expenditure.html)r   r   r   r   )r   r(   r)   r   r-   r   r   r   )r*   r+   r_   r   r   r   r   s          r,   r-   EditExpenditureView.get  sv    ##'')!))--2-6||'')//%%'g6h  K  9a  b  	br/   c                     [         R                  R                  US9nUR                  R                  S5      nXCl        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul	        UR                  R                  S5      Ul
        UR                  R                  S	5      Ul        UR                  R                  S
5      (       a   UR                  R                  S
5      Ul        UR                  R                  S5      (       a   UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR+                  5         [,        R                  R                  US9nUR.                  Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      Ul        UR                  R                  S5      (       a  UR                  R                  S5      OSUl        UR                  R                  S5      Ul        UR+                  5         [>        R                  R                  US9nUR.                  Ul        UR                  R                  S5      Ul         UR                  R                  S5      Ul!        UR                  R                  S5      Ul"        UR                  R                  S5      Ul#        UR                  R                  S5      Ul$        UR                  R                  S5      Ul%        UR+                  5         [L        R                  R                  US9nUR.                  Ul        UR                  R                  S 5      Ul'        UR                  R                  S!5      Ul(        UR                  R                  S"5      Ul)        UR                  R                  S#5      Ul*        UR                  R                  S$5      Ul+        UR                  R                  S%5      Ul,        UR+                  5         [Z        R                  R]                  US9R_                  5         / nUR                  Ra                  S&5      n	UR                  Ra                  S'5      n
UR                  Ra                  S(5      nUR                  Ra                  S)5      nUR                  Ra                  S*5      nUR                  Ra                  S+5      nUR                  Ra                  S,5      nUR                  Ra                  S-5      n[c        U	5       HE  u  nnURe                  [[        UR.                  UU
U   UU   UU   UU   UU   UU   UU   S.9	5        MG     [g        U5      (       a  [Z        R                  Ri                  U5        [j        R                  R                  US9nUR.                  Ul        UR                  R                  S/5      Ul6        UR                  R                  S05      Ul7        UR                  R                  S15      Ul8        UR                  R                  S25      Ul9        UR                  R                  S35      Ul:        UR                  R                  S45      Ul;        UR                  R                  S55      Ul<        UR                  R                  S65      Ul=        UR                  R                  S75      Ul>        UR+                  5         [~        R                  R                  US9nUR.                  Ul        UR                  R                  S85      Ul@        UR                  R                  S95      UlA        UR                  R                  S:5      UlB        UR                  R                  S;5      UlC        UR                  R                  S<5      UlD        UR                  R                  S=5      UlE        UR                  R                  S>5      UlF        UR                  R                  S?5      UlG        UR+                  5         [        R                  R                  US9nUR.                  Ul        UR                  R                  S@5      UlI        UR                  R                  SA5      UlJ        UR                  R                  SB5      UlK        UR                  R                  SC5      UlL        UR                  R                  SD5      UlM        UR                  R                  SE5      UlN        UR                  R                  SF5      UlO        UR                  R                  SG5      UlP        UR+                  5         [        R                  " USH5        [        SI5      $ ! [         R                   a%    [        R                  " USJ5        [        SI5      s $ f = f)KNr{   r   r   rI   r   r   r   r   r   r   r   r   r   r   r   r   r7   )r   r:   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   z!Expenditure updated successfully.r   Expenditure doesn't exists.)Ur   r(   r-   rX   r   r   r[   r   r   r   r   r   rY   r   r   r   r   r   r   r   r7   r^   r   r_   r   r:   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r`   ra   rb   rc   rd   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   re   r   r}   )r*   r+   r_   r   r   r   r   r   r   r   r   r   r   r   r   r   r  rk   r  r  r  r  s                         r,   rn   EditExpenditureView.post  s   {	0%--11r1:K"<<++N;L'3$,3LL,<,<=P,QK)%,\\%5%5i%@K"181A1ABZ1[K.'.||'7'7'GK$)0)9)9:J)KK&!(!1!1(!;K-4\\-=-=>R-SK*}}  11,3MM,=,=o,N)}}  !67729--2C2CDY2Z/"),,"2"29"=K&-ll&6&6}&EK#+2<<+;+;<N+OK($+LL$4$4V$<K!$+LL$4$4X$>K!!(!1!1(!;K&&**B*?B +B ' 0 01A BB!(!1!12C!DB"<<++K8BL#LL,,\:BMJQ,,JZJZ[mJnJn',,"2"23E"FtuB'.||'7'78O'PB$GGI,4488"8MI'2~~I$/6||/?/?@X/YI,)0)9)9:L)MI&*1,,*:*:;N*OI'070@0@AZ0[I-070@0@AZ0[I-5<\\5E5EFd5eI2NN&..22B2GF$/NNF!)0)9)9:O)PF&#*<<#3#34K#LF $+LL$4$45M$NF!*1,,*:*:;Y*ZF'*1,,*:*:;Y*ZF'/6||/?/?@c/dF,KKM %%,,b,AHHJ O#LL001FGM --k:J||++I6H%ll223CDO$\\11/BN%ll223CDO$\\112HIN"),,"6"67R"S&/&>"{&&%)4.9$.u$5"*5/)8)?(6u(=)8)?/=e/D4G4N
 '? ?##!))55oF ((,,b,AC!,C#*<<#3#34F#GC ||''/CH"<<++J7CL||''/CH$\\--l;CN%ll..}=CO%ll..}=CO$+LL$4$45H$IC!)0)9)9:R)SC&HHJ3;;??QS?TL*5..L'6=ll6F6FGc6dL329,,2B2BC[2\L/3:<<3C3CD]3^L0&-ll&6&6|&DL#070@0@AW0XL-181A1ABY1ZL.7>||7G7GHe7fL4<CLL<L<LMo<pL94<<@@RT@UM+6>>M(7>||7G7GHd7eM4070@0@AV0WM-29,,2B2BCZ2[M/181A1ABX1YM.29,,2B2BCZ2[M/8?8H8HIf8gM5=D\\=M=MNp=qM:6=ll6F6FGb6cM3 W&IJ.//'' 	0W&CD.//	0s   ll 6m	m	rp   Nrq   rp   r/   r,   r)  r)    s    b|0r/   r)  c                       \ rS rSrS rSrg)DeleteExpenditureViewia  c                     [         R                  R                  US9nUR                  5         [        R
                  " US5        [        S5      $ ! [         R                   a%    [        R                  " US5        [        S5      s $ f = f)Nr{   z!Expenditure deleted successfully.r   r-  )	r   r(   r-   r   r   re   r   r}   rf   r*   r+   r_   r   s       r,   r-   DeleteExpenditureView.getc  sy    	0%--11r1:K W&IJ.//'' 	0NN7$AB.//	0   AA 6B
	B
rp   Nr   rp   r/   r,   r0  r0  a  s    0r/   r0  c                       \ rS rSrS rSrg)ExpenditureViewio  c                      [         R                  R                  US9n[        USSU05      $ ! [         R                   a    [        S5      s $ f = f)Nr{   zexpenditure.htmlr   r   )r   r(   r-   r   r}   r   r2  s       r,   r-   ExpenditureView.getp  sV    	0%--11r1:K'#57TUU'' 	0.//	0r   rp   Nr   rp   r/   r,   r6  r6  o  s    0r/   r6  c                       \ rS rSrS rSrg)DeleteIncomeViewix  c                     [         R                  R                  US9nUR                  5         [        R
                  " US5        [        S5      $ ! [         R                   a%    [        R                  " US5        [        S5      s $ f = f)Nr{   zIncome deleted successfully.rW   zIncome doesn't exists.)	r   r(   r-   r   r   re   r   r}   rf   r   s       r,   r-   DeleteIncomeView.getz  sr    	+__((b(1FMMOW&DEM**## 	+NN7$<=M**	+r4  rp   Nr   rp   r/   r,   r:  r:  x  s    +r/   r:  )7randomdjango.formsr   django.httpr   django.shortcutsr   r   django.viewsr   django.contribr   django.contrib.auth.mixinsr	   django.db.models.functionsr
   r   program_department.modelsr   hr_department.modelsr   r   modelsr   r   r   r   r   r   r   r   r   r   country.modelsr   django.db.modelsr   r   r   r   r   r    r!   r#   rx   rW   r   r   r   r   r   r)  r0  r6  r:  rp   r/   r,   <module>rJ     s    % $ -  # 9 5 3 . I  I  I ! * * . : ,<& <~?+' ?+DD$d D:($ **#T *A,+T A,HD])4 D]N:>-t :>zF0,d F0R
0. 
00($ 0
+)4 
+r/   