Пример #1
0
 def get(self, country_id: UUID):
     try:
         result = super(CountryStore, self).runProc('common.countries_get',
                                                    [country_id])
         if len(result) > 0:
             return result[0]
         else:
             raise StoreException('No country found with specified Id')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve country')
Пример #2
0
 def get(self, client_id: UUID, project_id: UUID) -> dict:
     try:
         result = super(ProjectStore, self).runProc('work.project_get',
                                                    [client_id, project_id])
         if len(result) > 0:
             return result[0]
         else:
             raise StoreException('Project not found')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve project')
Пример #3
0
 def get(self, client_id: UUID, dimension: str, uom_id: int) -> {}:
     try:
         result = super(UOMStore,
                        self).runProc('common.uom_get',
                                      [client_id, dimension, uom_id])
         if len(result) > 0:
             return result[0]
         else:
             raise StoreException('Unable to find unit of measure')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve unit of measure')
Пример #4
0
 def get(self, client_id: UUID, facility_id: UUID):
     try:
         result = super(FacilityStore,
                        self).runProc('inventory.facility_get',
                                      [client_id, facility_id])
         if len(result) > 0:
             return result[0]
         else:
             raise StoreException('Facility not found')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve facility')
Пример #5
0
 def get(self, client_id: UUID, account_id: UUID) -> {}:
     try:
         result = super(AccountsStore,
                        self).runProc('accounting.account_get',
                                      [client_id, account_id])
         if len(result) > 0:
             return result[0]
         else:
             raise StoreException('Missing account')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve account')
Пример #6
0
 def get(self, client_id: UUID, location_id: UUID) -> {}:
     try:
         result = super(LocationStore,
                        self).runProc('inventory.location_get',
                                      [client_id, location_id])
         if len(result) > 0:
             return result[0]
         else:
             raise StoreException('No location found')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve location')
Пример #7
0
 def get(self, client_id: UUID, group_id: UUID) -> {}:
     try:
         result = super(GroupStore, self).runProc('accounting.account_group_get', [
             client_id,
             group_id
         ])
         if len(result) > 0:
             return result[0]
         else:
             raise StoreException('No account group found')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve account group')
Пример #8
0
 def get(self, client_id: UUID, project_id: UUID, task_id: UUID) -> dict:
     try:
         result = super(TaskStore, self).runProc('work.task_get', [
             client_id,
             project_id,
             task_id
         ])
         if len(result) > 0:
             return result[0]
         else:
             raise StoreException('Missing project task')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve project task')
Пример #9
0
 def by_name(self, name: str) -> UUID:
     try:
         result = super(ClientStore, self).runProc('clients.client_by_name', [
             super(ClientStore, self).remove_wildcards(name)
         ])
         if len(result) > 0:
             client = result[0]
             client_id = client[0]
             return client_id
         else:
             raise StoreException('Unable to find client account using name')
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to find client using name')
Пример #10
0
    def add(self, transaction={}):
        try:
            client_id = transaction['clientId']
            transaction_id = transaction['transactionId']

            cn = super(TransactionStore, self).begin()

            c = cn.cursor()
            c.callproc('accounting.transaction_add', [
                client_id, transaction_id, transaction['currencyId'],
                transaction['description']
            ])

            # process transaction items
            entries = transaction['entries']
            for e in entries:
                c.callproc('accounting.transaction_item_add', [
                    client_id, transaction_id, e['id'], e['accountId'],
                    e['debit'], e['credit']
                ])

            # process transaction attachments
            attachments = transaction[
                'attachments'] if 'attachments' in transaction else []
            for a in attachments:
                c.callproc('accounting.transaction_attachment_add', [
                    client_id, transaction_id, a['id'], a['filename'],
                    a['type'], a['size'], a['data']
                ])

            super(TransactionStore, self).commit(cn)
        except Exception as e:
            log.error(e)
            super(TransactionStore, self).rollback(cn)
            raise StoreException(e)
Пример #11
0
    def update(self, client_id: UUID, project_id: UUID, name: str,
               description: str, planned_start: datetime,
               planned_end: datetime, actual_start: datetime,
               actual_end: datetime, tasks: list) -> None:
        cn = super(ProjectStore, self).begin()
        try:
            c = cn.cursor()
            c.callproc('work.project_update', [
                client_id, project_id, name, description, planned_start,
                planned_end, actual_start, actual_end
            ])

            for t in tasks:
                current_task_id = t['taskId']
                status = t['status']
                if status is None:
                    c.callproc('work.task_add', [
                        client_id, project_id, current_task_id, t['name'],
                        t['description']
                    ])
                elif status == 'update':
                    c.callproc('work.task_update', [])
                elif status == 'remove':
                    c.callproc('work.task_remove',
                               [client_id, project_id, current_task_id])
                else:
                    log.warning('Unhandled case %s', status)

                super(ProjectStore, self).commit(cn)
        except Exception as e:
            super(ProjectStore, self).rollback(cn)
            log.error(e)
            raise StoreException('Unable to update project')
Пример #12
0
 def post(self, client_id: UUID, transaction_id: UUID) -> None:
     try:
         super(TransactionStore,
               self).runProcTransactional('accounting.transaction_post',
                                          [client_id, transaction_id])
     except Exception as e:
         log.error(e)
         raise StoreException(e)
