Skip to content

feat: add V2 valuation and marketing fields to RM groups and cost snapshots with new UpdateGroupItem RPC#23

Merged
ilramdhan merged 1 commit intomutugading:mainfrom
ilramdhan:feat/formula-master-proto
Apr 30, 2026
Merged

feat: add V2 valuation and marketing fields to RM groups and cost snapshots with new UpdateGroupItem RPC#23
ilramdhan merged 1 commit intomutugading:mainfrom
ilramdhan:feat/formula-master-proto

Conversation

@ilramdhan
Copy link
Copy Markdown
Member

@ilramdhan ilramdhan commented Apr 30, 2026

Description

This pull request introduces a comprehensive set of V2 enhancements to the raw material (RM) cost and group proto definitions, focusing on enabling granular control and snapshotting of cost calculation inputs and results. The changes add new enums, fields, and RPCs to support advanced cost simulation, marketing projections, and per-row overrides for both group and cost detail levels.

Change Type

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

Proto Files Changed

  • finance/v1/rm_cost.proto
  • finance/v1/rm_group.proto

Changes Made

The most important changes are:

New Enums and Fields for Valuation and Marketing Flags:

  • Added RMValuationFlag and RMMarketingFlag enums to allow explicit selection of cost valuation and marketing projection strategies at both the group and cost levels. These flags support fine-grained control over which rates or projections are used in cost calculations, with sensible AUTO/default fallbacks. [1] [2] [3] [4]

Expanded Per-Row and Per-Group Inputs:

  • Added new optional fields for marketing and valuation inputs (freight rate, anti-dumping %, duty %, transport rate, default value) to RMGroupHead, RMGroupDetail, AddItemSelection, and cost-related messages. This enables capturing and editing detailed input snapshots for each item and group, supporting more accurate and customizable cost simulations. [1] [2] [3] [4] [5] [6]

New and Updated RPCs for V2 Cost/Group Detail Management:

  • Introduced new RPCs in RMCostService for listing cost details, updating per-row marketing inputs and simulation rates, and updating fix rates on individual cost detail rows. Similarly, added a new UpdateGroupItem RPC in RMGroupService for partial updates to group detail rows, including valuation fields and sort order. [1] [2] [3]

Snapshot and Simulation Support:

  • Added RMCostDetail message to capture a full snapshot of all intermediate cost calculation columns per item/grade for each cost row, supporting detailed auditing and simulation scenarios. Also, new fields in RMCost allow storing computed group-total rates and editable simulation rates.

Clear Flags for Nullable Fields:

  • Added boolean clear flags alongside optional fields in update requests, allowing clients to explicitly reset (null out) marketing and valuation inputs as needed for both group and cost detail updates. [1] [2] [3]

These changes lay the foundation for a much more flexible and auditable RM cost calculation engine, supporting advanced simulation, auditing, and user-driven overrides at every level.

Breaking Change Check

Is this a breaking change?

  • No - buf breaking passes
  • Yes - Requires version bump

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 ilramdhan requested a review from Copilot April 30, 2026 01:33
@ilramdhan ilramdhan self-assigned this Apr 30, 2026
@ilramdhan ilramdhan added enhancement New feature or request feat labels Apr 30, 2026
Copy link
Copy Markdown
Member Author

@ilramdhan ilramdhan left a comment

Choose a reason for hiding this comment

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

Approved

@ilramdhan ilramdhan merged commit b299759 into mutugading:main Apr 30, 2026
3 checks passed
Copy link
Copy Markdown

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

Adds V2 raw-material costing/grouping capabilities to the Finance protos by introducing new valuation/marketing flags, snapshot fields, and row-level update RPCs to support more granular simulation and auditing.

Changes:

  • Added RMValuationFlag/RMMarketingFlag enums and new V2 marketing/valuation fields on RM group head/detail and related requests.
  • Introduced UpdateGroupItem RPC for partial per-detail updates (valuation inputs, sort order, active).
  • Added RMCostDetail snapshot message plus ListCostDetails, UpdateRMCostInputs, and UpdateCostDetailFixRate RPCs for cost-row/detail editing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
finance/v1/rm_group.proto Adds V2 valuation/marketing flags & inputs on groups, plus UpdateGroupItem for row-level detail updates.
finance/v1/rm_cost.proto Adds V2 cost snapshot fields & RMCostDetail, plus RPCs to list details and update per-row inputs/fix rate.

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

Comment thread finance/v1/rm_cost.proto
Comment on lines +538 to +542
// UpdateCostDetailFixRate sets fix_rate on one detail row.
message UpdateCostDetailFixRateRequest {
string cost_detail_id = 1 [(buf.validate.field).string.uuid = true];
// Empty/0 clears the fix override (FL chain → 0).
optional double fix_rate = 2 [(buf.validate.field).double.gte = 0];
Comment thread finance/v1/rm_group.proto
Comment on lines +37 to +59
// RMValuationFlag selects which computed rate becomes `cost_val` in the
// RM Cost row. UNSPECIFIED behaves as AUTO (CL → SL → FL fallback, where
// FL incorporates the per-detail valuation_default_value).
enum RMValuationFlag {
// Default zero value. Treated as AUTO (CL→SL→FL fallback).
RM_VALUATION_FLAG_UNSPECIFIED = 0;
// Use Consumption Rate (CR) — group-total cons_val / cons_qty.
RM_VALUATION_FLAG_CR = 1;
// Use Stock Rate (SR) — group-total stock_val / stock_qty.
RM_VALUATION_FLAG_SR = 2;
// Use PO Rate (PR) — group-total po_val / po_qty.
RM_VALUATION_FLAG_PR = 3;
// Use Consumption Landed Cost (CL) — group-total CL aggregate.
RM_VALUATION_FLAG_CL = 4;
// Use Stock Landed Cost (SL) — group-total SL aggregate.
RM_VALUATION_FLAG_SL = 5;
// Use Fix Landed Cost (FL) — MAX of per-detail FL.
RM_VALUATION_FLAG_FL = 6;
}

// RMMarketingFlag selects which computed marketing projection becomes
// `cost_mark`. UNSPECIFIED behaves as AUTO (SP → PP → FP fallback).
enum RMMarketingFlag {
Comment thread finance/v1/rm_group.proto
Comment on lines +273 to 276
// Cost percentage multiplier (>= 0). Aliased as Marketing Duty %.
double cost_percentage = 6 [(buf.validate.field).double.gte = 0];
// Per-kg overhead (>= 0).
// Per-kg overhead (>= 0). Aliased as Marketing Transport Rate.
double cost_per_kg = 7 [(buf.validate.field).double.gte = 0];
Comment thread finance/v1/rm_group.proto
Comment on lines +467 to +468
optional double valuation_freight_rate = 3 [(buf.validate.field).double.gte = 0];
optional double valuation_anti_dumping_pct = 4 [(buf.validate.field).double.gte = 0];
Comment thread finance/v1/rm_cost.proto
Comment on lines +476 to +477
// in-place recompute of SP/PP/FP/cost_mark and cost_sim from stored snapshots.
// No full pipeline recalc required.
Comment thread finance/v1/rm_cost.proto
Comment on lines +127 to +131
// V2: RMCostDetail is one row per (cost_id, item_code, grade_code) — full
// snapshot of intermediate columns from the Excel reference (rows 9–11).
message RMCostDetail {
string cost_detail_id = 1;
string cost_id = 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants