My App

QUICKBOOKS INTEGRATION PLAN

SmartCrew Admin - QUICKBOOKS INTEGRATION PLAN

/cl# SmartCrew → QuickBooks Integration Plan

Executive Summary

This document outlines a high-level integration plan for syncing SmartCrew Admin Console data with QuickBooks Online for comprehensive accounting management. The integration will leverage Firebase Cloud Functions for secure API key management and the node-quickbooks NPM package for API interactions.

Architecture Overview

Security Architecture

  • API Key Storage: QuickBooks API credentials stored securely in Firebase Cloud Functions environment variables
  • Authentication Flow: OAuth 2.0 handled server-side via Cloud Functions
  • Client Communication: Flutter web app communicates with Cloud Functions, never directly with QuickBooks
  • Data Flow: SmartCrew → Cloud Functions → QuickBooks API

Technology Stack

  • Backend: Firebase Cloud Functions (TypeScript)
  • QuickBooks SDK: node-quickbooks NPM package
  • Frontend: Flutter Web (existing SmartCrew Admin Console)
  • Database: Firestore (existing)

Data Mapping: SmartCrew → QuickBooks

1. Company & Organization

SmartCrew Entity: Company QuickBooks Entity: CompanyInfo Mappable Fields:

  • Company.name → CompanyInfo.CompanyName
  • Company.startTime/endTime → Business hours configuration
  • Company.id → External reference tracking

2. Customers

SmartCrew Entity: CustomerBasic QuickBooks Entity: Customer Mappable Fields:

  • companyName → DisplayName
  • contactPerson → GivenName/FamilyName
  • email → PrimaryEmailAddr.Address
  • phoneNumber → PrimaryPhone.FreeFormNumber
  • address → BillAddr/ShipAddr
  • website → WebAddr.URI

Use Cases:

  • Sync all SmartCrew customers as QuickBooks customers
  • Enable invoice generation for projects
  • Track customer balances and payments

3. Vendors/Suppliers

SmartCrew Entity: Vendor QuickBooks Entity: Vendor Mappable Fields:

  • companyName → DisplayName
  • contactPerson → GivenName/FamilyName
  • email → PrimaryEmailAddr.Address
  • phoneNumber → PrimaryPhone.FreeFormNumber
  • address → BillAddr
  • vendorType → Custom field/Notes
  • paymentTerms → TermRef

Use Cases:

  • Sync material suppliers and equipment vendors
  • Track vendor bills and payments
  • Manage 1099 contractor information

4. Employees & Labor

SmartCrew Entity: AppUser + Labor QuickBooks Entities: Employee + TimeActivity Mappable Fields:

Employee Creation:

  • firstName + lastName → DisplayName
  • email → PrimaryEmailAddr.Address
  • phoneNumber → PrimaryPhone.FreeFormNumber
  • hourRate → HourlyRate (for hourly employees)
  • role → Title
  • active → Active status

Time Tracking:

  • DailyLog.clockIn/clockOut → TimeActivity.StartTime/EndTime
  • JobsiteActivity → TimeActivity.Description
  • Project reference → TimeActivity.CustomerRef
  • Labor hours → TimeActivity.Hours
  • Billable status → TimeActivity.Billable

Use Cases:

  • Sync all employees for payroll processing
  • Import daily time logs as TimeActivity records
  • Track billable vs non-billable hours
  • Generate payroll reports

5. Projects

SmartCrew Entity: Project QuickBooks Entities: Customer:Job (sub-customer) + Class Mappable Fields:

  • projectName → Customer.DisplayName (as sub-customer)
  • clientId → ParentRef (link to main customer)
  • expectedRevenue → Custom field for tracking
  • laborBudget → Budget tracking
  • materialBudget → Budget tracking
  • machineBudget → Budget tracking
  • startDate/endDate → Project timeline tracking

Use Cases:

  • Create projects as sub-customers under main clients
  • Use Classes for project categorization
  • Track project profitability
  • Monitor budget vs actual costs

6. Materials & Inventory

SmartCrew Entity: Materials QuickBooks Entities: Item (Service/NonInventory) + Bill or Purchase Mappable Fields:

  • item → Item.Name
  • vendorName → VendorRef
  • quantity → Qty
  • cost → UnitPrice
  • project → CustomerRef (for job costing)
  • billable → Item.Type (billable vs non-billable)
  • className → Class tracking

Use Cases:

  • Create items for frequently used materials
  • Record material purchases as Bills or Purchases
  • Track material costs per project
  • Generate material usage reports

7. Equipment

SmartCrew Entity: Equipment + EquipmentServiceRecord QuickBooks Entities: Item (Service type for rental rates) + FixedAsset + Purchase Mappable Fields:

  • name → Item.Name / FixedAsset.Name
  • hourRate → Item.UnitPrice (for equipment rental rates)
  • price → FixedAsset.PurchaseCost
  • purchaseDate → FixedAsset.PurchaseDate
  • Service records → Purchase/Bill for maintenance

Use Cases:

  • Track equipment as fixed assets
  • Bill equipment usage to projects
  • Record maintenance expenses
  • Calculate equipment depreciation

8. Financial Transactions

Invoicing

SmartCrew → QuickBooks Invoice:

  • Project completion → Generate Invoice
  • Customer reference → Invoice.CustomerRef
  • Labor hours × rates → Invoice.Line (Service items)
  • Materials (billable) → Invoice.Line (Product items)
  • Equipment usage → Invoice.Line (Service items)

Expense Tracking

SmartCrew → QuickBooks Bill/Purchase:

  • Material purchases → Bill (with VendorRef)
  • Equipment maintenance → Purchase
  • Other project expenses → Purchase/Bill with Class tracking

