From 49f9ab93c34fbfb78ed0681b616c0884bd390784 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 16 Aug 2006 17:25:43 +0000 Subject: [PATCH] cashdrawer summary objects git-svn-id: svn://svn.open-ils.org/ILS/trunk@5534 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 15 ++++++ .../Application/Storage/Publisher/money.pm | 52 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 660fb391cd..3f79c77dea 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -1,6 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/money.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/money.pm index 396c1e53c2..838578d3ef 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/money.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/money.pm @@ -106,4 +106,56 @@ __PACKAGE__->register_method( argc => 3, ); +sub ou_desk_payments { + my $self = shift; + my $client = shift; + my $lib = shift; + my $startdate = shift; + my $enddate = shift; + + my $sql = <<' SQL'; + +SELECT * + FROM crosstab($$ + SELECT ws.id, + p.payment_type, + SUM(COALESCE(p.amount,0.0)) + FROM money.desk_payment_view p + JOIN actor.workstation ws ON (ws.id = p.cash_drawer) + WHERE p.payment_ts >= ? + AND p.payment_ts < ?::TIMESTAMPTZ + INTERVAL '1 day' + AND p.voided IS FALSE + AND ws.owning_lib = ? + GROUP BY 1, 2 + ORDER BY 1,2 + $$) AS X( + workstation int, + cash_payment numeric(10,2), + check_payment numeric(10,2), + credit_card_payment numeric(10,2) ); + + SQL + + my $rows = money::payment->db_Main->selectall_arrayref( $sql, {}, $startdate, $enddate, $lib ); + + for my $r (@$rows) { + my $x = new Fieldmapper::money::workstation_payment_summary; + $x->workstation( actor::workstation->retrieve($$r[0])->to_fieldmapper ); + $x->cash_payment($$r[1]); + $x->check_payment($$r[2]); + $x->credit_card_payment($$r[3]); + + $client->respond($x); + } + + return undef; +} +__PACKAGE__->register_method( + method => 'ou_desk_payments', + api_name => 'open-ils.storage.money.org_unit.desk_payments', + stream => 1, + argc => 3, +); + + 1; -- 2.43.2