Skip to content

feat: add protobuf definitions for raw material cost calculations and history tracking#22

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

feat: add protobuf definitions for raw material cost calculations and history tracking#22
ilramdhan merged 1 commit intomutugading:mainfrom
ilramdhan:feat/formula-master-proto

Conversation

@ilramdhan
Copy link
Copy Markdown
Member

Description

Add protobuf definitions for raw material cost calculations and history tracking

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

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 22, 2026 04:29
@ilramdhan ilramdhan self-assigned this Apr 22, 2026
@ilramdhan ilramdhan added documentation Improvements or additions to documentation enhancement New feature or request feat labels Apr 22, 2026
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 new finance.v1 protobuf APIs to support raw material grouping and landed-cost calculation workflows, including async recalculation triggering and history tracking.

Changes:

  • Introduces RMGroupService with CRUD, item assignment/removal, ungrouped-items reporting, and import/export/template RPCs.
  • Introduces RMCostService with async trigger + synchronous admin calculation, listing/fetching costs, listing history, and period/export helpers.
  • Adds new domain enums/messages to model RM group configuration, per-stage rates, computed costs, and append-only calculation history.

Reviewed changes

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

File Description
finance/v1/rm_group.proto New RM group domain messages + RMGroupService endpoints for managing groups and memberships, plus import/export/template and reporting APIs.
finance/v1/rm_cost.proto New RM cost + history domain messages and RMCostService endpoints for recalculation trigger/calc and querying/exporting results.

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

Comment thread finance/v1/rm_group.proto
Comment on lines +653 to +657
// How to handle existing groups by `group_code`: "skip" (default) or "update".
// Detail rows always additive: items already active in ANOTHER group are
// reported as skipped errors; items already in the target group are ignored.
string duplicate_action = 3 [(buf.validate.field).string = {
in: [
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

duplicate_action is documented as defaulting to "skip", but the validation requires min_len: 1 (so callers must always supply it). Either allow empty string and treat it as "skip", or update the comment to remove the default claim and mark the field as required.

Copilot uses AI. Check for mistakes.
Comment thread finance/v1/rm_group.proto
message GetRMGroupItemRatesResponse {
// Standard response envelope.
common.v1.BaseResponse base = 1;
// Per-item rates, one row per active detail.
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The comment says this returns "one row per active detail", but RMGroupItemRates includes is_active/is_dummy flags, implying inactive/dummy rows may be included too. Please clarify whether the response includes only active details or all details.

Suggested change
// Per-item rates, one row per active detail.
// Per-item rates, one row per detail; use `is_active` and `is_dummy`
// to distinguish active/inactive and dummy rows.

Copilot uses AI. Check for mistakes.
Comment thread finance/v1/rm_group.proto
Comment on lines +3 to +7
package finance.v1;

import "buf/validate/validate.proto";
import "common/v1/common.proto";
import "finance/v1/uom.proto";
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

This new finance/v1 proto file is missing the standard header note used elsewhere ("Note: go_package is managed by buf.gen.yaml managed mode") right after the package declaration. Add it for consistency with other finance/v1 protos.

Copilot uses AI. Check for mistakes.
Comment thread finance/v1/rm_cost.proto
Comment on lines +3 to +7
package finance.v1;

import "buf/validate/validate.proto";
import "common/v1/common.proto";
import "finance/v1/rm_group.proto";
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

This new finance/v1 proto file is missing the standard header note used elsewhere ("Note: go_package is managed by buf.gen.yaml managed mode") right after the package declaration. Add it for consistency with other finance/v1 protos.

Copilot uses AI. Check for mistakes.
Comment thread finance/v1/rm_cost.proto
Comment on lines +92 to +96
RMGroupFlag flag_valuation_used = 17;
// Stage actually used after cascade / INIT resolution.
RMGroupFlag flag_marketing_used = 18;
// Stage actually used after cascade / INIT resolution.
RMGroupFlag flag_simulation_used = 19;
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

In RMCost, tag ordering is confusing: fields with tags 17–19 are declared before tag 16 (audit, declared later in the message). Reorder the field declarations to follow ascending tag order (and keep audit = 16 before any higher-numbered fields) to match other finance protos and reduce maintenance mistakes.

Copilot uses AI. Check for mistakes.
Comment thread finance/v1/rm_cost.proto
Comment on lines +377 to +381
// ListRMCostPeriods returns distinct periods from cost rows (newest first).
rpc ListRMCostPeriods(ListRMCostPeriodsRequest) returns (ListRMCostPeriodsResponse) {
option (google.api.http) = {get: "/api/v1/finance/rm-costs/periods"};
}

Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

ListRMCostPeriods references request/response types that are declared later in the file (after the service). This works, but it’s inconsistent with other finance/v1 protos where messages are declared before the service; consider moving the Periods/Export message blocks above the service for easier navigation.

Copilot uses AI. Check for mistakes.
Comment thread finance/v1/rm_group.proto
"",
"code",
"group_name",
"sort_order",
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

ListRMGroupsRequest.sort_by includes "sort_order" in the allowed values, but this is a group-head listing and RMGroupHead doesn’t expose any sort_order-like field. If unsupported server-side, clients may send an allowed value that errors or no-ops. Consider removing "sort_order" from the allowed list or documenting what it sorts by.

Suggested change
"sort_order",

Copilot uses AI. Check for mistakes.
@ilramdhan ilramdhan merged commit 7de4a5c into mutugading:main Apr 22, 2026
5 checks passed
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 feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants