# SampleApp_Dimensions_Python A simple Flask application that demonstrates integration with QuickBooks Online API to fetch dimensions and attach those dimensions to invoices. ## App features - OAuth 2.0 authentication with QuickBooks Online - Fetch dimensions from QuickBooks - Attach dimensions to invoices - Dimension tracking and management ## Prerequisites - Python 3.12.7 or higher - QuickBooks Developer account with OAuth 2.0 credentials - Quickbooks company with IES subscription - Dimensions scope enabled for your sample app ## Setup Instructions 1. **Clone the Repository** ```bash git clone cd SampleApp_Dimensions_Python ``` 2. **Create Virtual Environment** ```bash python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate ``` 3. **Install Dependencies** ```bash pip3 install -r FlaskApp/requirements.txt ``` 4.**Set environment variables** Create a `.env` file in the root directory of the project with your QuickBooks credentials: Update the environment variables with your app credentials(Note:In case the .env file doesn't pick your app credentials, you can directly update the values in the codebase at config.py): ``` QB_CLIENT_ID=your_client_id QB_CLIENT_SECRET=your_client_secret QB_REDIRECT_URI=your_redirect_uri # e.g., https://your-ngrok-url.ngrok-free.app/callback QB_ENVIRONMENT=sandbox # or production ``` ## Configure your QuickBooks app 1. Go to Intuit Developer Portal 2. Create a new app or use an existing one 3. Enable Dimensions and Accounting API scopes 4. Add your redirect URI (e.g., https://your-ngrok-url.ngrok-free.app/callback) ## Start ngrok ```bash ngrok http 5002 ``` ## Running the Application 1. **Start the Flask Server** ```bash cd FlaskApp python3 app.py ``` 2. **Access the Application** Access the application at `http://localhost:5002` ## Usage Guide ### Authentication 1. Click the "Connect to QuickBooks" button 2. Log in to your QuickBooks account 3. Authorize the application to access your QuickBooks data ### Fetching Dimensions 1. Ensure you have dimensions created in QuickBooks 2. The dropdowns will be populated with the dimensions and their values 3. Select a dimension and select its value ### Creating Invoices 1. Select a customer from the dropdown 2. Select an item from the dropdown 3. Select a dimension and select its value 4. Enter the amount 5. Click "Create Invoice" ## Project Structure ``` SampleApp_Demensions_Python/ ├── FlaskApp/ │ ├── app.py # Main Flask application │ ├── config.py # Configuration settings │ ├── requirements.txt # Python dependencies │ ├── .env.template # Template for environment variables │ ├── static/ # Static assets (CSS, images) │ │ ├── styles.css │ │ ├── graphql/ # GraphQL queries and mutations │ │ └── images/ │ └── templates/ # HTML templates │ └── index.html ├── README.md ├── .gitignore └── LICENSE.txt ``` ## Security Notes - Never commit your `.env` file to version control - Keep your QuickBooks credentials secure - Use environment variables for all sensitive information - The `.env` file is automatically ignored by Git ## Troubleshooting 1. **Authentication Issues** - Ensure your OAuth credentials are correct in the `.env` file - Check that the redirect URI matches your QuickBooks app settings - Verify admin is connecting to Quickbooks account 2. **Environment Setup Issues** - Make sure the `.env` file exists and contains all required variables - Verify that environment variables are being loaded correctly - Check that the virtual environment is activated 3. **API Errors** - Check the application logs for detailed error messages - Verify your QuickBooks subscription includes API access - Ensure you're using the correct API endpoints for your QuickBooks environment ## Contributing Feel free to submit issues and enhancement requests. For major changes, please open an issue first to discuss what you would like to change.