@@ -143,6 +143,9 @@ private function camtIndex(Request $request, Configuration $configuration): View
143143 'explanation ' => trans ('camt.explain_B ' ),
144144 'fields ' => $ this ->getFieldsForLevel ('B ' ),
145145 ];
146+ // var_dump($levels['B']);
147+ // var_dump($roles);
148+ // exit;
146149 $ levels ['C ' ] = [
147150 'title ' => trans ('camt.level_C ' ),
148151 'explanation ' => trans ('camt.explain_C ' ),
@@ -176,6 +179,7 @@ private function camtIndex(Request $request, Configuration $configuration): View
176179 'fields ' => [
177180 // have to collect D by hand because of intermediate sections
178181 'entryDetailAccountServicerReference ' => config ('camt.fields.entryDetailAccountServicerReference ' ),
182+ 'entryDetailEndToEndId ' => config ('camt.fields.entryDetailEndToEndId ' ),
179183 'entryDetailRemittanceInformationUnstructuredBlockMessage ' => config ('camt.fields.entryDetailRemittanceInformationUnstructuredBlockMessage ' ),
180184 'entryDetailRemittanceInformationStructuredBlockAdditionalRemittanceInformation ' => config ('camt.fields.entryDetailRemittanceInformationStructuredBlockAdditionalRemittanceInformation ' ),
181185 'section_tr ' => ['section ' => true , 'title ' => 'transaction ' ],
@@ -192,6 +196,7 @@ private function camtIndex(Request $request, Configuration $configuration): View
192196 ],
193197 ];
194198 }
199+ $ levels = $ this ->mergeLevelsAndRoles ($ levels , $ roles );
195200
196201 return view ('import.005-roles.index-camt ' , compact ('mainTitle ' , 'configuration ' , 'subTitle ' , 'levels ' , 'doMapping ' , 'examples ' , 'roles ' ));
197202 }
@@ -234,13 +239,16 @@ private function processPostIndex(RolesPostRequest $request, Configuration $conf
234239
235240 // set role config as complete.
236241 session ()->put (Constants::ROLES_COMPLETE_INDICATOR , true );
237-
242+ Log:: debug ( ' Set ROLES_COMPLETE_INDICATOR = true ' );
238243 // redirect to mapping thing.
239244 if (true === $ needsMapping ) {
245+ Log::debug ('Redirect to mapping, because $needsMapping is true. ' );
246+
240247 return redirect ()->route ('006-mapping.index ' );
241248 }
242249 // otherwise, store empty mapping, and continue:
243250 // set map config as complete.
251+ Log::debug ('Set READY_FOR_CONVERSION = true + redirect to conversion, because $needsMapping is false. ' );
244252 session ()->put (Constants::READY_FOR_CONVERSION , true );
245253
246254 return redirect ()->route ('007-convert.index ' );
@@ -260,4 +268,31 @@ private function needMapping(array $array): bool
260268
261269 return $ need ;
262270 }
271+
272+ private function mergeLevelsAndRoles (array $ levels , array $ roles ): array
273+ {
274+ foreach ($ levels as $ letter => $ info ) {
275+ foreach ($ info ['fields ' ] as $ index => $ field ) {
276+ $ title = $ field ['title ' ];
277+ $ selected = $ field ['default_role ' ] ?? '_impossible ' ;
278+ Log::debug (sprintf ('Analysing level %s field "%s" ' , $ letter , $ title ));
279+ if (array_key_exists ($ title , $ roles )) {
280+ if ('_ignore ' === $ roles [$ title ]) {
281+ $ selected = '_ignore ' ;
282+ Log::debug (sprintf ('Make default role "_ignore" for level %s field "%s" ' , $ letter , $ title ));
283+ }
284+ if ($ roles [$ title ] === $ field ['default_role ' ]) {
285+ // $selected = $field['default_role'];
286+ Log::debug (sprintf ('User has selected role "%s" for level %s field "%s" ' , $ roles [$ title ], $ letter , $ title ));
287+ }
288+ }
289+ if (!array_key_exists ($ title , $ roles )) {
290+ Log::debug (sprintf ('User has no role pre-selected for level %s field "%s" ' , $ letter , $ title ));
291+ }
292+ $ levels [$ letter ]['fields ' ][$ index ]['selected ' ] = $ selected ;
293+ }
294+ }
295+
296+ return $ levels ;
297+ }
263298}
0 commit comments