Skip to content

Conversation

ansmonjol
Copy link
Collaborator

@ansmonjol ansmonjol commented Jun 24, 2025

Context

CPU stands for Custom Pricing Units.

We recently added the possibility to add a custom pricing unit in the app's settings (hidden via a FE Feature Flag) #2275

We're moving forward with this feature by introducing those CPU deeper in the codebase.

Description

This PR allow to setup a CPU at the plan level.

This new CPU, once selected on a charge, is called appliedPricingUnit.

When sent to the BE it only contains code, conversionRate. However when manipulated in the app we add extra arguments (at form init or when adding a new charge to the formikProps).
Those arguments helps us determining some internal logic for display and data formatting.

Attribute name Type Notes
shortName string: any The value displayed in the forms and details (later invoices and usage). It's given by BE but not something we send at charge level
type string: 'custom' OR 'fiat' Used to understand if the charge currency is custom or not. If not, we clean it from the payloads

The 3rd commit could be hard to review but it's mostly display adjustments. All logic stands in the first 2 ones.

Happy to help for the review in any ways!

Fixes LAGO-882

@ansmonjol ansmonjol self-assigned this Jun 24, 2025
@ansmonjol ansmonjol added the 🛠 feature New feature or request label Jun 24, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates Custom Pricing Units (CPU) at the plan level by introducing an appliedPricingUnit that is used for both form initialization and charge serialization/display.

  • Introduces CPU handling at the plan and charge levels.
  • Updates validations, serialization logic, and UI components to support pricing unit properties.
  • Adds a new hook to fetch custom pricing units and updates related translations and tests.

Reviewed Changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
translations/base.json Updates translation texts and adds a max-length note for pricing unit short name.
src/pages/settings/Invoices/CreatePricingUnit.tsx Enhances form validation with a maximum length for shortName and adds an info alert.
src/pages/CreatePlan.tsx Modifies GraphQL query to include appliedPricingUnit details.
src/hooks/plans/usePlanForm.tsx Incorporates appliedPricingUnit handling in forming plan values.
src/hooks/plans/useCustomPricingUnits.tsx Introduces a new hook to load custom pricing units.
src/formValidation/chargeSchema.ts Updates Yup schema to validate the appliedPricingUnit fields.
src/core/serializers/serializePlanInput.ts Adjusts serialization logic to conditionally include appliedPricingUnit data.
Other components Modify UI components (e.g., charge tables, details sections, and input components) to display pricing unit information.
Comments suppressed due to low confidence (1)

translations/base.json:3215

  • Typo in translation text: 'shouls' should be corrected to 'should'.
  "text_1750424999815o2wik8216ht": "This value shouls have a maximum length of 3 characters"

Copy link
Collaborator

@stephenlago99 stephenlago99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ansmonjol ansmonjol force-pushed the custom-pricing-plan branch 2 times, most recently from 6058584 to 1c0113f Compare June 24, 2025 15:09
@ansmonjol ansmonjol force-pushed the custom-pricing-plan branch from 4cb2cdb to d6901e5 Compare June 25, 2025 09:33
@ansmonjol ansmonjol merged commit e03d9f7 into main Jun 25, 2025
4 checks passed
@ansmonjol ansmonjol deleted the custom-pricing-plan branch June 25, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠 feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants