LP1901930 SIP mediator continued
authorBill Erickson <berickxx@gmail.com>
Wed, 25 Nov 2020 18:46:01 +0000 (10:46 -0800)
committerBill Erickson <berickxx@gmail.com>
Wed, 25 Nov 2020 18:46:01 +0000 (10:46 -0800)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/eg2/src/app/staff/admin/server/admin-server-splash.component.html
Open-ILS/src/eg2/src/app/staff/admin/server/routing.module.ts
Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Checkout.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Payment.pm
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.sip-config.sql

index 3157ae1..528a125 100644 (file)
@@ -13522,7 +13522,23 @@ SELECT  usr,
                        <link field="account" reltype="has_a" key="id" map="" class="sipacc"/>
                </links>
        </class>
-
+       <class id="sipsm" controller="open-ils.cstore open-ils.pcrud"
+               oils_obj:fieldmapper="sip::screen_message" 
+               oils_persist:tablename="sip.screen_message" 
+               reporter:label="SIP Screen Message">
+               <fields oils_persist:primary="key">
+                       <field name="key" reporter:datatype="text" reporter:label="Message Key"/>
+                       <field name="message" reporter:datatype="text" reporter:label="Message" oils_persist:i18n="true"/>
+               </fields>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+                       <actions>
+                               <create permission="SIP_ADMIN" global_required="true"/>
+                               <retrieve />
+                               <update permission="SIP_ADMIN" global_required="true"/>
+                               <delete permission="SIP_ADMIN" global_required="true"/>
+                       </actions>
+               </permacrud>
+       </class>
 
 
        <!-- ********************************************************************************************************************* -->
index 42fb9e3..b1fd867 100644 (file)
@@ -92,6 +92,8 @@
       routerLink="/staff/admin/server/config/remoteauth_profile"></eg-link-table-link>
     <eg-link-table-link i18n-label label="SIP Accounts"  
       routerLink="/staff/admin/server/sip/account"></eg-link-table-link>
+    <eg-link-table-link i18n-label label="SIP Screen Messages"  
+      routerLink="/staff/admin/server/sip/screen_message"></eg-link-table-link>
     <eg-link-table-link i18n-label label="SMS Carriers"  
       routerLink="/staff/admin/server/config/sms_carrier"></eg-link-table-link>
     <eg-link-table-link i18n-label label="User Activity Types"  
index cae28a0..093ceff 100644 (file)
@@ -46,6 +46,11 @@ const routes: Routes = [{
     loadChildren: () =>
       import('./sip/account.module').then(m => m.SipAccountModule)
 }, {
+    path: 'sip/screen_message',
+    component: BasicAdminPageComponent,
+    data: [{schema: 'sip',
+        table: 'screen_message', readonlyFields: 'key'}]
+}, {
     path: ':schema/:table',
     component: BasicAdminPageComponent
 }];
index a739d0d..ab3b73f 100644 (file)
@@ -126,11 +126,19 @@ sub perform_checkout {
         }
 
         if ($textcode eq 'OPEN_CIRCULATION_EXISTS' ) {
-            # TODO: messages
-            $circ_details->{screen_msg} = 'This item is already checked out';
+            my $msg = $session->editor
+                ->retrieve_sip_screen_message('checkout.open_circ_exists');
+
+            $circ_details->{screen_msg} = 
+                $msg ? $msg->message : 'This item is already checked out';
 
         } else {
-            $circ_details->{screen_msg} = # TODO messages / renew
+
+            my $msg = 
+                $session->editor
+                    ->retrieve_sip_screen_message('checkout.patron_not_allowed');
+
+            $circ_details->{screen_msg} = $msg ? $msg->message : 
                 'Patron is not allowed to checkout the selected item';
         }
     }
index 145d46a..bb8b85b 100644 (file)
@@ -54,8 +54,10 @@ sub pay_one_transaction {
     return unless $pay_amount > 0;
 
     if ($pay_amount > $xact->balance_owed) {
-        # TODO strings
-        $details->{screen_msg} = 'Overpayment not allowed';
+        my $msg = $session->editor
+            ->retrieve_sip_screen_message('payment.overpayment_not_allowed');
+
+        $details->{screen_msg} = $msg ? $msg->message : 'Overpayment not allowed';
         return;
     }
 
@@ -74,8 +76,10 @@ sub pay_multi_transactions {
         $session->editor->authtoken, $user->id);
 
     if (!$xacts || !@$xacts) { # nothing to pay
-        # TODO: i18n
-        $details->{screen_msg} = 'Bill not found';
+        my $msg = $session->editor->
+            retrieve_sip_screen_message('payment.transaction_not_found');
+
+        $details->{screen_msg} = $msg ? $msg->message : 'Bill not found';
         return;
     }
 
@@ -117,8 +121,10 @@ sub pay_multi_transactions {
     }
 
     if ($amount_remaining > 0) {
-        # TODO strings
-        $details->{screen_msg} = 'Overpayment not allowed';
+        my $msg = $session->editor
+            ->retrieve_sip_screen_message('payment.overpayment_not_allowed');
+
+        $details->{screen_msg} = $msg ? $msg->message : 'Overpayment not allowed';
         return;
     }
 
index 16e08cf..6cc2777 100644 (file)
@@ -49,6 +49,11 @@ CREATE TABLE sip.session (
     create_time TIMESTAMPTZ NOT NULL DEFAULT NOW()
 );
 
+CREATE TABLE sip.screen_message (
+    key     TEXT PRIMARY KEY,
+    message TEXT NOT NULL
+);
+
 -- SEED DATA
 
 INSERT INTO actor.passwd_type (code, name, login, crypt_algo, iter_count)
@@ -154,6 +159,33 @@ VALUES (
         'sipset', 'description')
 );
 
+INSERT INTO sip.screen_message (key, message) VALUES (
+    'checkout.open_circ_exists', 
+    oils_i18n_gettext(
+        'checkout.open_circ_exists',
+        'This item is already checked out',
+        'sipsm', 'message')
+), (
+    'checkout.patron_not_allowed', 
+    oils_i18n_gettext(
+        'checkout.patron_not_allowed',
+        'Patron is not allowed to checkout the selected item',
+        'sipsm', 'message')
+), (
+    'payment.overpayment_not_allowed',
+    oils_i18n_gettext(
+        'payment.overpayment_not_allowed',
+        'Overpayment not allowed',
+        'sipsm', 'message')
+), (
+    'payment.transaction_not_found',
+    oils_i18n_gettext(
+        'payment.transaction_not_found',
+        'Bill not found',
+        'sipsm', 'message')
+);
+
+
 /* EXAMPLE SETTINGS