11package software .xdev .bzst .dip .client .model .message .cesop ;
22
3+ import java .util .ArrayList ;
34import java .util .GregorianCalendar ;
5+ import java .util .List ;
46
57import javax .xml .datatype .DatatypeConfigurationException ;
68import javax .xml .datatype .DatatypeFactory ;
3234import software .xdev .bzst .dip .client .xmldocument .model .cesop .TransactionDateTypeType ;
3335import software .xdev .bzst .dip .client .xmldocument .model .cesop .VATIdType ;
3436
35- // TODO: Das in Methoden auslagern, für bessere Lesbarkeit
36-
3737
3838/**
3939 * @param reportingPSP The reportingPSP element clearly defines the payment service provider that reports the payment
4040 * data to the national tax administration. {@link BzstCesopReportingPSP}
4141 * @param reportedPayee defines the payee to whom the data transmitted by the payment service provider
4242 */
43- public record BzstCesopPaymentDataBody (BzstCesopReportingPSP reportingPSP , BzstCesopReportedPayee reportedPayee )
43+ public record BzstCesopPaymentDataBody (BzstCesopReportingPSP reportingPSP , List < BzstCesopReportedPayee > reportedPayees )
4444{
4545 public PaymentDataBodyType toXmlType () throws DatatypeConfigurationException
4646 {
4747 final PaymentDataBodyType paymentDataBodyType = new PaymentDataBodyType ();
4848
49+ paymentDataBodyType .setReportingPSP (this .convertToPSPType ());
50+
51+ this .convertToReportedPayeesType ();
52+ for (final ReportedPayeeType reportedPayeeType : this .convertToReportedPayeesType ())
53+ {
54+ paymentDataBodyType .getReportedPayee ().add (reportedPayeeType );
55+ }
56+
57+ return paymentDataBodyType ;
58+ }
59+
60+ private List <ReportedPayeeType > convertToReportedPayeesType () throws DatatypeConfigurationException
61+ {
62+ final List <ReportedPayeeType > reportedPayeeTypes = new ArrayList <>();
63+ for (final BzstCesopReportedPayee reportedPayee : this .reportedPayees )
64+ {
65+ final ReportedPayeeType reportedPayeeType = new ReportedPayeeType ();
66+
67+ final NameType nameTypeReportedPayeeType = new NameType ();
68+ final DocSpecType docSpecType = new DocSpecType ();
69+ final AccountIdentifierType accountIdentifierType = new AccountIdentifierType ();
70+ final TAXIdentifierType taxIdentifierType = new TAXIdentifierType ();
71+ final VATIdType vatIdType = new VATIdType ();
72+ final ReportedTransactionType reportedTransactionType = new ReportedTransactionType ();
73+ final AmountType amountType = new AmountType ();
74+ final PaymentMethodType paymentMethodType = new PaymentMethodType ();
75+ final PayerMSType payerMSType = new PayerMSType ();
76+ final PSPRoleType pspRoleType = new PSPRoleType ();
77+ final TransactionDateType transactionDateType = new TransactionDateType ();
78+
79+ nameTypeReportedPayeeType .setValue (reportedPayee .name ().value ());
80+ nameTypeReportedPayeeType .setNameType (NameTypeEnumType .fromValue (reportedPayee .name ()
81+ .nameType ()
82+ .value ()));
83+ docSpecType .setDocTypeIndic (DocTypeIndicEnumType .fromValue (reportedPayee .docSpec ()
84+ .docTypeIndicEnum ()
85+ .value ()));
86+ docSpecType .setDocRefId (reportedPayee .docSpec ().docRefId ().toString ());
87+ accountIdentifierType .setType (AccountIdentifierTypeType .fromValue (reportedPayee .accountIdentifier ()
88+ .accountIdentifierType ()
89+ .value ()));
90+ accountIdentifierType .setValue (reportedPayee .accountIdentifier ().value ());
91+ accountIdentifierType .setCountryCode (CountryCodeType .fromValue (reportedPayee .countryCode ().name ()));
92+ vatIdType .setValue (reportedPayee .taxIdentification ().vatId ().value ());
93+ vatIdType .setIssuedBy (MSCountryCodeType .fromValue (reportedPayee .taxIdentification ()
94+ .vatId ()
95+ .msCountryCodeTypeEnum ()
96+ .value ()));
97+ taxIdentifierType .getVATId ().add (vatIdType );
98+ amountType .setValue (reportedPayee .reportedTransaction ().amount ().amountValue ());
99+ amountType .setCurrency (CurrCodeType .fromValue (reportedPayee .reportedTransaction ()
100+ .amount ()
101+ .currency ()
102+ .name ()));
103+ reportedTransactionType .setAmount (amountType );
104+ reportedTransactionType .setTransactionIdentifier (reportedPayee .reportedTransaction ()
105+ .transactionIdentifier ());
106+ paymentMethodType .setPaymentMethodType (PaymentMethodTypeType .valueOf (reportedPayee .reportedTransaction ()
107+ .paymentMethod ()
108+ .paymentMethodEnum ()
109+ .value ()));
110+ payerMSType .setPayerMSSource (AccountIdentifierTypeType .valueOf (reportedPayee .reportedTransaction ()
111+ .payerMS ()
112+ .accountIdentifierType ()
113+ .value ()));
114+ payerMSType .setValue (MSCountryCodeType .valueOf (reportedPayee .reportedTransaction ()
115+ .payerMS ()
116+ .msCountryCodeType ()
117+ .value ()));
118+ pspRoleType .setPSPRoleType (PSPRoleTypeType .valueOf (reportedPayee .reportedTransaction ()
119+ .pspRole ()
120+ .pspRoleType ()
121+ .value ()));
122+ reportedTransactionType .setPaymentMethod (paymentMethodType );
123+ reportedTransactionType .setIsRefund (reportedPayee .reportedTransaction ().isRefund ());
124+ reportedTransactionType .setPayerMS (payerMSType );
125+ reportedTransactionType .setPSPRole (pspRoleType );
126+ reportedTransactionType .setInitiatedAtPhysicalPremisesOfMerchant (reportedPayee .reportedTransaction ()
127+ .initiatedAtPhysicalPremisesOfMerchant ());
128+
129+ final GregorianCalendar gregorianCalendar =
130+ GregorianCalendar .from (reportedPayee .reportedTransaction ().transactionDateType ().value ());
131+ final XMLGregorianCalendar xmlGregorianCalendar =
132+ DatatypeFactory .newInstance ().newXMLGregorianCalendar (gregorianCalendar );
133+
134+ transactionDateType .setValue (xmlGregorianCalendar );
135+ transactionDateType .setTransactionDateType (TransactionDateTypeType .valueOf (reportedPayee .reportedTransaction ()
136+ .transactionDateType ()
137+ .transactionDateTypeEnum ()
138+ .value ()));
139+ reportedTransactionType .getDateTime ().add (transactionDateType );
140+
141+ reportedPayeeType .getName ().add (nameTypeReportedPayeeType );
142+ reportedPayeeType .setCountry (CountryCodeType .fromValue (reportedPayee .countryCode ().name ()));
143+ reportedPayeeType .setDocSpec (docSpecType );
144+ reportedPayeeType .setAccountIdentifier (accountIdentifierType );
145+ reportedPayeeType .setTAXIdentification (taxIdentifierType );
146+ reportedPayeeType .getReportedTransaction ().add (reportedTransactionType );
147+ reportedPayeeTypes .add (reportedPayeeType );
148+ }
149+ return reportedPayeeTypes ;
150+ }
151+
152+ private PSPType convertToPSPType ()
153+ {
49154 final PSPType pspType = new PSPType ();
50155 final PSPIdType pspIdType = new PSPIdType ();
51156 final NameType nameType = new NameType ();
@@ -56,92 +161,6 @@ public PaymentDataBodyType toXmlType() throws DatatypeConfigurationException
56161 nameType .setValue (this .reportingPSP .name ().value ());
57162 pspType .setPSPId (pspIdType );
58163 pspType .getName ().add (nameType );
59-
60- paymentDataBodyType .setReportingPSP (pspType );
61-
62- final ReportedPayeeType reportedPayeeType = new ReportedPayeeType ();
63-
64- final NameType nameTypeReportedPayeeType = new NameType ();
65- final DocSpecType docSpecType = new DocSpecType ();
66- final AccountIdentifierType accountIdentifierType = new AccountIdentifierType ();
67- final TAXIdentifierType taxIdentifierType = new TAXIdentifierType ();
68- final VATIdType vatIdType = new VATIdType ();
69- final ReportedTransactionType reportedTransactionType = new ReportedTransactionType ();
70- final AmountType amountType = new AmountType ();
71- final PaymentMethodType paymentMethodType = new PaymentMethodType ();
72- final PayerMSType payerMSType = new PayerMSType ();
73- final PSPRoleType pspRoleType = new PSPRoleType ();
74- final TransactionDateType transactionDateType = new TransactionDateType ();
75-
76- nameTypeReportedPayeeType .setValue (this .reportedPayee .name ().value ());
77- nameTypeReportedPayeeType .setNameType (NameTypeEnumType .fromValue (this .reportedPayee .name ().nameType ().value ()));
78- docSpecType .setDocTypeIndic (DocTypeIndicEnumType .fromValue (this .reportedPayee .docSpec ()
79- .docTypeIndicEnum ()
80- .value ()));
81- docSpecType .setDocRefId (this .reportedPayee .docSpec ().docRefId ().toString ());
82- accountIdentifierType .setType (AccountIdentifierTypeType .fromValue (this .reportedPayee .accountIdentifier ()
83- .accountIdentifierType ()
84- .value ()));
85- accountIdentifierType .setValue (this .reportedPayee .accountIdentifier ().value ());
86- accountIdentifierType .setCountryCode (CountryCodeType .fromValue (this .reportedPayee .countryCode ().name ()));
87- vatIdType .setValue (this .reportedPayee .taxIdentification ().vatId ().value ());
88- vatIdType .setIssuedBy (MSCountryCodeType .fromValue (this .reportedPayee .taxIdentification ()
89- .vatId ()
90- .msCountryCodeTypeEnum ()
91- .value ()));
92- taxIdentifierType .getVATId ().add (vatIdType );
93- amountType .setValue (this .reportedPayee .reportedTransaction ().amount ().amountValue ());
94- amountType .setCurrency (CurrCodeType .fromValue (this .reportedPayee .reportedTransaction ()
95- .amount ()
96- .currency ()
97- .name ()));
98- reportedTransactionType .setAmount (amountType );
99- reportedTransactionType .setTransactionIdentifier (this .reportedPayee .reportedTransaction ()
100- .transactionIdentifier ());
101- paymentMethodType .setPaymentMethodType (PaymentMethodTypeType .valueOf (this .reportedPayee .reportedTransaction ()
102- .paymentMethod ()
103- .paymentMethodEnum ()
104- .value ()));
105- payerMSType .setPayerMSSource (AccountIdentifierTypeType .valueOf (this .reportedPayee .reportedTransaction ()
106- .payerMS ()
107- .accountIdentifierType ()
108- .value ()));
109- payerMSType .setValue (MSCountryCodeType .valueOf (this .reportedPayee .reportedTransaction ()
110- .payerMS ()
111- .msCountryCodeType ()
112- .value ()));
113- pspRoleType .setPSPRoleType (PSPRoleTypeType .valueOf (this .reportedPayee .reportedTransaction ()
114- .pspRole ()
115- .pspRoleType ()
116- .value ()));
117- reportedTransactionType .setPaymentMethod (paymentMethodType );
118- reportedTransactionType .setIsRefund (this .reportedPayee .reportedTransaction ().isRefund ());
119- reportedTransactionType .setPayerMS (payerMSType );
120- reportedTransactionType .setPSPRole (pspRoleType );
121- reportedTransactionType .setInitiatedAtPhysicalPremisesOfMerchant (this .reportedPayee .reportedTransaction ()
122- .initiatedAtPhysicalPremisesOfMerchant ());
123-
124- final GregorianCalendar gregorianCalendar =
125- GregorianCalendar .from (this .reportedPayee .reportedTransaction ().transactionDateType ().value ());
126- final XMLGregorianCalendar xmlGregorianCalendar =
127- DatatypeFactory .newInstance ().newXMLGregorianCalendar (gregorianCalendar );
128-
129- transactionDateType .setValue (xmlGregorianCalendar );
130- transactionDateType .setTransactionDateType (TransactionDateTypeType .valueOf (this .reportedPayee .reportedTransaction ()
131- .transactionDateType ()
132- .transactionDateTypeEnum ()
133- .value ()));
134- reportedTransactionType .getDateTime ().add (transactionDateType );
135-
136- reportedPayeeType .getName ().add (nameTypeReportedPayeeType );
137- reportedPayeeType .setCountry (CountryCodeType .fromValue (this .reportedPayee .countryCode ().name ()));
138- reportedPayeeType .setDocSpec (docSpecType );
139- reportedPayeeType .setAccountIdentifier (accountIdentifierType );
140- reportedPayeeType .setTAXIdentification (taxIdentifierType );
141- reportedPayeeType .getReportedTransaction ().add (reportedTransactionType );
142-
143- paymentDataBodyType .getReportedPayee ().add (reportedPayeeType );
144-
145- return paymentDataBodyType ;
164+ return pspType ;
146165 }
147166}
0 commit comments