Make "totals from primary" for bundle discounts a per-customer or per-instance toggle

Objective

  • Make the behavior that totals bundle discounts from the primary (e.g. US bundle logic) optional and configurable per customer, brand, or instance.
  • Expose a toggle so organizations that need the "totals from primary" behavior can have it on, and others can keep the previous totaling behavior.

Background

  • A recent change rolled out "totaling the totals off of the primary" for bundle discounts to all customers. Some organizations need this behavior; others do not. The one-size-fits-all rollout caused incorrect totals or process mismatches for those who do not want it.
  • The requirement is to unwind the global behavior and make it a toggle (per customer, brand, or instance) so each organization can choose the totaling behavior that matches their process.

Scope

Backend

  • Quote and charge totaling: the quote schema has a total field; charges are defined in chargeSchema with bundleDiscountAmount, isPrimary, and _bundleId. The logic that computes quote or inspection total (including when to derive it from primary vs. sum of all charges) must respect a new setting. Likely touchpoints include quote creation and update (e.g. src/util/functions/quote/createQuoteWithCharges.ts, src/util/functions/quote/createOrUpdateDraft.ts) and any route or aggregation that computes or returns quote total (e.g. src/routes/quote.ts). Bundle-related logic appears in src/util/functions/charge/createOrUpdateCharges.ts, src/util/functions/inspection/createInspection.ts (bundle discount amounts, and totalFromCharges around line 240), and the bundle route in src/routes/bundle.js. Document resolution and data exports that sum charges (e.g. src/util/functions/dataExports/documentResolution.ts, src/util/functions/dataExports/aggregationHelpers.ts) may need to stay consistent with the chosen totaling behavior where quote or inspection totals are used.
  • Settings / instance or company-level toggle: the codebase uses company-scoped data (_companyId on quotes, charges, inspections). A new setting (e.g. "total bundle discounts from primary" or equivalent) must be stored and read at the appropriate scope (company, brand, or instance—decision needed). Existing patterns for per-company or per-instance settings can be found in schemas such as src/models/scheduleSettingsSchema.ts and src/models/appPaymentsSettingSchema.ts; the new toggle should follow the same scope and storage approach once decided.

Frontend

  • Where quote or order totals are displayed and how they are computed (e.g. quote flows, scheduling, client-facing quote views) must align with the backend totaling behavior. Any UI that shows bundle discount or quote total may need to read the new setting and compute (or request) totals accordingly. If the toggle is configurable by the customer, a settings surface (e.g. under Services or a settings area) is in scope to expose and persist the toggle.

Decision needed

  • Scope of the toggle: per customer (company), per brand, or per instance. This determines where the setting is stored and how it is read when computing totals.

References

  • Charge and quote models: attik-backend/src/models/chargeSchema.ts, attik-backend/src/models/quoteSchema.ts
  • Quote charge creation: attik-backend/src/util/functions/quote/createQuoteWithCharges.ts, attik-backend/src/util/functions/quote/createOrUpdateDraft.ts
  • Inspection total from charges: attik-backend/src/util/functions/inspection/createInspection.ts (e.g. totalFromCharges)
  • Bundle route: attik-backend/src/routes/bundle.js (via protectedRouteBarrel.ts)
  • Example company-level settings: attik-backend/src/models/scheduleSettingsSchema.ts, attik-backend/src/models/appPaymentsSettingSchema.ts

Please authenticate to join the conversation.

Upvoters
Status

Completed

Board
💡

New Features

ETA
Mar 13, 2026
Date

18 days ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.