fee treatment added

This commit is contained in:
Stephan D
2026-02-24 16:39:08 +01:00
parent 2fe90347a8
commit 2e08ec9b9b
17 changed files with 162 additions and 30 deletions

View File

@@ -0,0 +1,24 @@
import 'package:pshared/data/dto/payment/fee_line.dart';
import 'package:pshared/data/mapper/money.dart';
import 'package:pshared/models/payment/fees/line.dart';
extension FeeLineDTOMapper on FeeLineDTO {
FeeLine toDomain() => FeeLine(
ledgerAccountRef: ledgerAccountRef,
amount: amount?.toDomain(),
lineType: lineType,
side: side,
meta: meta,
);
}
extension FeeLineMapper on FeeLine {
FeeLineDTO toDTO() => FeeLineDTO(
ledgerAccountRef: ledgerAccountRef,
amount: amount?.toDTO(),
lineType: lineType,
side: side,
meta: meta,
);
}

View File

@@ -0,0 +1,26 @@
import 'package:pshared/models/payment/fees/treatment.dart';
FeeTreatment feeTreatmentFromValue(String? value) {
switch (value) {
case 'add_to_source':
return FeeTreatment.addToSource;
case 'deduct_from_destination':
return FeeTreatment.deductFromDestination;
case 'unspecified':
return FeeTreatment.unspecified;
default:
throw ArgumentError('Unknown FeeTreatment value: $value');
}
}
String feeTreatmentToValue(FeeTreatment value) {
switch (value) {
case FeeTreatment.addToSource:
return 'add_to_source';
case FeeTreatment.deductFromDestination:
return 'deduct_from_destination';
case FeeTreatment.unspecified:
return 'unspecified';
}
}