Commit Graph
200 Commits
Author SHA1 Message Date
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 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 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 c31ec82e61 Normalize customer name before saving and update QBO display name accordingly 2026-08-10 15:20:14 -04:00
ricky bb57af71ae Simplified detail calls 2026-03-14 08:20:18 -04:00
ricky 2bcb1840a4 Added qbo_sync flag 2026-03-13 08:33:18 -04:00
ricky 4fa8be856a Refactored models to use base model 2026-03-12 11:14:45 -04:00
ricky 00b1baa1f3 Fixed create new customer 2026-03-05 21:33:49 -05:00
ricky b96678a2e9 fixed accident deleteion details_cache_key 2026-03-04 20:09:13 -05:00
ricky bccfcd9dbc cache qbo details to reduce api calls 2026-03-04 20:06:22 -05:00
ricky 4403267abb Moved QBO fetch from customer model into service 2026-03-03 19:49:36 -05:00
ricky f8b1c72394 show all customer when search is blank 2026-03-02 22:49:18 -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 f02b50ae26 Added time stamps to each qbo entity model 2026-03-02 07:10:13 -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 eee99e4d83 Implement CustomerSyncService for customer synchronization and update CustomerSyncJob to support syncing by ID 2026-02-28 07:50:07 -05:00
ricky 889e9bf31f Refactor customer synchronization to use CustomerSyncJob; remove direct sync logic from Customer model for improved background processing 2026-02-27 08:00:38 -05:00
ricky a64016eb95 Refactor QBO billing to use ActiveJob; remove threaded billing and add manual job enqueue support 2026-02-26 19:48:29 -05:00
ricky 5d858ae186 Enhance customer search functionality by ordering results and refining search method 2026-02-25 22:05:52 -05:00
ricky 138e55933b Fixed creation of new customers. 2026-02-25 15:32:45 -05:00
ricky 5fbc169ade Restored old search 2026-02-25 08:08:02 -05:00
ricky 65db8f00a8 Improve customer search with Full-Text index and phonetic matching 2026-02-22 19:07:20 -05:00
ricky 0197dc2a30 removed unused method 2026-02-22 13:34:23 -05:00
ricky 4b45d24a75 Enhance Customer model with redmine's built in searchable and event capabilities 2026-02-22 13:31:28 -05:00
ricky 3deafd8a6d Fixed search event_url 2026-02-21 11:35:15 -05:00
ricky a54de28db5 Extending customers to Redmine's built in search 2026-02-21 11:20:20 -05:00
ricky 9b656534ae Sanitize search, no little bobby tables 2026-02-21 08:23:58 -05:00
ricky b80e1d4e28 loose the hash rocket, use symbol keys 2026-01-29 22:30:59 -05:00
ricky 3c2f1d0edd Merge branch 'redmine-6' into HEAD 2026-01-22 20:39:20 -05:00
ricky 2aeb3fa028 Updated copyright dates 2026-01-21 20:40:06 -05:00
ricky 166a9ee31b Removed has_many purchases, table doesn't exist anymore 2025-06-16 22:54:47 -04:00
ricky dac9a7c756 Started Support for Redmine 6 2024-12-12 06:00:36 -05:00
ricky 8c63817950 Use free_form_number 2024-03-28 14:13:39 -04:00
ricky e2f43d398f Nil Checks 2024-03-28 14:01:18 -04:00
ricky 7ba4829066 Update Customer Phone Numbers On Sync 2024-03-28 13:51:29 -04:00
ricky aceb6cb6b5 fixed typo 2023-12-31 16:26:02 -05:00
ricky 2985fad77c Fixed typo 2023-12-30 23:01:01 -05:00
ricky 02b5fb4d0e Fixed returned variable handling 2023-12-30 22:53:08 -05:00
ricky bf417c163c Rework performing authenticated requests 2023-12-30 22:33:28 -05:00
ricky f094ef57ec Setter for notes 2023-12-30 20:08:36 -05:00
ricky 122063b1d5 Fixed customer typo 2023-12-29 19:14:38 -05:00
ricky 3a0e58c3da Append last 4 of phone number to customers name 2023-05-22 07:34:18 -04:00
ricky b686110145 Initial Vehicle Delete 2022-03-14 07:22:43 -04:00
ricky a75f1abd71 Removed extra white spaces 2022-03-09 22:53:03 -05:00
ricky 09c497ff96 Removed old #attr_accessible... comments 2022-03-09 22:31:19 -05:00
ricky 24f8be6e80 Drop the Qbo prefix 2022-03-09 21:31:56 -05:00
ricky 7cc8a946fd Inital update for redmine 4.0+ compatibility 2022-02-01 20:53:20 -05:00
ricky d37ff922fc Update customer.rb 2020-01-04 15:51:04 -05:00
ricky b8fc57d583 Oauth2 Upgrade 2020-01-04 15:31:19 -05:00
ricky 65eac58f6c Update customer.rb 2019-06-25 12:48:35 -04:00