Пример #13
0
 def assign_group(self, client_id: UUID, account_id: UUID, group_id: UUID):
     try:
         super(AccountsStore,
               self).runProcTransactional('accounting.account_assign_group',
                                          [client_id, account_id, group_id])
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to assign account to group')
Пример #14
0
 def add(self, client_id: UUID, role_id: UUID, name: str) -> None:
     try:
         super(RolesStore, self).runProcTransactional(
             'iam.role_add',
             [str(client_id), str(role_id), name])
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to add client role')
Пример #15
0
 def filter(self, filter: str) -> []:
     try:
         return super(CountryStore, self).runProc('common.countries_filter',
                                                  [f'%{filter}%'])
     except Exception as e:
         log.error(e)
         raise StoreException(
             'Unable to retrieve a filtered list of countries')
Пример #16
0
 def get(self, currency_id: int):
     try:
         return super(CurrencyStore, self).runProc('common.currency_get', [
             currency_id,
         ])
     except StoreException as e:
         log.error(e)
         raise StoreException('Unable to retrieve currency')
Пример #17
0
 def filter(self, client_id: UUID, filter: str):
     try:
         return super(FacilityStore,
                      self).runProc('inventory.facility_filter',
                                    [client_id, f'%{filter}%'])
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve facilities')
Пример #18
0
 def filter(self, client_id: UUID, filter: str) -> list:
     try:
         result = super(ProjectStore,
                        self).runProc('work.project_filter',
                                      [client_id, f'%{filter}%'])
         return result
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve projects')
Пример #19
0
 def userByEmail(self, email: str):
     '''find user account by email address
     '''
     try:
         [result, ] = super(UserStore, self).runProcTransactional('iam.user_get_by_email', [email, ])
         return result
     except Exception as e:
         log.error(e)
         raise StoreException("Unable to find user account by email address")
Пример #20
0
 def tree(self, client_id: UUID):
     try:
         result = super(GroupStore, self).runProc('accounting.account_group_tree', [
             client_id,
         ])
         return result
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve account group tree')
Пример #21
0
 def join(self, client_id: UUID, user_id: UUID) -> None:
     try:
         super(ClientStore, self).runProcTransactional('iam.client_user_join', [
             str(client_id),
             str(user_id)
         ])
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to join client')
Пример #22
0
 def update(self, client_id: UUID, account_id: UUID, name: str,
            description: str) -> None:
     try:
         super(AccountsStore,
               self).runProc('accounting.account_update',
                             [client_id, account_id, name, description])
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to update account')
Пример #23
0
 def filter(self, client_id: UUID, dimension: str, filter: str) -> []:
     try:
         return super(UOMStore,
                      self).runProc('common.uom_filter',
                                    [client_id, dimension, f'%{filter}%'])
     except Exception as e:
         log.error(e)
         raise StoreException(
             'Unable to retrieve filter list of units of measure')
Пример #24
0
 def client_user_set_active(self, client_id: UUID, user_id: UUID,
                            active: bool) -> None:
     try:
         super(UsersStore, self).runProcTransactional(
             'iam.client_user_set_active',
             [str(client_id), str(user_id), active])
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to set client user to active')
Пример #25
0
 def filter(self, client_id: UUID, filter: str):
     try:
         result = super(TransactionStore,
                        self).runProc('accounting.transactions_filter',
                                      [client_id, f'%{filter}%'])
         return result
     except Exception as e:
         log.error(e)
         raise StoreException(e)
Пример #26
0
 def accounts(self, client_id: UUID, group_id: UUID) -> []:
     try:
         result = super(GroupStore, self).runProc('accounting.account_group_accounts', [
             client_id,
             group_id
         ])
         return result
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve account group accounts')
Пример #27
0
 def assignParent(self, client_id: UUID, group_id: UUID, parent_group_id: UUID):
     try:
         super(GroupStore, self).runProcTransactional('accounting.account_group_assign_parent', [
             client_id,
             group_id,
             parent_group_id
         ])
     except Exception as e:
         log.error(e)
         raise StoreException(e)
Пример #28
0
 def permissions(self, client_id: UUID, user_id: UUID) -> List[str]:
     try:
         result = super(UserStore, self).runProc('iam.client_user_permissions', [
             str(client_id),
             str(user_id)
         ])
         permissions = [r[0] for r in result]
         return permissions
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to retrieve user permissions')
Пример #29
0
 def userClients(self, user_id: UUID) -> list:
     '''retrieve clients allowed/available to user
     '''
     try:
         result = super(UserStore, self).runProc('iam.user_clients_all', [
             str(user_id), 
         ])
         return result
     except Exception as e:
         log.error(e)
         raise StoreException("Unable to retrieve user clients")
Пример #30
0
 def userAdd(self, user_id: UUID, email: str, name: str) -> None:
     ''' add user
     '''
     try:
         super(UserStore, self).runProcTransactional('iam.user_add', [
             str(user_id),
             email,
             name
         ])
     except Exception as e:
         log.error(e)
         raise StoreException('Unable to add user')