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 Apr 30, 2026
Conversation
…pshots with new UpdateGroupItem RPC
There was a problem hiding this comment.
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/RMMarketingFlagenums and new V2 marketing/valuation fields on RM group head/detail and related requests. - Introduced
UpdateGroupItemRPC for partial per-detail updates (valuation inputs, sort order, active). - Added
RMCostDetailsnapshot message plusListCostDetails,UpdateRMCostInputs, andUpdateCostDetailFixRateRPCs 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 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 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 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 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 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 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Proto Files Changed
finance/v1/rm_cost.protofinance/v1/rm_group.protoChanges Made
The most important changes are:
New Enums and Fields for Valuation and Marketing Flags:
RMValuationFlagandRMMarketingFlagenums 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:
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:
RMCostServicefor listing cost details, updating per-row marketing inputs and simulation rates, and updating fix rates on individual cost detail rows. Similarly, added a newUpdateGroupItemRPC inRMGroupServicefor partial updates to group detail rows, including valuation fields and sort order. [1] [2] [3]Snapshot and Simulation Support:
RMCostDetailmessage 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 inRMCostallow storing computed group-total rates and editable simulation rates.Clear Flags for Nullable Fields:
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?
buf breakingpassesPre-merge Checklist
buf format -wappliedbuf lintpassesbuf breakingpassesImpact Assessment