Skip to content

CROSSLINK-236 action params#496

Open
adamdickmeiss wants to merge 6 commits intomainfrom
CROSSLINK-236-action-params
Open

CROSSLINK-236 action params#496
adamdickmeiss wants to merge 6 commits intomainfrom
CROSSLINK-236-action-params

Conversation

@adamdickmeiss
Copy link
Copy Markdown
Contributor

@adamdickmeiss adamdickmeiss commented Mar 27, 2026

Copilot AI review requested due to automatic review settings March 27, 2026 15:04
@adamdickmeiss adamdickmeiss changed the title Crosslink 236 action params CROSSLINK-236 action params Mar 27, 2026
Copy link
Copy Markdown
Contributor

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 support for passing lender action parameters (via EventData.CustomData) through the action service so outgoing ISO18626 SupplyingAgencyMessages can include fields like note, offeredCosts, and loanCondition.

Changes:

  • Introduces ActionParams and decodes EventData.CustomData into it in handleLenderAction.
  • Populates ISO18626 MessageInfo.Note, MessageInfo.OfferedCosts, and DeliveryInfo.LoanCondition for selected lender actions.
  • Extends tests to pass CustomData and assert the resulting ISO18626 message contents.

Reviewed changes

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

File Description
broker/patron_request/service/action.go Parses action parameters from CustomData and includes them in outgoing SupplyingAgencyMessages (note/costs/loan condition).
broker/patron_request/service/action_test.go Updates/extends lender action tests to supply CustomData and verify outgoing ISO18626 message fields.

Copy link
Copy Markdown
Contributor

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

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

Comment on lines +676 to +687
func (a *PatronRequestActionService) addConditionsLenderRequest(ctx common.ExtendedContext, pr pr_db.PatronRequest, actionParams ActionParams) actionExecutionResult {
var offeredCosts *iso18626.TypeCosts
if actionParams.Cost != nil {
if actionParams.Currency == "" {
status, result := a.logErrorAndReturnResult(ctx, "currency is required when cost is provided", nil)
return actionExecutionResult{status: status, result: result, pr: pr}
}
_, costBase, costExp := utils.ExtractDecimal(strconv.FormatFloat(*actionParams.Cost, 'f', -1, 64), -1)
offeredCosts = &iso18626.TypeCosts{
CurrencyCode: iso18626.TypeSchemeValuePair{Text: actionParams.Currency},
MonetaryValue: utils.XSDDecimal{Base: costBase, Exp: costExp},
}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

ActionParams.Cost is modeled as a float64 and then converted to an XSD decimal via FormatFloat/ExtractDecimal. Using binary floating point for money can produce surprising decimal expansions (and therefore incorrect Base/Exp) for some inputs. Consider accepting cost as a string/decimal representation (or as explicit base/exp) and converting deterministically, to avoid rounding artifacts.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment on lines +50 to +56
type ActionParams struct {
Note string `json:"note,omitempty"`
LoanCondition string `json:"loanCondition,omitempty"`
Cost *float64 `json:"cost,omitempty"`
Currency string `json:"currency,omitempty"`
ReasonUnfilled string `json:"reasonUnfilled,omitempty"`
}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

ActionParams.Cost is modeled as *float64, and later converted via FormatFloat -> ExtractDecimal. Using floating point for monetary values can introduce rounding artifacts (e.g., 12.34 may format to a longer representation), resulting in incorrect MonetaryValue being sent. Consider representing cost as a decimal-safe type in params (e.g., string/json.Number and parse, or accept base/exp directly) to preserve exact values.

Copilot uses AI. Check for mistakes.
Comment on lines +736 to +742
note := actionParams.Note + encodeItemsNote(items)
result := events.EventResult{}
status, eventResult, httpStatus := a.sendSupplyingAgencyMessage(ctx, pr, &result,
iso18626.MessageInfo{ReasonForMessage: iso18626.TypeReasonForMessageStatusChange, Note: note},
iso18626.StatusInfo{Status: iso18626.TypeStatusLoaned})
iso18626.MessageInfo{
ReasonForMessage: iso18626.TypeReasonForMessageStatusChange,
Note: note,
},
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

When composing the shipped-message note, actionParams.Note is concatenated directly with the #MultipleItems#... payload. If a human note is provided, consider inserting a delimiter (e.g., newline) before the encoded items block to keep the note readable and consistent with other code paths that prepend notes before item markers.

Copilot uses AI. Check for mistakes.
Comment on lines 692 to 696
iso18626.MessageInfo{
ReasonForMessage: iso18626.TypeReasonForMessageNotification,
Note: shim.RESHARE_ADD_LOAN_CONDITION, // TODO add action params
Note: actionParams.Note + shim.RESHARE_ADD_LOAN_CONDITION,
OfferedCosts: offeredCosts,
},
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

actionParams.Note is concatenated directly with the #ReShareAddLoanCondition# marker. If a note is provided, add a separator (space/newline) before the marker to avoid the marker being glued to the last word of the note and to keep the combined field easier to read/debug.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants