Esempio n. 1
0
    def sync_vendors(self):
        """
        Get vendors
        """
        vendors = self.connection.vendors.get()

        vendor_attributes = []

        for vendor in vendors:
            vendor_attributes.append({
                'attribute_type': 'VENDOR',
                'display_name': 'vendor',
                'value': vendor['DisplayName'],
                'destination_id': vendor['Id']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            vendor_attributes, self.workspace_id)
        return account_attributes
Esempio n. 2
0
    def sync_classes(self):
        """
        Get classes
        """
        classes = self.connection.classes.get()

        class_attributes = []

        for qbo_class in classes:
            class_attributes.append({
                'attribute_type': 'CLASS',
                'display_name': 'class',
                'value': qbo_class['Name'],
                'destination_id': qbo_class['Id']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            class_attributes, self.workspace_id)
        return account_attributes
Esempio n. 3
0
    def sync_departments(self):
        """
        Get departments
        """
        departments = self.connection.departments.get()

        department_attributes = []

        for department in departments:
            department_attributes.append({
                'attribute_type': 'DEPARTMENT',
                'display_name': 'Department',
                'value': department['Name'],
                'destination_id': department['Id']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            department_attributes, self.workspace_id)
        return account_attributes
Esempio n. 4
0
    def sync_customers(self):
        """
        Get customers
        """
        customers = self.connection.customers.get()

        customer_attributes = []

        for customer in customers:
            customer_attributes.append({
                'attribute_type': 'CUSTOMER',
                'display_name': 'customer',
                'value': customer['DisplayName'],
                'destination_id': customer['Id']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            customer_attributes, self.workspace_id)
        return account_attributes
Esempio n. 5
0
    def sync_employees(self):
        """
        Get employees
        """
        employees = self.connection.employees.get()

        employee_attributes = []

        for employee in employees:
            employee_attributes.append({
                'attribute_type': 'EMPLOYEE',
                'display_name': 'employee',
                'value': employee['DisplayName'],
                'destination_id': employee['Id']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            employee_attributes, self.workspace_id)
        return account_attributes
Esempio n. 6
0
    def sync_projects(self):
        """
        Get projects
        """
        projects = self.connection.projects.get_all()

        project_attributes = []

        for project in projects:
            project_attributes.append({
                'attribute_type': 'PROJECT',
                'display_name': 'project',
                'value': project['NAME'],
                'destination_id': project['PROJECTID']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            project_attributes, self.workspace_id)
        return account_attributes
Esempio n. 7
0
    def sync_expense_types(self):
        """
        Get expense types
        """
        expense_types = self.connection.expense_types.get_all()

        expense_types_attributes = []

        for expense_type in expense_types:
            expense_types_attributes.append({
                'attribute_type': 'EXPENSE_TYPE',
                'display_name': 'Expense Types',
                'value': expense_type['DESCRIPTION'],
                'destination_id': expense_type['ACCOUNTLABEL']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            expense_types_attributes, self.workspace_id)
        return account_attributes
Esempio n. 8
0
    def sync_accounts(self):
        """
        Get accounts
        """
        accounts = self.connection.accounts.get_all()

        account_attributes = []

        for account in accounts:
            account_attributes.append({
                'attribute_type': 'ACCOUNT',
                'display_name': 'account',
                'value': account['TITLE'],
                'destination_id': account['ACCOUNTNO']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            account_attributes, self.workspace_id)
        return account_attributes
Esempio n. 9
0
    def sync_locations(self):
        """
        Get locations
        """
        locations = self.connection.locations.get_all()

        location_attributes = []

        for location in locations:
            location_attributes.append({
                'attribute_type': 'LOCATION',
                'display_name': 'location',
                'value': location['NAME'],
                'destination_id': location['LOCATIONID']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            location_attributes, self.workspace_id)
        return account_attributes
Esempio n. 10
0
    def sync_accounts(self, account_type: str):
        """
        Get accounts
        """
        accounts = self.connection.accounts.get()

        accounts = list(
            filter(
                lambda current_account: current_account['AccountType'] ==
                account_type, accounts))

        account_attributes = []

        if account_type == 'Expense':
            attribute_type = 'ACCOUNT'
            display_name = 'Account'
        elif account_type == 'Credit Card':
            attribute_type = 'CREDIT_CARD_ACCOUNT'
            display_name = 'Credit Card Account'
        elif account_type == 'Bank':
            attribute_type = 'BANK_ACCOUNT'
            display_name = 'Bank Account'
        else:
            attribute_type = 'ACCOUNTS_PAYABLE'
            display_name = 'Accounts Payable'

        for account in accounts:
            account_attributes.append({
                'attribute_type': attribute_type,
                'display_name': display_name,
                'value': account['Name'],
                'destination_id': account['Id']
            })

        account_attributes = DestinationAttribute.bulk_upsert_destination_attributes(
            account_attributes, self.workspace_id)
        return account_attributes