|
Lines 166-184
if ( $op eq 'cud-cashup_start' ) {
Link Here
|
| 166 |
next unless $register; |
166 |
next unless $register; |
| 167 |
|
167 |
|
| 168 |
eval { |
168 |
eval { |
| 169 |
# Quick cashup: calculate expected amount from outstanding accountlines |
169 |
# Get the amount from the request parameter |
| 170 |
my $expected_amount = |
170 |
# For quick cashup, this will be the expected amount set by JavaScript |
| 171 |
$register->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) * -1; |
171 |
# For two-stage cashup completion, this will be the user-entered actual amount |
|
|
172 |
my $amount = $input->param('amount'); |
| 173 |
|
| 174 |
# If no amount provided, calculate expected amount (backwards compatibility) |
| 175 |
unless ( defined $amount && $amount ne '' ) { |
| 176 |
$amount = |
| 177 |
$register->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) * -1; |
| 178 |
} |
| 172 |
|
179 |
|
| 173 |
# Quick cashup assumes actual amount equals expected (no reconciliation needed) |
180 |
# Get optional reconciliation note |
| 174 |
$register->add_cashup( |
181 |
my $reconciliation_note = $input->param('reconciliation_note'); |
| 175 |
{ |
|
|
| 176 |
manager_id => $logged_in_user->id, |
| 177 |
amount => $expected_amount, |
| 178 |
|
182 |
|
| 179 |
# No reconciliation_note = quick cashup assumes correct amounts |
183 |
# Complete the cashup |
| 180 |
} |
184 |
my %cashup_params = ( |
|
|
185 |
manager_id => $logged_in_user->id, |
| 186 |
amount => $amount, |
| 181 |
); |
187 |
); |
|
|
188 |
|
| 189 |
# Add reconciliation note if provided |
| 190 |
if ( defined $reconciliation_note && $reconciliation_note ne '' ) { |
| 191 |
$cashup_params{reconciliation_note} = $reconciliation_note; |
| 192 |
} |
| 193 |
|
| 194 |
$register->add_cashup( \%cashup_params ); |
| 182 |
$success_count++; |
195 |
$success_count++; |
| 183 |
}; |
196 |
}; |
| 184 |
if ($@) { |
197 |
if ($@) { |
| 185 |
- |
|
|