Payroll Integration

SmartCrew → QuickBooks Payroll:

  • TimeActivity records → Payroll hours
  • Employee rates → Payroll calculations
  • Overtime calculations → Based on SmartCrew overtime rules

9. Reporting Integration

Reports to Generate in QuickBooks:

  1. Project Profitability (P&L by Class/Customer)
  2. Labor Cost Reports (Time by Customer)
  3. Material Usage Reports (Expenses by Customer)
  4. Vendor Payment Reports (A/P Aging)
  5. Customer Invoice Reports (A/R Aging)
  6. Cash Flow Statements
  7. Budget vs Actual (by Project/Class)

Sync Strategy

Real-time Sync Triggers

  1. Customer/Vendor Changes: Immediate sync on create/update
  2. Employee Changes: Immediate sync for active status changes
  3. Invoice Generation: Sync when project milestones are reached

Batch Sync Operations

  1. Daily Time Logs: End-of-day batch sync
  2. Material Purchases: Daily batch sync
  3. Equipment Usage: Weekly sync
  4. Project Updates: Daily sync for active projects

Conflict Resolution

  1. Master Data Source: SmartCrew remains source of truth
  2. Update Direction: One-way sync (SmartCrew → QuickBooks)
  3. Error Handling: Failed syncs queued for retry
  4. Audit Trail: Log all sync operations in Firestore

Cloud Functions Implementation

Required Cloud Functions

// Authentication
- initializeQuickBooksAuth()
- refreshQuickBooksToken()

// Customer Management
- syncCustomerToQuickBooks()
- batchSyncCustomers()

// Vendor Management
- syncVendorToQuickBooks()
- batchSyncVendors()

// Employee & Time Tracking
- syncEmployeeToQuickBooks()
- syncTimeActivityToQuickBooks()
- batchSyncDailyLogs()

// Project Management
- createProjectInQuickBooks()
- updateProjectBudgets()

// Financial Transactions
- createInvoiceFromProject()
- recordMaterialPurchase()
- recordEquipmentUsage()

// Reporting
- generateProjectProfitabilityReport()
- generatePayrollReport()
- generateCashFlowStatement()

Environment Variables Required

QB_CLIENT_ID=<QuickBooks App Client ID>
QB_CLIENT_SECRET=<QuickBooks App Client Secret>
QB_REDIRECT_URI=<OAuth Redirect URI>
QB_ENVIRONMENT=<sandbox|production>
QB_WEBHOOK_TOKEN=<Webhook Verification Token>

Data Validation & Mapping Rules

Customer/Vendor Validation

  • Ensure unique DisplayName in QuickBooks
  • Map SmartCrew ID to QuickBooks ExternalId
  • Validate email and phone formats

Time Entry Rules

  • Round time to nearest 15 minutes (configurable)
  • Apply overtime rules from SmartCrew
  • Validate against QuickBooks payroll periods

Invoice Generation Rules

  • Group labor by employee and rate
  • Apply project markup percentages
  • Include only billable materials
  • Add equipment usage as line items

Benefits & Business Value

Immediate Benefits

  1. Automated Bookkeeping: Eliminate manual data entry
  2. Real-time Financial Visibility: Current project profitability
  3. Streamlined Payroll: Direct time entry to payroll system
  4. Accurate Job Costing: Track all project expenses
  5. Simplified Tax Preparation: All data in QuickBooks

Long-term Benefits

  1. Better Cash Flow Management: Real-time A/R and A/P tracking
  2. Improved Profitability Analysis: Detailed project margins
  3. Compliance: Proper books for audits and taxes
  4. Scalability: Handle growing transaction volumes
  5. Integration Ecosystem: Connect with other QuickBooks integrations

Limitations & Considerations

QuickBooks API Limitations

  1. Rate Limits: 500 requests/minute, 500K/month for Builder tier
  2. Batch Size: Maximum 30 operations per batch request
  3. Data Retention: Deleted records retained for 30 days only
  4. Custom Fields: Limited custom field support

Data Synchronization Challenges

  1. Schema Differences: Not all SmartCrew fields map directly
  2. Business Rule Conflicts: QuickBooks may reject certain data
  3. Timing Issues: Payroll period vs SmartCrew log dates
  4. Currency Handling: Ensure consistent currency codes

Phase 1: Core Entities (Month 1)

  • Customers and Vendors sync
  • Basic employee sync

Phase 2: Time Tracking (Month 2)

  • Daily log to TimeActivity sync
  • Basic payroll integration

Phase 3: Project Financials (Month 3)

  • Project creation and tracking
  • Material and equipment cost tracking

Phase 4: Invoicing & Reporting (Month 4)

  • Automated invoice generation
  • Financial reporting integration

Next Steps

  1. Obtain QuickBooks Developer Account: Register app in QuickBooks
  2. Set Up Sandbox Environment: Test integration safely
  3. Implement OAuth Flow: Secure authentication in Cloud Functions
  4. Create Data Mapping Service: Build transformation layer
  5. Develop Sync Queue System: Handle batch operations
  6. Build Error Recovery: Implement retry logic and notifications
  7. Create Admin UI: Add QuickBooks sync controls to SmartCrew
  8. Test with Pilot Customer: Validate with real data
  9. Document User Workflows: Train users on new features
  10. Monitor and Optimize: Track sync performance and errors

Conclusion

This integration will transform SmartCrew from a project management tool into a comprehensive business management platform. By leveraging QuickBooks' robust accounting features while maintaining SmartCrew's specialized construction management capabilities, businesses can operate more efficiently with real-time financial insights and automated bookkeeping processes.

On this page