Skip to content

feat(payment_terms): REST API write and read - #6201

Open
D1353L wants to merge 2 commits into
feat-payment-terms-templates-changesfrom
feat-payment-terms-api
Open

feat(payment_terms): REST API write and read#6201
D1353L wants to merge 2 commits into
feat-payment-terms-templates-changesfrom
feat-payment-terms-api

Conversation

@D1353L

@D1353L D1353L commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Context

Earlier steps in this stack added the structured payment_term to customers and billing entities, with the net_payment_term integer as a compatibility alias. This PR exposes it via the REST API. Before this change, clients could only send the integer.

Description

Write path

  • payment_term is accepted on customer and billing entity create/update.
  • PaymentTerms::ValidateService runs in all five write services before any persistence. Invalid input returns a validation error.
  • The redundant direct net_payment_term column writes are removed. PaymentTerms::AssignService is now the only term write path.
  • A new RawPaymentTermParams controller concern copies the raw payment_term and net_payment_term values into the permitted params. Without this concern, invalid input would be dropped silently instead of returning a validation error.
  • PaymentTerms::ValidateService normalizes its input, so ActionController::Parameters and plain hashes give the same result.

Read path

  • Added payment_term to customer and billing entity serializers.
  • The invoice serializer returns the snapshotted payment_term. For invoices from before this feature, it builds {term_type: "net", days: N} from the invoice's own integer.

Stack created with GitHub Stacks CLIGive Feedback 💬

@D1353L
D1353L force-pushed the feat-payment-terms-api branch from 58a3a14 to f01ed55 Compare August 21, 2026 14:55
@D1353L
D1353L force-pushed the feat-payment-terms-api branch from f01ed55 to 32a1772 Compare August 21, 2026 16:02
@D1353L
D1353L force-pushed the feat-payment-terms-api branch from 32a1772 to 632a60d Compare August 21, 2026 16:27
@D1353L
D1353L force-pushed the feat-payment-terms-api branch from 632a60d to 28a1c2c Compare August 21, 2026 16:33
@D1353L
D1353L force-pushed the feat-payment-terms-api branch 3 times, most recently from 2484e8b to 62759f4 Compare August 25, 2026 13:09
@D1353L
D1353L force-pushed the feat-payment-terms-api branch from 62759f4 to 8b31eef Compare August 25, 2026 14:21
@D1353L
D1353L force-pushed the feat-payment-terms-api branch from 8b31eef to 411cde5 Compare August 25, 2026 14:27
@D1353L
D1353L force-pushed the feat-payment-terms-api branch from 411cde5 to 614b744 Compare August 25, 2026 14:35
@D1353L
D1353L force-pushed the feat-payment-terms-api branch 2 times, most recently from 4541299 to feceeae Compare August 26, 2026 16:24
@D1353L
D1353L force-pushed the feat-payment-terms-api branch from feceeae to 7d6f42b Compare August 26, 2026 19:38
@D1353L
D1353L marked this pull request as ready for review August 26, 2026 19:57
@lago-claude-ai-agent

Copy link
Copy Markdown
Contributor

Automated pre-review (advisory, not a required check) — verdict: HOLD · CI green

HOLD — structured payment-term support is incomplete across sibling APIs and still has invalid-input failure paths.

  • Expose payment_term on the customer and billing-entity GraphQL object/input types and cover those paths. A non-net term written through V1 currently cannot be read or edited through the sibling GraphQL API; it appears there only as net_payment_term: null.
  • Make raw-param preservation handle array-shaped wrong types recursively and add request coverage. In CustomersController, payment_term: [{term_type: "net"}] copies unpermitted nested parameters into permitted, so the subsequent to_h raises instead of returning the intended payment_term: ["invalid_format"] response.
  • Apply payment_term precedence consistently during validation. The services validate net_payment_term even when payment_term is present, so an invalid legacy alias rejects a request that AssignService documents as ignoring because the structured term wins.

@D1353L
D1353L force-pushed the feat-payment-terms-api branch from 7d6f42b to 2fbfb0f Compare August 26, 2026 20:29
@D1353L
D1353L force-pushed the feat-payment-terms-api branch from 2fbfb0f to fca7bfe Compare August 26, 2026 20:30
@lago-claude-ai-agent

Copy link
Copy Markdown
Contributor

Automated pre-review (advisory, not a required check) — verdict: HOLD · CI green

HOLD — Organizations::CreateService ignores the newly possible validation failure returned by BillingEntities::CreateService.

  • Propagate that child failure and add a regression spec proving invalid payment-term input rolls back organization/API-key creation; currently the outer service reports success and commits an organization without its default billing entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant