Commit Graph
54 Commits
Author SHA1 Message Date
rickyandClaude Opus 5.5 5b6c1ed2c2 Cache invoices' sales tax and the day they were paid in full
New invoices columns tax_amount and paid_on, filled in by the invoice
sync. An invoice is paid in full on the later of its date and the
dates of the payments and credit memos applied to it (local payments
first; QuickBooks only for ones not synced yet and credit memos), so
reports such as the monthly sales commission don't have to read
invoices from QuickBooks. A full sync fills them in for older
invoices; it now syncs payments before invoices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:34:21 -05:00
rickyandClaude Opus 5.5 d2cdd798cd Show names in issue history, and record invoices the webhook attaches
The history showed the customer and estimate as id numbers. It now shows their names,
for existing entries too. When the QuickBooks webhook attaches an invoice to an issue,
the issue's history gets "Invoice 1042 added", linking to the invoice PDF.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 21:53:13 -05:00
Claude b739b84917 Fix duplicate estimates: make QuickBooks ids unique
The customers, employees, estimates and invoices tables were created with
t.integer :id, options: 'PRIMARY KEY', which Rails ignores, so the QuickBooks id was never unique. Two
syncs of the same record at once (saving an estimate in Redmine, then QuickBooks' webhook) inserted it
twice, so it showed twice on the customer page and counted twice on the business report.

- Migration 050 keeps one row per id (the most recently updated) and adds a unique index on id.
- A sync that collides with another one's insert retries once as an update.
- Estimates, customers and employees validate a unique id, like invoices already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-31 11:48:23 -04:00
Claude 28538d4c7f Show when a QuickBooks sync is running
Syncs record their state in a new qbo_sync_statuses table: queued when asked for, running with how
many records have been read, removed when finished (stale rows are ignored after 6 hours). The
business report says when estimates, invoices or payments are still syncing and refreshes every 30
seconds until they finish; the settings page's Synchronization table shows the same per type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-31 10:03:12 -04:00
Claude bf7c7b0905 Sync services and other items without a description or rate
QuickBooks only requires an item's name, but the local Item required a description and a rate, so
services such as Labor (often with neither) failed validation and were silently skipped by the sync.
Name is now the only requirement; a missing description syncs as blank and a missing rate as 0.
Product/service pickers and the labor setting list sellable items only (no Categories or Bundles).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-31 09:34:22 -04:00
Claude 3304fce92f Make billed estimates read-only
An estimate that's Converted or Closed in QuickBooks, or linked to an invoice, opens read-only and is
refused on save (this includes redmine_qbo_lineitems' estimates once invoiced). Its page lists the
invoices it's on. Estimates cache their status so lists show View instead of Edit for them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-31 08:34:41 -04:00
Claude 4732c32409 Combine the labor settings into Labor products/services
The estimate item codes and "Replaced by imported time" become one list of products/services
(RedmineQboBilling::LaborItems), used to create issues from an estimate's labor lines (and an
appointment's minimum hours), to offer an invoice's labor lines to be replaced by imported time, and
to total the hours on estimates and invoices for the business report. While none are chosen,
products/services named Labor are used. The old settings and redmine_qbo_calendar's fallbacks are no
longer read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-31 08:22:32 -04:00
Claude 062ef9b8b3 Cache totals, man-hours and payments; add a business report
- Estimates now keep their total; estimates and invoices keep their man-hours: the quantities of the
  products/services set as "Replaced by imported time" (bundles included; the estimate item codes
  while that setting is blank). Filled in by the webhook and the sync.
- Payment model (QboBaseModel) caching each payment's customer, date, amount and unapplied amount,
  kept current by the webhook, the sync and the Receive payment page.
- Business report (View business reports permission, top menu): estimates written vs. invoices written
  vs. payments received, and estimated hours on estimates and issues vs. invoiced and spent hours, for
  a period, with a month-by-month breakdown.
- Fix two keyword arguments that defaulted to themselves (QboSyncDispatcher.enque_jobs, PdfService),
  which newer Ruby refuses to parse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-31 07:54:28 -04:00
Claude 9121e079a0 Fold redmine_qbo_billing into redmine_qbo
Estimates, invoices and payments written in Redmine, issues from estimates,
and the QuickBooks product/service list and accounts are now part of this
plugin (the RedmineQboBilling code, its controllers, views, strings and
permissions), so there's one plugin and one version instead of two that had
to match.

- The customer page, estimate and invoice lists and the issue page render the
  Create Estimate / Create invoice / Receive payment and Edit links directly;
  the hooks that only existed to let billing add them are gone. Users without
  the billing permissions still get the links to QuickBooks.
- Migrations 043-046 create the items and accounts tables and the estimate
  line links, skipping whatever an existing database already has
  (redmine_qbo_lineitems' tables are used as they are), and copy calendar's
  existing estimate line links in.
- The billing settings are a section of this plugin's settings page.
- The hooks other plugins use stay: qbo_billing_issue_values,
  qbo_billing_validate, qbo_billing_issue_defaults, qbo_billing_issues_created
  and view_qbo_estimate_contextual.
- rake redmine_qbo:relate_estimate_issues

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-30 23:47:01 -04:00
Claude c4ab97b75e Customer search: bundled nickname data and sound-alike matching
- Nicknames now come from the carltonnorthern/nicknames data set
  (Apache 2.0, ~2,800 pairs, bundled in data/nicknames with its license),
  plus a few extra groups in EXTRA_NICKNAME_GROUPS. Names match if
  directly linked, or if both are short for the same longer name, so
  Bill/William and Bill/Will match but William/Robert don't (the data
  lists "bill" for both)
- Double Metaphone (text gem) matches names that sound alike but are
  spelled differently: Jon/John, Smyth/Smith, Cathy/Kathy,
  Steven/Stephen, Jeffrey/Geoffrey
- Faster ranking: per-search word-pair scores are cached, whole-name
  comparison only runs when it can succeed, and prepared search data is
  kept in process memory until a customer changes (~40 ms per search at
  5,000 customers)

Adds gem 'text', '~> 1.3' to the Gemfile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-28 22:22:00 -04:00
Claude 0523e8dd24 Security, permission and search fixes
Security
- Connecting to QuickBooks (authenticate/oauth_callback) and all syncs
  are admin-only; the OAuth state is stored and verified on callback
- New "Bill issue time to QuickBooks" project permission; billing is now
  a POST and checks the permission and issue visibility
- Estimate/invoice PDFs require a logged-in user, or a customer share
  link limited to the estimate and invoices attached to that issue
  (the old require_user check never ran)
- Attachments patch keeps the share token per request instead of in
  Thread.current, so it can't leak into other requests

Permissions and share links
- customers#autocomplete and the filter_* actions are part of View
  customers, so non-admins can pick customers on forms
- customers#view no longer goes through authorize_global; share needs
  the new "Share issues with customers" permission and a visible issue
- Removed a check in customers#view that compared a value to itself

Bugs
- Subjects and customer names capitalize each word without lowercasing
  the rest (LED, JL, 4x4 stay as typed); subjects only when changed
- Settings page shows Invoice/Estimate sync times (Item/Account models
  no longer exist)
- customers#update shows validation errors instead of reporting success
- Billing marks each activity billed once sent to QBO, so retries and
  token refreshes don't create duplicate TimeActivities

Search
- New CustomerSearchService for autocomplete and the customer search
  page: nicknames (Bill/William), typos, word order, partial words,
  accents, and phone digits in any format; ranked, with the candidate
  list cached until a customer changes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
2026-10-28 22:08:36 -04:00
ricky f2b0186ee2 Add EstimateService class 2026-08-09 20:50:20 -04:00
ricky e681203a45 Removed custom field sync, it was never really useful anyways. 2026-03-28 00:25:07 -04:00
ricky 7993f15441 updated comments 2026-03-14 15:30:50 -04:00
ricky 1a10360884 refactored PdfService to use QboConnectionService 2026-03-14 00:16:11 -04:00
ricky cd109f16b5 Refactored QBO service calls 2026-03-14 00:10:10 -04:00
ricky 164252cb97 Refactored PDF services 2026-03-13 23:40:52 -04:00
ricky fd18205c10 Refactored all Sync Jobs into QboSyncJob 2026-03-13 23:26:02 -04:00
ricky 6fc8a18e93 Updated attribute mapping 2026-03-13 15:43:24 -04:00
ricky c87e18810b Added Attribute Mapping DSL 2026-03-13 08:32:55 -04:00
ricky eb6954ddf1 refactor(sync): improve attribute mapping to support dynamic fields and custom transformations 2026-03-12 21:38:06 -04:00
ricky be1a69217f created a shared helper for authenticated requests. 2026-03-12 21:05:39 -04:00
ricky 99669f7baa created a shared helper for performing authenticated request. 2026-03-12 18:26:21 -04:00
ricky 29530e2c95 fixed order 2026-03-12 17:55:09 -04:00
ricky 40f7a3335c Reworked push on save and refactored variable names 2026-03-12 15:58:28 -04:00
ricky ffd8dc6332 Refactored Customer service to use a service base class 2026-03-12 09:48:36 -04:00
ricky b10665355d Allow Subclasses to override the page size 2026-03-08 23:34:37 -04:00
ricky ef5089438c Fixed query_in_batches 2026-03-08 21:51:31 -04:00
ricky 9f9810686f removed logging 2026-03-03 20:36:23 -05:00
ricky f041e1bce4 Added logging for completed pull 2026-03-03 20:05:19 -05:00
ricky d44d5e2fb7 Fixed log prefix 2026-03-03 19:54:50 -05:00
ricky 4403267abb Moved QBO fetch from customer model into service 2026-03-03 19:49:36 -05:00
ricky 23e565a304 raise exceptions if not initialized properly 2026-03-02 22:57:13 -05:00
ricky 2e2b17fac3 log should be private 2026-03-02 22:54:26 -05:00
ricky 899237c5ab Reduced blanket rescues, added respond_to_missing?, and extracted push into CustomerPushService 2026-03-02 22:41:22 -05:00
ricky 899c9878c4 Fix: only attach invoices if document is updated 2026-03-01 19:27:23 -05:00
ricky ef3f00c445 Refactor: Replace BillingValidator with inline validations in bill method and update error messages in locale 2026-03-01 12:29:20 -05:00
ricky 46f06df995 Removed unused service 2026-03-01 12:14:53 -05:00
ricky 7b7b07b5fa fixed file name 2026-03-01 01:01:26 -05:00
ricky ed111fefe7 Refactor: Update QBO connection handling to use QboConnectionService for consistency across services and controllers 2026-03-01 00:27:06 -05:00
ricky f921f227e2 Refactor: Introduce PdfServiceBase for shared PDF fetching functionality and update Invoice/Estimate controllers to utilize new services 2026-02-28 21:59:01 -05:00
ricky a34ae46358 Refactor: Simplify invoice PDF fetching and introduce InvoicePdfService for better organization 2026-02-28 21:36:16 -05:00
ricky 348c521491 Added comments 2026-02-28 20:03:19 -05:00
ricky 6cee8c1d81 Fix: Remove logging of fetched page information in SyncServiceBase 2026-02-28 19:59:50 -05:00
ricky d4a0aa1db5 Refactor: Introduce SyncServiceBase for shared functionality across sync services 2026-02-28 19:47:45 -05:00
ricky b80dbaa015 Fix: Update last_update query to use correct timestamp field for customer sync 2026-02-28 09:11:01 -05:00
ricky 9e399b934b Fix: Update last_update query to use correct timestamp field for employee sync 2026-02-28 09:10:55 -05:00
ricky 9089adaba0 removed uneeded comments 2026-02-28 08:35:35 -05:00
ricky 19911b7940 Refactor EstimateSyncJob to support syncing by ID and document number; add EstimateSyncService for handling estimate synchronization 2026-02-28 08:24:25 -05:00
ricky eee99e4d83 Implement CustomerSyncService for customer synchronization and update CustomerSyncJob to support syncing by ID 2026-02-28 07:50:07 -05:00