
    kh                        d dl mZ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mZmZmZ d dlmZ d dlmZ d dl
mZ  ed	d
g      Zej-                  d       ee       ee      fdededefd       Zej-                  d       ee      fdedefd       Zej-                  d       ee      fdedefd       Zej-                  d       ee      fdedefd       Zej-                  d       ee       ee      fdededefd       Zej7                  d       ee      fdededefd       Zej-                  d       ee      fd edefd!       ZejA                  d"       ee      fd#edefd$       Z ej7                  d%       ee      fd#edefd&       Z!ej-                  d'       ee      fd(edefd)       Zej7                  d*       ee       ee      fded+efd,       Z"y-).    )	APIRouterDepends)get_dbget_db2)Session)CollectionClass)StoreCollectionCollectionListCollectionSearchManualStoreCollectionUpdateCollection)WhatsappClass)get_current_active_user)	UserLoginz/collectionsCollections)prefixtags/
collectionsession_userdbc                     t        |      j                  |j                  |j                  | j                  | j
                  | j                  | j                        }d|iS Nmessager   get_allrol_idrutbranch_office_id
cashier_id
added_datepage)r   r   r   datas       K/var/www/intrajisbackend.com/public_html/app/backend/routers/collections.pyindexr%      sv    2&&|':':L<L<LjNiNiku  lA  lA  CM  CX  CX  Zd  Zi  Zi  jDt    z/detailc                     t        |      j                  | j                  | j                  | j                  | j
                        }d|iS r   r   get_all_with_detailr   r    r!   r"   r   r   r#   s      r$   detailr+      R    222:3N3NPZPePegqg|g|  I  N  N  ODtr&   z/detail/searchc                     t        |      j                  | j                  | j                  | j                  | j
                        }d|iS r   r(   r*   s      r$   r+   r+      r,   r&   z/storestore_collectionc                 ^    | j                         }t        |      j                  |      }d|iS r   )dictr   store)r.   r   collection_inputsr#   s       r$   r1   r1   !   s2    (--/2$$%67Dtr&   z/searchr2   c                     t        |      j                  |j                  |j                  | j                  | j
                  | j                  | j                        }d|iS r   r   )r2   r   r   r#   s       r$   searchr4   )   s{    2&&|':':L<L<LN_NpNp  sD  sO  sO  Qb  Qm  Qm  o@  oE  oE  FDtr&   z6/total_collection/{branch_office_id}/{collection_date}r   collection_datec                 @    t        |      j                  | |      }d|iS r   )r   total_collection)r   r5   r   r#   s       r$   r7   r7   /   s%    2//0@/RDtr&   z/manual_storemanual_store_collectionc                 ^    | j                         }t        |      j                  |      }d|iS r   )r0   r   manual_store)r8   r   r2   r#   s       r$   r:   r:   5   s2    /4462++,=>Dtr&   z/delete/{id}idc                 >    t        |      j                  |        ddiS )Nr   success)r   delete)r;   r   s     r$   r>   r>   <   s     Br"y!!r&   z
/edit/{id}c                 >    t        |      j                  |       }d|iS r   )r   get)r;   r   r#   s      r$   editrA   B   s"    2""2&Dtr&   z/updateupdate_collectionc                 >    t        |      j                  |       }d|iS r   )r   update)rB   r   r#   s      r$   postrE   H   s#    2%%&78Dtr&   z/crondb2c                 p    t        |      j                         }t        |       j                  |       ddiS )Nr   z6Updated o inserted collections in the second database.)r   get_all_collectionsupdate_all_collections)r   rF   r#   s      r$   cronrJ   N   s4    3335DB..t4OPPr&   N)#fastapir   r   app.backend.db.databaser   r   sqlalchemy.ormr   $app.backend.classes.collection_classr   app.backend.schemasr	   r
   r   r   r   "app.backend.classes.whatsapp_classr   app.backend.auth.auth_userr   r   collectionsrE   r%   r+   r1   r4   r@   intstrr7   r:   r>   rA   rJ    r&   r$   <module>rV      s   & 3 " @ z z < > )

 #@GH_@`pwx~p n I fm  
 )5<V_ ~ 7  
 "#5<V_ ~ 7  $
 (;B6? O    )=DV_ho  qH  iI - 7 \e  
 IJOVW] c C W  K
 /"OVW] *? W  # N#")&/ "s " " $"
  ' S g  
 )<CFO , '  
 vww7G QW QW Q Qr&   