From 2b9c91b2830f6e3a60e8d5b7d686ee63e5dad1e0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 19 Apr 2021 14:39:08 -0400 Subject: [PATCH] LP1904036 more billing Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../circ/patron/billing-history.component.html | 2 +- .../staff/circ/patron/billing-history.component.ts | 5 ++-- .../src/app/staff/circ/patron/bills.component.html | 28 ++++++++++++++++------ .../src/app/staff/circ/patron/bills.component.ts | 24 ++++++++++++------- .../src/app/staff/share/billing/billing.service.ts | 10 +++++--- .../src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm | 9 +++++++ .../sql/Pg/upgrade/XXXX.data.angular-patron.sql | 26 ++++++++++++-------- 7 files changed, 72 insertions(+), 32 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.html index 4b3f0f0562..f92b47928a 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.html @@ -134,7 +134,7 @@ diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.ts index 54c1e50dce..735eb6d640 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/billing-history.component.ts @@ -116,9 +116,10 @@ export class BillingHistoryComponent implements OnInit { } } - showStatement(row: any) { + showStatement(row: any, forPayment?: boolean) { + const id = forPayment ? row['xact.id'] : row.id; this.router.navigate(['/staff/circ/patron', - this.patronId, 'bills', row.xact.id(), 'statement']); + this.patronId, 'bills', id, 'statement']); } addBillingForXact(rows: any[]) { diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.html index fe26a62409..390f74df8c 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.html @@ -215,8 +215,14 @@ - + + + + + @@ -249,14 +255,14 @@ path="circulation.target_copy.call_number.record.id" [required]="true" [hidden]="true"> - - + - + @@ -265,6 +271,14 @@ path="circulation.target_copy.call_number.record.simple_record.author"> + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts index 4282db8f32..887ae896f3 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/bills.component.ts @@ -101,13 +101,16 @@ export class BillsComponent implements OnInit, AfterViewInit { const query: any = { usr: this.patronId, xact_finish: null, - 'summary.balance_owed' : {'<>' : 0} + balance_owed: {'<>' : 0} }; return this.flatData.getRows( this.billGrid.context, query, pager, sort) .pipe(tap(row => { row.paymentPending = 0; + row.billingLocation = + row['grocery.billing_location.shortname'] || + row['circulation.circ_lib.shortname'] })); }; @@ -172,9 +175,9 @@ export class BillsComponent implements OnInit, AfterViewInit { if (!row) { return; } // Called mid-reload - info.owed += Number(row['summary.balance_owed']) * 100; - info.billed += Number(row['summary.total_owed']) * 100; - info.paid += Number(row['summary.total_paid']) * 100; + info.owed += Number(row.balance_owed) * 100; + info.billed += Number(row.total_owed) * 100; + info.paid += Number(row.total_paid) * 100; }); info.owed /= 100; @@ -215,7 +218,7 @@ export class BillsComponent implements OnInit, AfterViewInit { refundsAvailable(): number { let amount = 0; this.gridDataSource.data.forEach(row => { - const balance = row['summary.balance_owed']; + const balance = row.balance_owed; if (balance < 0) { amount += balance * 100; } }); @@ -266,7 +269,10 @@ export class BillsComponent implements OnInit, AfterViewInit { this.convertChangeToCredit ); }) - .then(paymentIds => this.handlePayReceipt(payments, paymentIds)) + .then(resp => { + this.patron().last_xact_id(resp.last_xact_id); + return this.handlePayReceipt(payments, resp.payments); + }) // refresh affected xact IDs .then(_ => this.billGrid.reload()) @@ -355,7 +361,7 @@ export class BillsComponent implements OnInit, AfterViewInit { if (done) { return; } const row = this.billGrid.context.getRowByIndex(index); - const owed = Number(row['summary.balance_owed']); + const owed = Number(row.balance_owed); if (amount > owed) { // Pending payment amount exceeds balance of this @@ -411,7 +417,7 @@ export class BillsComponent implements OnInit, AfterViewInit { payments.forEach(payment => { const entry = - this.gridDataSource.data.filter(e => e.xact.id() === payment[0])[0]; + this.gridDataSource.data.filter(e => e.id === payment[0])[0]; context.payments.push({ amount: payment[1], @@ -435,7 +441,7 @@ export class BillsComponent implements OnInit, AfterViewInit { selectRefunds() { this.billGrid.context.rowSelector.clear(); this.gridDataSource.data.forEach(row => { - if (row['summary.balance_owed'] < 0) { + if (row.balance_owed < 0) { this.billGrid.context.toggleSelectOneRow(row.id); } }); diff --git a/Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts b/Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts index 52ca1e5432..89f04bd8c8 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/billing/billing.service.ts @@ -24,6 +24,11 @@ export interface CreditCardPaymentParams { note?: string; } +interface PaymentResponse { + payments: number[]; + last_xact_id: string; +} + @Injectable() export class BillingService { billingTypes: IdlObject[]; @@ -73,7 +78,7 @@ export class BillingService { paymentNote?: string, checkNumber?: string, creditCardParams?: CreditCardPaymentParams, - convertChangeToCredit?: boolean): Promise { + convertChangeToCredit?: boolean): Promise { return this.net.request( 'open-ils.circ', @@ -97,8 +102,7 @@ export class BillingService { } // TODO work log - - return response.payments; + return response; }); } } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm index 318f849acf..d678fb3962 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm @@ -221,6 +221,15 @@ $helpers = { return $U->ou_ancestor_setting_value($org_id, $setting); }, + # Useful for accessing hash values whose key contains dots (.), + # which TT interprets as levels within a nested hash. + # + # e.g. So you don't have to do stuff like this: + # SET field = 'summary.balance_owed'; xact.$field + hashval => sub { + my ($hash, $key) = @_; + return $hash ? $hash->{$key} : undef; + } }; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-patron.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-patron.sql index 04ff243de4..3562fb44e4 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-patron.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.angular-patron.sql @@ -44,11 +44,13 @@ INSERT INTO config.print_template (name, label, owner, active, locale, content_type, template) VALUES ('bills_current', 'Bills, Current', 1, TRUE, 'en-US', 'text/html', ''); +*/ + UPDATE config.print_template SET template = $TEMPLATE$ [% USE date; USE money = format('$%.2f'); - xacts = template_data.xacts; + SET xacts = template_data.xacts; %]
@@ -71,29 +73,30 @@ UPDATE config.print_template SET template = $TEMPLATE$ Last Billing: - [% xact.summary.last_billing_type %] + [% xact.last_billing_type %] Total Billed: - [% money(xact.summary.total_owed) %] + [% money(xact.total_owed) %] Last Payment: - [% xact.summary.last_payment_type %] - [% IF xact.summary.last_payment_ts %] - at [% date.format(helpers.format_date( - xact.summary.last_payment_ts, staff_org_timezone), '%x %r') %] + [% xact.last_payment_type %] + [% IF xact.last_payment_ts %] + at [% date.format( + helpers.format_date( + xact.last_payment_ts, staff_org_timezone), '%x %r') %] [% END %] Total Paid: - [% money(xact.summary.total_paid) %] + [% money(xact.total_paid) %] Balance: - [% money(xact.summary.balance_owed) %] + [% money(xact.balance_owed) %] @@ -106,6 +109,8 @@ UPDATE config.print_template SET template = $TEMPLATE$
$TEMPLATE$ WHERE name = 'bills_current'; +/* + INSERT INTO config.print_template (name, label, owner, active, locale, content_type, template) @@ -468,7 +473,6 @@ INSERT INTO config.print_template (name, label, owner, active, locale, content_type, template) VALUES ('holds_for_patron', 'Holds For Patron', 1, TRUE, 'en-US', 'text/html', ''); -*/ UPDATE config.print_template SET template = $TEMPLATE$ [% @@ -495,6 +499,8 @@ UPDATE config.print_template SET template = $TEMPLATE$ $TEMPLATE$ WHERE name = 'holds_for_patron'; +*/ + COMMIT; -- 2.11.0