Refactor billing annotations to structured JSON format #453

Merged
tobru merged 7 commits from billing-annotations-change into main 2026-03-17 10:05:29 +00:00
Owner

Replace flat servala.com/erp_* annotations with two new annotations:

  • billing.servala.com/items: JSON array of billing items with productID, value, and description fields
  • billing.servala.com/salesOrderID: from Organization.odoo_sale_order_name

Product IDs can come from three sources configured per ServiceDefinition: compute_plan (ComputePlanAssignment), storage (ControlPlane), or static (inline in config). Values are extracted from K8s spec paths with automatic unit stripping and boolean-to-number coercion.

Replace flat servala.com/erp_* annotations with two new annotations: - billing.servala.com/items: JSON array of billing items with productID, value, and description fields - billing.servala.com/salesOrderID: from Organization.odoo_sale_order_name Product IDs can come from three sources configured per ServiceDefinition: `compute_plan` (ComputePlanAssignment), `storage` (ControlPlane), or `static` (inline in config). Values are extracted from K8s spec paths with automatic unit stripping and boolean-to-number coercion.
Refactor billing annotations to structured JSON format
All checks were successful
Tests / test (push) Successful in 51s
5714b83153
Replace flat servala.com/erp_* annotations with two new annotations:
- billing.servala.com/items: JSON array of billing items with productID,
  value, and description fields
- billing.servala.com/salesOrderID: from Organization.odoo_sale_order_name

Product IDs can come from three sources configured per ServiceDefinition:
compute_plan (ComputePlanAssignment), storage (ControlPlane), or static
(inline in config). Values are extracted from K8s spec paths with
automatic unit stripping and boolean-to-number coercion.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix code review findings for billing annotations
All checks were successful
Tests / test (push) Successful in 53s
bcc93c8486
- Fix bool/int isinstance ordering in _extract_billing_value (bool is
  subclass of int, so bool check must come first)
- Restore 404 handling on patch call in sync_billing_metadata to handle
  race condition where resource is deleted between fetch and patch
- Simplify getattr to direct attribute access on service_definition
- Add sync command test verifying spec data is fetched from K8s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Migrate namespace labels and annotations to use the same
billing.servala.com/ prefix as service instance annotations:
- servala.com/erp_company_id → billing.servala.com/companyPartnerID
- servala.com/erp_invoice_id → billing.servala.com/invoicePartnerID
- servala.com/erp_sale_order_id → billing.servala.com/salesOrderID
  (now uses sale order name instead of numeric ID)
- servala.com/billing → billing.servala.com/billingEntity

Consolidate duplicated namespace metadata logic from
get_or_create_namespace and sync_billing_metadata into
ControlPlane.build_namespace_metadata static method.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove deprecated annotation keys during sync_billing_metadata
All checks were successful
Tests / test (push) Successful in 52s
27b1047280
The sync command now explicitly sets old keys to null in merge patches
so Kubernetes removes them:
- Namespace labels: servala.com/erp_company_id, erp_invoice_id, erp_sale_order_id
- Namespace annotations: servala.com/billing
- Instance annotations: servala.com/erp_product_id_resource,
  erp_product_id_storage, erp_item_description, erp_item_group_description

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
renovate force-pushed billing-annotations-change from 27b1047280
All checks were successful
Tests / test (push) Successful in 52s
to 429a4c7f4c
All checks were successful
Tests / test (push) Successful in 51s
2026-03-16 15:28:02 +00:00
Compare
renovate force-pushed billing-annotations-change from 429a4c7f4c
All checks were successful
Tests / test (push) Successful in 51s
to ead5247861
All checks were successful
Tests / test (push) Successful in 53s
2026-03-17 08:02:07 +00:00
Compare
validate mandatory fields on billing config
All checks were successful
Tests / test (push) Successful in 52s
209b8e2040
tobru merged commit 719e0012f7 into main 2026-03-17 10:05:29 +00:00
tobru deleted branch billing-annotations-change 2026-03-17 10:05:29 +00:00
Sign in to join this conversation.
No description provided.