@@ -38,12 +38,12 @@ Available values:
3838
3939=item * delete
4040
41- =item * submit
42-
4341=item * reconcile
4442
4543=item * reject
4644
45+ =item * submit
46+
4747=back
4848
4949=cut
@@ -94,7 +94,7 @@ sub execute($self, $wf) {
9494
9595# ####################################
9696#
97- # aadd_pending_items
97+ # add_pending_items
9898#
9999# ####################################
100100
@@ -130,23 +130,26 @@ sub _add_pending_payments($recon_fx, $pending) {
130130 return ($payments {__NOPAYMENT__ }, \@new_recon );
131131}
132132
133- sub _adjust_todo_lines ($pending , $book_todo ) {
133+ sub _adjust_todo_lines ($recon_fx , $ pending , $book_todo ) {
134134 # add adjustment lines to existing payment lines
135135 my %existing_sources ;
136136 for my $line ($book_todo -> @*) {
137137 $existing_sources {$line -> {source }} //= [];
138138 push $existing_sources {$line -> {source }}-> @*, $line ;
139139 }
140+
140141 for my ($index , $line ) (indexed $pending -> @*) {
141142 next unless exists $existing_sources {$line -> {source }};
142143 my $existing = $existing_sources {$line -> {source }};
143144 my @same_date = grep {
144- $_ -> {post_date } eq $line -> {post_date }
145+ $_ -> {post_date } eq $line -> {transdate }
145146 } $existing -> @*;
146147 next if scalar (@same_date ) != 1;
147148
148149 splice $pending -> @*, $index , 1;
149150 push $same_date [0]-> {links }-> @*, $line ;
151+ $same_date [0]-> {amount } +=
152+ $recon_fx ? $line -> {amount_tc } : $line -> {amount_bc };
150153 }
151154
152155 return ;
@@ -176,7 +179,7 @@ sub _add_remaining_lines($recon_fx, $pending, $book_todo) {
176179 else {
177180 for my $line ($lines -> @*) {
178181 my $amount =
179- $recon_fx ? $_ -> {amount_tc } : $_ -> {amount_bc };
182+ $recon_fx ? $line -> {amount_tc } : $line -> {amount_bc };
180183 push $book_todo -> @*, {
181184 amount => $amount ,
182185 post_date => $date ,
@@ -198,7 +201,10 @@ sub _add_pending_items($self, $wf) {
198201 push $book_todo -> @*, $new_recon -> @*;
199202
200203 # modifies $pending->@* and $book_todo->@*
201- _adjust_todo_lines( $pending , $book_todo );
204+ _adjust_todo_lines(
205+ $wf -> context-> param( ' recon_fx' ),
206+ $pending ,
207+ $book_todo );
202208
203209 # add the remaining lines grouped by source, if they have one
204210 # modifies $book_todo->@*
0 commit comments