Bug 29987: Display credit without offsets in transactions
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 24 Aug 2022 10:06:57 +0000 (11:06 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 21 Oct 2022 13:18:53 +0000 (10:18 -0300)
This patch adds a row to the transactions table for credits without
corresponding offsets

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt

index 84cd8d5..8e8bd5c 100644 (file)
                 <tbody>
                     [% FOREACH accountline IN accountlines %]
                         [% IF accountline.is_credit %]
+                        [% IF accountline.credit_offsets.count == 1 %]
+                            <tr class="credit dtrg-group dtrg-start dtrg-level-0">
+                                <td></td>
+                                <td>{}</td>
+                                <td>[% accountline.timestamp | $KohaDates with_hours => 1 %] ([% IF accountline.credit_number %][%- accountline.credit_number | html -%][% ELSE %][% accountline.accountlines_id | html %][% END %])</td>
+                                <td>[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])</td>
+                                <td></td>
+                                <td>[% accountline.amount * -1 | $Price %]</td>
+                                <td><button class="printReceipt btn btn-default btn-xs" data-accountline="[% accountline.accountlines_id | uri %]"><i class="fa fa-print"></i> Print receipt</button></td>
+                            </tr>
+                            [% ELSE %]
                             [% FOREACH credit IN accountline.credit_offsets %]
                             [% IF credit.debit %]
-                            <tr>
+                            <tr cnt="[% accountline.credit_offsets.count %]">
                                 <td>[% accountline.accountlines_id | html %]</td>
                                 <td>{ "type": "credit", "identifier": "[%- accountline.credit_number | html -%]", "description": "[%- PROCESS account_type_description account=accountline -%] ([% AuthorisedValues.GetByCode( 'PAYMENT_TYPE', accountline.payment_type ) | html %])", "amount": "[% accountline.amount * -1 | $Price %]", "timestamp": "[% accountline.timestamp | $KohaDates with_hours => 1 %]" }</td>
                                 <td></td>
                             </tr>
                             [% END %]
                             [% END %]
+                            [% END %]
                         [% ELSE %]
                             [% FOREACH debit IN accountline.debit_offsets %]
                             [% IF debit.credit %]
             rowGroup: {
                 dataSrc: 0,
                 startRender: function ( rows, group ) {
+                    if ( group ) {
                     var details = JSON.parse(rows.data().pluck(1).pop());
                     var identifier = details.identifier || group;
                     return $('<tr class="'+details.type+'"/>')
                         .append( '<td colspan="2">'+details.description+'</td>' )
                         .append( '<td>'+details.amount+'</td>' )
                         .append( '<td><button class="printReceipt btn btn-default btn-xs" data-accountline="'+group+'"><i class="fa fa-print"></i> ' + _("Print receipt") + '</button></td>');
+                    }
                 },
                 endRender: null,
             },