Skip to content

feat(product-cost): Add Product and Cost Calculation services with RPCs#28

Merged
ilramdhan merged 7 commits into
mutugading:mainfrom
ilramdhan:feat/product-costing-phase-1
May 26, 2026
Merged

feat(product-cost): Add Product and Cost Calculation services with RPCs#28
ilramdhan merged 7 commits into
mutugading:mainfrom
ilramdhan:feat/product-costing-phase-1

Conversation

@ilramdhan

Copy link
Copy Markdown
Member

Description

This pull request introduces several new proto files and updates the code generation setup for the finance service, adding major new API surfaces for cost management features. The most important changes are the introduction of proto definitions for cost product master data, ERP lookups, audit logging, notification management, file attachments, and related lookups, as well as switching code generation plugins from remote to local binaries for improved reliability.

Change Type

  • ✨ New service/message
  • ➕ Add field/RPC/enum value
  • 🔄 Modify validation
  • 📝 Documentation update
  • ⚠️ Deprecation
  • 🔧 Config/script changes

Proto Files Changed

  • finance/v1/cost_calc.proto
  • finance/v1/cost_product_request.proto
  • finance/v1/cost_attachment.proto
  • finance/v1/cost_audit_log.proto
  • finance/v1/cost_erp.proto
  • finance/v1/cost_notification.proto
  • finance/v1/cost_paper_tube_type.proto
  • finance/v1/cost_product_master.proto
  • finance/v1/cost_product_parameter.proto
  • finance/v1/cost_product_type.proto
  • finance/v1/cost_request_comment.proto
  • finance/v1/cost_request_type.proto
  • finance/v1/cost_rm_type.proto
  • finance/v1/cost_route.proto
  • finance/v1/cost_routing_rule.proto
  • finance/v1/parameter.proto
  • finance/v1/product.proto (deletion)
  • finance/v1/product_request.proto (deletion)
  • iam/v1/auth.proto/auth.proto
  • iam/v1/auth.proto/company_mapping.proto
  • iam/v1/auth.proto/user.proto
  • iam/v1/auth.proto/workflow.proto

Changes Made

Proto API Additions

  • Added cost_product_master.proto defining the CostProductMaster entity and a full CRUD+list API, supporting creation, update, ERP linkage, deactivation, and rich filtering for product master records.
  • Added cost_erp.proto providing read-only, paginated lookup APIs for ERP master data (items, grades, shades) to facilitate integration and autocomplete features.
  • Added cost_audit_log.proto introducing an append-only audit log entity and a read-only API for querying audit events related to cost entities.
  • Added cost_notification.proto defining entities and APIs for in-app notifications, unread counts, and marking notifications as read, supporting user notification workflows.
  • Added cost_attachment.proto providing file attachment support for requests and comments, including upload, listing, download URL generation, and deletion.
  • Added cost_paper_tube_type.proto for listing paper tube type lookups used in product specifications.

Build System Improvements

  • Updated buf.gen.yaml to use local code generation plugins (protoc-gen-go, protoc-gen-go-grpc, etc.) instead of remote plugins, improving reliability and removing runtime dependency on the Buf Schema Registry.

Pre-merge Checklist

  • I have read and followed RULES.md
  • buf format -w applied
  • buf lint passes
  • buf breaking passes
  • Comments document new messages/fields
  • REST mappings follow conventions
  • Validation rules are complete
  • Field numbers are logical

Impact Assessment

  • Backend code regeneration required
  • Frontend code regeneration required
  • OpenAPI spec regeneration required

ilramdhan and others added 7 commits May 9, 2026 11:13
Defines ProductService (7 RPCs: CRUD + Duplicate + ListByRequest) and
ProductRequestService (9 RPCs: CRUD + Assign + Resolve + Reject + SearchExistingProducts)
with full buf.validate annotations and gRPC-Gateway HTTP annotations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Defines 11 RPCs covering calc job lifecycle (trigger/get/list/chunks/products/cancel)
and cost result access (get/breakdown/history/verify/approve) plus 6 enums and core
entity messages (CalJob, CalJobChunk, CalJobProduct, CostResult, CostBreakdown,
LevelBreakdown, CostRMDetail, FormulaEval, CostHistoryEntry). Renamed RMCostDetail
to CostRMDetail to avoid collision with rm_cost.proto.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
New internal RPC on CostCalcService that delegates to existing
app.Service.ProcessChunk. No REST gateway path -- service-to-service
only. Gated by finance.cost.caljob.trigger permission.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors Revise: POST /api/v1/finance/cost-product-requests/{id}/reopen.
Lets an admin move a terminal CLOSED request back to DRAFT to re-enter
the lifecycle.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…eriod default)

