complete MECE request

This commit is contained in:
Stephan D
2026-02-24 18:33:12 +01:00
parent 4c5677202a
commit a998b59072
34 changed files with 957 additions and 156 deletions

View File

@@ -6,7 +6,6 @@ import (
"github.com/tech/sendico/payments/storage/model"
pkgmodel "github.com/tech/sendico/pkg/model"
payecon "github.com/tech/sendico/pkg/payments/economics"
paymentv1 "github.com/tech/sendico/pkg/proto/common/payment/v1"
endpointv1 "github.com/tech/sendico/pkg/proto/payments/endpoint/v1"
quotationv2 "github.com/tech/sendico/pkg/proto/payments/quotation/v2"
@@ -29,10 +28,7 @@ func mapIntentSnapshot(src model.PaymentIntent) (*quotationv2.QuoteIntent, error
}
settlementMode := settlementModeToProto(src.SettlementMode)
feeTreatment := payecon.DefaultFeeTreatment()
if len(src.Attributes) > 0 {
feeTreatment = payecon.ResolveFeeTreatmentFromStringOrDefault(src.Attributes["fee_treatment"])
}
feeTreatment := feeTreatmentToProto(src.FeeTreatment)
return &quotationv2.QuoteIntent{
Source: source,
Destination: destination,
@@ -191,6 +187,17 @@ func settlementModeToProto(mode model.SettlementMode) paymentv1.SettlementMode {
}
}
func feeTreatmentToProto(value model.FeeTreatment) quotationv2.FeeTreatment {
switch value {
case model.FeeTreatmentDeductFromDestination:
return quotationv2.FeeTreatment_FEE_TREATMENT_DEDUCT_FROM_DESTINATION
case model.FeeTreatmentAddToSource:
return quotationv2.FeeTreatment_FEE_TREATMENT_ADD_TO_SOURCE
default:
return quotationv2.FeeTreatment_FEE_TREATMENT_ADD_TO_SOURCE
}
}
func uintToString(value uint32) string {
if value == 0 {
return ""

View File

@@ -239,10 +239,10 @@ func newPaymentFixture() *agg.Payment {
Currency: "USDT",
},
SettlementMode: model.SettlementModeFixSource,
FeeTreatment: model.FeeTreatmentDeductFromDestination,
SettlementCurrency: "USD",
Attributes: map[string]string{
"comment": "invoice-7",
"fee_treatment": "deduct_from_destination",
"comment": "invoice-7",
},
},
QuoteSnapshot: &model.PaymentQuoteSnapshot{