From 9ce3259c218eaadc781c2889d1b77a49e3d03a99 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 11 Mar 2021 11:55:27 -0500 Subject: [PATCH] LP1904036 Payment receipts Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../staff/admin/server/print-template.component.ts | 24 +++++- .../src/app/staff/circ/patron/bills.component.ts | 50 ++++++++--- .../src/app/staff/share/patron/search.component.ts | 7 +- .../src/perlmods/lib/OpenILS/Application/Actor.pm | 30 +++---- .../sql/Pg/upgrade/XXXX.data.angular-patron.sql | 97 +++++++++++++++++++++- 5 files changed, 178 insertions(+), 30 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts index 3cd8d56b14..e6542abaf9 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts @@ -112,7 +112,7 @@ export class PrintTemplateComponent implements OnInit { this.sampleData.holds_for_bib = wide_holds; - // Flesh the summary + // Bills samples.mbt[0].summary = samples.mbts[0]; samples.mbt[1].summary = samples.mbts[1]; samples.mbt[2].summary = samples.mbts[2]; @@ -122,6 +122,28 @@ export class PrintTemplateComponent implements OnInit { samples.mbt[1], samples.mbt[2] ]; + + // Payments + this.sampleData.bills_payment = { + previous_balance: 10, + payment_type: 'cash_payment', + payment_total: 5, + payment_applied: 3, + amount_voided: 0, + change_given: 2, + payment_note: 'Test Note', + payments: [{ + amount: 1, + xact: samples.mbt[0], + title: 'A Title', + copy_barcode: '3423482302393' + }, { + amount: 4, + xact: samples.mbt[1], + title: 'Another Title', + copy_barcode: '3423482302394' + }] + }; } onTabChange(evt: NgbTabChangeEvent) { 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 a894aa79f1..2bf5f2d31f 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 @@ -319,17 +319,7 @@ export class BillsComponent implements OnInit, AfterViewInit { .finally(() => this.applyingPayment = false); } - handlePayReceipt(payments: Array>, paymentIds: number[]): Promise { - - if (this.disableAutoPrint || !this.receiptOnPayment) { - return Promise.resolve(); - } - - // TODO - // return this.printer.pr - } - - compilePayments(): Array> { + compilePayments(): Array> { // [ [xactId, payAmount], ... ] const payments = []; this.entries.forEach(row => { if (row.paymentPending) { @@ -431,5 +421,43 @@ export class BillsComponent implements OnInit, AfterViewInit { printContext: 'default' }); } + + handlePayReceipt(payments: Array>, paymentIds: number[]): Promise { + + if (this.disableAutoPrint || !this.receiptOnPayment) { + return Promise.resolve(); + } + + const context = { + payments: [], + previous_balance: this.context.patronStats.fines.balance_owed, + payment_type: this.paymentType, + payment_total: this.paymentAmount, + payment_applied: this.pendingPayment(), + amount_voided: this.sessionVoided, + change_given: this.pendingChange(), + payment_note: this.paymentNote + }; + + payments.forEach(payment => { + const entry = + this.entries.filter(entry => entry.xact.id() === payment[0])[0]; + + context.payments.push({ + amount: payment[1], + xact: entry.xact, + title: entry.title, + copy_barcode: entry.copy ? entry.copy.barcode() : '' + }); + }); + + this.printer.print({ + templateName: 'bills_payment', + contextData: context, + printContext: 'receipt' + }); + } + + } diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts index 24341568dd..d8a172c312 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts @@ -50,6 +50,7 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { @ViewChild('searchGrid', {static: false}) searchGrid: GridComponent; + startWithFired = false; @Input() startWithSearch: PatronSearch; // Fires on dbl-click or Enter while one or more search result @@ -171,11 +172,13 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { searchByForm(pager: Pager, sort: any[]): Observable { - if (this.startWithSearch) { + if (this.startWithSearch && !this.startWithFired) { this.absorbPatronSearch(this.startWithSearch); - this.startWithSearch = null; } + // Never fire a "start with" search after any search has fired + this.startWithFired = true; + const search = this.compileSearch(); if (!search) { return of(); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 3bf2c14c44..be1010524c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -5396,25 +5396,25 @@ sub user_billing_xacts { $xact_id, { flesh => 5, flesh_fields => { - mbt => [qw/summary circulation grocery/], - circ => [qw/ + mbt => [qw/summary circulation grocery/], + circ => [qw/ target_copy workstation checkin_workstation /], - acp => [qw/ - call_number - holds_count - status - circ_lib - location - floating - age_protect - parts - /], - acpm => [qw/part/], - acn => [qw/record owning_lib prefix suffix/], - bre => [qw/wide_display_entry/] + acp => [qw/ + call_number + holds_count + status + circ_lib + location + floating + age_protect + parts + /], + acpm => [qw/part/], + acn => [qw/record owning_lib prefix suffix/], + bre => [qw/wide_display_entry/] }, # Avoid adding the MARXML # Fleshed fields are implicitly included. 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 5517680e0b..55fbd79dac 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 @@ -60,7 +60,6 @@ UPDATE config.print_template SET active = TRUE WHERE name = 'patron_address'; 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$ [% @@ -124,6 +123,102 @@ 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) +VALUES ('bills_payment', 'Bills, Payment', 1, TRUE, 'en-US', 'text/html', ''); +*/ + +UPDATE config.print_template SET template = $TEMPLATE$ +[% + USE date; + USE money = format('$%.2f'); + SET payments = template_data.payments; + SET previous_balance = template_data.previous_balance; + SET payment_type = template_data.payment_type; + SET payment_total = template_data.payment_total; + SET payment_applied = template_data.payment_applied; + SET amount_voided = template_data.amount_voided; + SET change_given = template_data.change_given; + SET payment_note = template_data.payment_note; + SET copy_barcode = template_data.copy_barcode; + SET title = template_data.title; +%] +
+ +
Welcome to [% staff_org.name %]
+
A receipt of your transaction:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Original Balance:[% money(previous_balance) %]
Payment Method: + [% SWITCH payment_type %] + [% CASE "cash_payment" %]Cash + [% CASE "check_payment" %]Check + [% CASE "credit_card_payment" %]Credit Card + [% CASE "debit_card_payment" %]Debit Card + [% CASE "credit_payment" %]Patron Credit + [% CASE "work_payment" %]Work + [% CASE "forgive_payment" %]Forgive + [% CASE "goods_payment" %]Goods + [% END %] +
Payment Received:[% money(payment_total) %]
Payment Applied:[% money(payment_applied) %]
Billings Voided:[% money(amount_voided) %]
Change Given:[% money(change_given) %]
New Balance:[% money(new_balance) %]
+

Note: [% payment_note %]

+

+ Specific Bills +

+ [% FOR payment IN payments %] + + + + + + + [% IF payment.copy_barcode %] + + + + [% END %] +
Bill # [% payment.xact.id %][% payment.xact.summary.last_billing_type %]Received: [% money(payment.amount) %]
[% payment.copy_barcode %] [% payment.title %]
+
+ [% END %] +
+

+
+

+
[% staff_org.name %] [% date.format(date.now, '%x %r') %]
+
You were helped by [% staff.first_given_name %]
+
+$TEMPLATE$ WHERE name = 'bills_payment'; + COMMIT; -- 2.11.0