mece request / payment economics
This commit is contained in:
@@ -37,7 +37,7 @@ func ensureComputedQuote(src *ComputedQuote, item *QuoteComputationPlanItem) *Co
|
||||
src.ResolvedFeeTreatment = item.ResolvedFeeTreatment
|
||||
}
|
||||
if src.ResolvedFeeTreatment == quotationv2.FeeTreatment_FEE_TREATMENT_UNSPECIFIED {
|
||||
src.ResolvedFeeTreatment = resolvedFeeTreatmentForSettlementMode(src.ResolvedSettlementMode)
|
||||
src.ResolvedFeeTreatment = defaultResolvedFeeTreatment()
|
||||
}
|
||||
return src
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package quote_computation_service
|
||||
|
||||
import (
|
||||
"github.com/tech/sendico/payments/storage/model"
|
||||
payecon "github.com/tech/sendico/pkg/payments/economics"
|
||||
paymentv1 "github.com/tech/sendico/pkg/proto/common/payment/v1"
|
||||
quotationv2 "github.com/tech/sendico/pkg/proto/payments/quotation/v2"
|
||||
)
|
||||
@@ -17,11 +18,6 @@ func resolvedSettlementModeFromModel(mode model.SettlementMode) paymentv1.Settle
|
||||
}
|
||||
}
|
||||
|
||||
func resolvedFeeTreatmentForSettlementMode(mode paymentv1.SettlementMode) quotationv2.FeeTreatment {
|
||||
switch mode {
|
||||
case paymentv1.SettlementMode_SETTLEMENT_FIX_RECEIVED:
|
||||
return quotationv2.FeeTreatment_FEE_TREATMENT_DEDUCT_FROM_DESTINATION
|
||||
default:
|
||||
return quotationv2.FeeTreatment_FEE_TREATMENT_ADD_TO_SOURCE
|
||||
}
|
||||
func defaultResolvedFeeTreatment() quotationv2.FeeTreatment {
|
||||
return payecon.DefaultFeeTreatment()
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/tech/sendico/payments/quotation/internal/service/quotation/transfer_intent_hydrator"
|
||||
"github.com/tech/sendico/payments/storage/model"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
payecon "github.com/tech/sendico/pkg/payments/economics"
|
||||
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
|
||||
quotationv2 "github.com/tech/sendico/pkg/proto/payments/quotation/v2"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
@@ -256,7 +257,7 @@ func (s *QuoteComputationService) buildPlanItem(
|
||||
ExecutionConditions: cloneExecutionConditions(conditions),
|
||||
}
|
||||
resolvedSettlementMode := resolvedSettlementModeFromModel(modelIntent.SettlementMode)
|
||||
resolvedFeeTreatment := resolvedFeeTreatmentForSettlementMode(resolvedSettlementMode)
|
||||
resolvedFeeTreatment := resolvedFeeTreatmentFromHydratedIntent(intent)
|
||||
|
||||
intentRef := strings.TrimSpace(modelIntent.Ref)
|
||||
if intentRef == "" {
|
||||
@@ -288,6 +289,13 @@ func (s *QuoteComputationService) buildPlanItem(
|
||||
}, nil
|
||||
}
|
||||
|
||||
func resolvedFeeTreatmentFromHydratedIntent(intent *transfer_intent_hydrator.QuoteIntent) quotationv2.FeeTreatment {
|
||||
if intent == nil {
|
||||
return defaultResolvedFeeTreatment()
|
||||
}
|
||||
return payecon.ResolveFeeTreatmentFromStringOrDefault(string(intent.FeeTreatment))
|
||||
}
|
||||
|
||||
func deriveItemIdempotencyKey(base string, total, index int) string {
|
||||
base = strings.TrimSpace(base)
|
||||
if base == "" {
|
||||
|
||||
Reference in New Issue
Block a user