@@ -, +, @@ against --- Koha/Cash/Register/Cashup.pm | 45 +++++++++++++++---- .../intranet-tmpl/prog/js/cashup_modal.js | 6 ++- 2 files changed, 41 insertions(+), 10 deletions(-) --- a/Koha/Cash/Register/Cashup.pm +++ a/Koha/Cash/Register/Cashup.pm @@ -109,7 +109,7 @@ sub summary { { sum => 'me.amount' }, 'debit.debit_type_code', 'debit_type_code.description' ], - 'as' => [ 'total', 'debit_type_code', 'debit_description' ], + 'as' => [ 'total', 'debit_type_code', 'debit_description' ], order_by => { '-asc' => 'debit_type_code.description' }, } ); @@ -120,18 +120,40 @@ sub summary { '-in' => $payout_transactions->_resultset->get_column( 'accountlines_id')->as_query }, - 'me.credit_id' => { '!=' => undef } + 'me.credit_id' => { '!=' => undef }, + 'account_offsets_credits.debit_id' => { + '-not_in' => $payout_transactions->_resultset->get_column( + 'accountlines_id')->as_query + } }, { - join => { 'credit' => 'credit_type_code' }, - group_by => - [ 'credit.credit_type_code', 'credit_type_code.description' ], + join => { + 'credit' => [ + 'credit_type_code', + { + 'account_offsets_credits' => + { 'debit' => 'debit_type_code' } + } + ] + }, + group_by => [ + 'credit.credit_type_code', 'credit_type_code.description', + 'debit.debit_type_code', 'debit_type_code.description' + ], 'select' => [ { sum => 'me.amount' }, 'credit.credit_type_code', - 'credit_type_code.description' + 'credit_type_code.description', 'debit.debit_type_code', + 'debit_type_code.description' + ], + 'as' => [ + 'total', 'credit_type_code', + 'credit_description', 'debit_type_code', + 'debit_description' ], - 'as' => [ 'total', 'credit_type_code', 'credit_description' ], - order_by => { '-asc' => 'credit_type_code.description' }, + order_by => { + '-asc' => + [ 'credit_type_code.description', 'debit_type_code.description' ] + }, } ); @@ -147,7 +169,12 @@ sub summary { total => $_->get_column('total') * -1, credit_type_code => $_->get_column('credit_type_code'), credit_type => - { description => $_->get_column('credit_description') } + { description => $_->get_column('credit_description') }, + related_debit => { + debit_type_code => $_->get_column('debit_type_code'), + debit_type => + { description => $_->get_column('debit_description') } + } } } $payout_summary->as_list; --- a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js +++ a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js @@ -16,7 +16,11 @@ $('#cashupSummaryModal').on('show.bs.modal', function(e) { var tbody = summary_modal.find('tbody') tbody.empty(); for (out of data.summary.payout_grouped) { - tbody.append('' + out.credit_type.description + '- ' + out.total + ''); + if ( out.credit_type_code == 'REFUND' ) { + tbody.append('' + out.credit_type.description + ' against ' + out.related_debit.debit_type.description + '- ' + out.total + ''); + } else { + tbody.append('' + out.credit_type.description + '- ' + out.total + ''); + } } for (income of data.summary.income_grouped) { --