GET /api/v1/finance/cost-results — lists active cost results across
products for a period (empty period resolves to the latest present),
with optional calc-type / status / product-search filters. Response
carries resolved product code/name/uom so the UI shows no UUIDs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ilramdhan ilramdhan self-assigned this May 25, 2026
Copilot AI review requested due to automatic review settings May 25, 2026 03:01
@ilramdhan ilramdhan added documentation Improvements or additions to documentation enhancement New feature or request fix labels May 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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 significantly expands the shared proto API surface for Finance product costing (requests, routing, masters, ERP lookups, parameters, notifications, attachments, audit logs, and cost calculation) and extends IAM with workflow and company-mapping capabilities. It also updates Buf codegen to use local plugin binaries for improved reliability.

Changes:

  • Added many new finance.v1 cost-related entities and CRUD/lookup/state-transition services (including a large CostCalcService API).
  • Added IAM workflow template/instance services and user ↔ company-mapping assignment RPCs/fields.
  • Switched buf.gen.yaml from remote BSR plugins to local protoc-gen-* binaries.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
buf.gen.yaml Switches Buf generation plugins from remote to local binaries.
finance/v1/cost_attachment.proto Adds attachment entity + upload/list/download-url/delete RPCs for requests/comments.
finance/v1/cost_audit_log.proto Adds read-only audit log listing API for cost-domain entities.
finance/v1/cost_calc.proto Adds cost calculation job orchestration API, results, breakdowns, and internal worker RPC.
finance/v1/cost_erp.proto Adds read-only paginated ERP replica lookup APIs (items/grades/shades).
finance/v1/cost_notification.proto Adds in-app notification listing/unread-count/mark-read APIs.
finance/v1/cost_paper_tube_type.proto Adds read-only lookup API for paper tube types.
finance/v1/cost_product_master.proto Adds cost-system product master CRUD/list + ERP linkage update RPC.
finance/v1/cost_product_parameter.proto Adds per-product parameter value upsert/batch upsert/delete + applicability APIs.
finance/v1/cost_product_request.proto Adds cost product request entity, CRUD/list, and state-transition RPCs.
finance/v1/cost_product_type.proto Adds CRUD/list API for cost product type master.
finance/v1/cost_request_comment.proto Adds request comment thread CRUD + hide/unhide + edit-history APIs.
finance/v1/cost_request_type.proto Adds read-only lookup API for request types.
finance/v1/cost_rm_type.proto Adds CRUD/list API for cost RM type master.
finance/v1/cost_route.proto Adds route head/graph APIs plus duplicate/link/create-from-product operations.
finance/v1/cost_routing_rule.proto Adds CRUD/list API for routing rule engine (condition/action).
finance/v1/parameter.proto Extends parameter entity and create/update requests with costing ownership/display fields.
iam/v1/auth.proto Extends AuthUser with section/department identifiers.
iam/v1/company_mapping.proto Adds company-mapping master CRUD/list API for org hierarchy mapping.
iam/v1/user.proto Adds user company-mapping assignment RPCs and new user/master-detail fields.
iam/v1/workflow.proto Adds workflow template CRUD/versioning + runtime workflow instance APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread iam/v1/user.proto
optional bool is_active = 4;
// Unlock account (optional).
optional bool unlock_account = 5;
// Employee level ID (optional, UUID; clears when omitted from request body).
Comment thread iam/v1/workflow.proto
Comment on lines +349 to +359
message ListWorkflowInstancesRequest {
string entity_kind = 1 [(buf.validate.field).string = {
in: [
"",
"PRD_REQUEST",
"CST_PRODUCT",
"PARAM_FILL"
]
}];
string entity_id = 2;
string status = 3 [(buf.validate.field).string = {
Comment thread iam/v1/workflow.proto
max_len: 200
}];
string description = 3 [(buf.validate.field).string = {max_len: 1000}];
repeated WorkflowTemplateStepInput steps = 4 [(buf.validate.field).repeated.min_items = 1];
Comment on lines +33 to +35
// Exactly one of (request_id, comment_id) must be > 0.
int64 request_id = 1;
int64 comment_id = 2;
Comment on lines +89 to +95
// Value as string (decimals as text for precision). One of these must be set.
string value_numeric = 3;
string value_text = 4;
// value_flag is a real bool — we cannot distinguish "unset" from FALSE, so
// callers must use has_value_flag to opt in.
bool value_flag = 5;
bool has_value_flag = 6;

message UpsertProductParamValuesBatchRequest {
int64 product_sys_id = 1 [(buf.validate.field).int64.gt = 0];
repeated UpsertProductParamValueRequest values = 2 [(buf.validate.field).repeated.min_items = 1];
Comment on lines +108 to +109
// CalJob represents a calculation job batch.
message CalJob {
// Pagination params.
common.v1.PaginationRequest pagination = 1;
// Optional period filter (YYYYMM).
string period = 2;
Comment on lines +621 to +622
// Product sys ids to compute; at least one required.
repeated int64 product_ids = 5 [(buf.validate.field).repeated.min_items = 1];
string uom_code = 22;
// Resolved UOM name (read-only, populated from mst_uom join).
string uom_name = 23;
// Responsible department (Engineering, Production, Finance, RND). Optional.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request fix

Projects

Status: Done

2 participants