|
Lines 291-304
sub start_cashup {
Link Here
|
| 291 |
|
291 |
|
| 292 |
my $expected_amount = abs( $self->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) ); |
292 |
my $expected_amount = abs( $self->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) ); |
| 293 |
|
293 |
|
| 294 |
# Create the CASHUP_START action |
294 |
# Create the CASHUP_START action using centralized exception handling |
| 295 |
my $rs = $self->_result->add_to_cash_register_actions( |
295 |
my $schema = $self->_result->result_source->schema; |
| 296 |
{ |
296 |
my $rs = $schema->safe_do( |
| 297 |
code => 'CASHUP_START', |
297 |
sub { |
| 298 |
manager_id => $manager_id, |
298 |
return $self->_result->add_to_cash_register_actions( |
| 299 |
amount => $expected_amount |
299 |
{ |
|
|
300 |
code => 'CASHUP_START', |
| 301 |
manager_id => $manager_id, |
| 302 |
amount => $expected_amount |
| 303 |
} |
| 304 |
)->discard_changes; |
| 300 |
} |
305 |
} |
| 301 |
)->discard_changes; |
306 |
); |
| 302 |
|
307 |
|
| 303 |
return Koha::Cash::Register::Cashup->_new_from_dbic($rs); |
308 |
return Koha::Cash::Register::Cashup->_new_from_dbic($rs); |
| 304 |
} |
309 |
} |
|
Lines 387-402
sub add_cashup {
Link Here
|
| 387 |
|
392 |
|
| 388 |
$schema->txn_do( |
393 |
$schema->txn_do( |
| 389 |
sub { |
394 |
sub { |
| 390 |
# Create the cashup action with actual amount |
395 |
try { |
| 391 |
my $rs = $self->_result->add_to_cash_register_actions( |
396 |
# Create the cashup action with actual amount using centralized exception handling |
| 392 |
{ |
397 |
my $rs = $schema->safe_do( |
| 393 |
code => 'CASHUP', |
398 |
sub { |
| 394 |
manager_id => $manager_id, |
399 |
return $self->_result->add_to_cash_register_actions( |
| 395 |
amount => $amount |
400 |
{ |
| 396 |
} |
401 |
code => 'CASHUP', |
| 397 |
)->discard_changes; |
402 |
manager_id => $manager_id, |
| 398 |
|
403 |
amount => $amount |
| 399 |
$cashup = Koha::Cash::Register::Cashup->_new_from_dbic($rs); |
404 |
} |
|
|
405 |
)->discard_changes; |
| 406 |
} |
| 407 |
); |
| 408 |
|
| 409 |
$cashup = Koha::Cash::Register::Cashup->_new_from_dbic($rs); |
| 410 |
} catch { |
| 411 |
|
| 412 |
# Propagate any exception (already translated by safe_do if needed) |
| 413 |
$_->rethrow(); |
| 414 |
}; |
| 400 |
|
415 |
|
| 401 |
# Create reconciliation accountline if there's a difference |
416 |
# Create reconciliation accountline if there's a difference |
| 402 |
if ( $difference != 0 ) { |
417 |
if ( $difference != 0 ) { |