
     bd#                         d dl m Z d dlmZmZmZmZ d dlmZm	Z	 d dl
mZ d dlmZ d dlT d dlZ e            Zd Ze                    d	           ed
          fdedefd            ZdS )    )datetime)	APIRouterRequestBodystatus)DictList)jsonable_encoder)JSONResponse)*Nc                 z   |dk    rg d}d}|                      |          }|j        dk    rg }|D ]!}g |}|                    |d                    "g }d                    dt	          |          z            }d|z  }|                      ||          }i }|D ]@}|d         |v r"||d                  |d         gz   ||d         <   .|d         g||d         <   A|S g S |d	k    rg d
}d}|                      |          }|j        dk    rg }|D ]!}g |}|                    |d                    "g }	d                    dt	          |          z            }d|z  }|                      ||          }i }	|D ]@}|d         |	v r"|	|d                  |d         gz   |	|d         <   .|d         g|	|d         <   A|	S g S d S )NGRNgrn_nopo_novender_namegrn_date
invoice_no	po_statusa  select COUNT(GRL.PurchaseOrderListId) as cnt, GRL.PurchaseOrderListId from Vaaak.GrnList AS GRL JOIN PurchaseOrderList as POL ON POL.PurchaseOrderListId = GRL.PurchaseOrderListId and POL.POStatus = 0Group By GRL.PurchaseOrderListId having COUNT(GRL.PurchaseOrderListId) = 1r      ,?l  select distinct GRL.GrnId,GRL.PurchaseOrderListId,VEN.VendorName,GRL.LastUpdate,GRI.InvoiceNumber,POL.POStatus from Vaaak.GrnList as GRL JOIN Vaaak.GrnItem as GRI on GRI.GrnId = GRL.GrnId JOIN PurchaseOrderList as POL ON POL.PurchaseOrderListId = GRL.PurchaseOrderListId JOIN Vaaak.Vendor as VEN on VEN.VendorId = POL.VendorId where GRL.PurchaseOrderListId in (%s)RNrn_nor   r   rn_dater   r     select COUNT(GRL.PurchaseOrderListId) as cnt, GRL.PurchaseOrderListId from Vaaak.GrnList AS GRL JOIN PurchaseOrderList as POL ON POL.PurchaseOrderListId = GRL.PurchaseOrderListId where POL.POStatus = 1 Group By GRL.PurchaseOrderListId having COUNT(GRL.PurchaseOrderListId) = 1 union select COUNT(GRL.PurchaseOrderListId) as cnt, GRL.PurchaseOrderListId from Vaaak.GrnList AS GRL JOIN PurchaseOrderList as POL ON POL.PurchaseOrderListId = GRL.PurchaseOrderListId Group By GRL.PurchaseOrderListId having COUNT(GRL.PurchaseOrderListId) > 1)executerowcountappendjoinlen)

sql_objecttypecolumns	statementrowspo_listrowgrn_listplaceholdersrn_lists
             #D:\Sites\api_v1\routes\dashboard.pygrn_rnr/      s[   u}}[[[a	 !!),,=AG ' 'fs1v&&&&H88C#g,,$677Lx {GGI
 %%i99DH 0 0q6X%%'/A'73q6('BHSV$$(+AxHSV$$OIt||YYYa	 !!),,=AG ' 'fs1v&&&&G88C#g,,$677Lx {GGI
 %%i99DG / /q6W$$&-c!foQ&@GCFOO'*1vhGCFOON IQ |    z/dash_po.requestfilterc           	      4  K   t          |          }| j        j                                        }g }|d         dk    rg d}d}d|v r(|d         dv r|d                    |d                   z   }|                    |          }|D ]l}g |}t                              |d                                       d	          |d<   |                    t          t          ||                               mt          |d
          }t          |d          }	|D ]D}
|
d         |v r||
d                  |
d<   nd |
d<   |
d         |	v r|	|
d                  |
d<   ?d |
d<   E|S |d         dk    rg d}d}|                    |          }|j        dk    rg }|D ]!}g |}|                    |d                    "g }	d                    dt          |          z            }d|z  }|                    ||          }|D ]l}g |}t                              |d                                       d	          |d<   |	                    t          t          ||                               mt          |	           |	S g S |d         d
k    rg d}d}|                    |          }|j        dk    rg }|D ]!}g |}|                    |d                    "g }d                    dt          |          z            }d|z  }|                    ||          }|D ]l}g |}t                              |d                                       d	          |d<   |                    t          t          ||                               mt          |           |S g S d S )Nc1PO)	po_numberr   po_dater   zselect POL.PurchaseOrderListId,VEN.VendorName,POL.CreatedDate, POL.POStatus from PurchaseOrderList as POL JOIN Vaaak.Vendor as VEN on VEN.VendorId = POL.VendorId where 1=1c2)10z-1z and POStatus = {}   z
DD/MM/YYYYr   r   r6   rn_nosgrn_nosr   a  select COUNT(GRL.PurchaseOrderListId) as cnt, GRL.PurchaseOrderListId from Vaaak.GrnList AS GRL JOIN PurchaseOrderList as POL ON POL.PurchaseOrderListId = GRL.PurchaseOrderListId and POL.POStatus = 0 Group By GRL.PurchaseOrderListId having COUNT(GRL.PurchaseOrderListId) = 1r   r   r   r   r      r   r   )r
   appmssqlcursorformatr   arrowgetr!   dictzipr/   r    r"   r#   json_serializer)r1   r2   rA   filter_itemsr&   r'   r(   r*   r-   r+   itrr)   r,   s                r.   dash_porJ   \   s     f%%F[%%''FLd|tFFFX	 6>>d|///%(<(C(CF4L(Q(QQ	~~i(( 	9 	9CC&CYYs1v&&--l;;CFS#%6%6 7 78888%%&''   		& 		&C;7** 'K(8 9H $H;8++!)#k*:!;I!%Id|u[[[b	 ~~i((=AG ' 'fs1v&&&&H88C#g,,$677Lx {GGI
 >>)W55D 9 9f3q6**11,??AS#%6%6 7 78888H%%%OId|tYYYa	 ~~i((=AG ' 'fs1v&&&&G88C#g,,$677Lx {GGI
 >>)W55D 8 8f3q6**11,??AtC$5$5667777G$$$NIM r0   )r   dtfastapir   r   r   r   typingr   r	   fastapi.encodersr
   fastapi.responsesr   
lib.commonpydashrouterr/   postrJ    r0   r.   <module>rU      s   # # # # # # 4 4 4 4 4 4 4 4 4 4 4 4         - - - - - - * * * * * *     	N N Nb Z37499 u u7 uD u u u u u ur0   