LP1929741 Zero-copy and no-assets PO activation
authorBill Erickson <berickxx@gmail.com>
Mon, 1 Feb 2021 22:29:26 +0000 (17:29 -0500)
committerJane Sandberg <js7389@princeton.edu>
Sun, 2 Oct 2022 15:02:49 +0000 (08:02 -0700)
And summary layout improvements.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.html
Open-ILS/src/eg2/src/app/staff/acq/po/summary.component.ts

index d7442b9..758fc30 100644 (file)
@@ -8,49 +8,11 @@
     <div class="col-lg-9">
 
       <div class="row">
-        <div class="col-lg-3 d-flex">
+        <div class="col-lg-4 d-flex">
           <div class="flex-2" i18n>PO ID:</div>
-          <div class="flex-3">{{poId}}</div>
+          <div class="flex-4">{{poId}}</div>
         </div>
-        <div class="col-lg-9 d-flex">
-          <div class="flex-1" i18n>PO Name:</div>
-          <div class="flex-6">
-            <ng-container *ngIf="editPoName">
-              <input id='pl-name-input' type="text" class="form-control"
-                [(ngModel)]="newPoName" (keyup.enter)="toggleNameEdit(true)" 
-                (blur)="toggleNameEdit()"/>
-            </ng-container>
-            <ng-container *ngIf="!editPoName">
-              <a (click)="toggleNameEdit()" href='javascript:;'
-                class='font-weight-bold'>{{po().name()}}</a>
-            </ng-container>
-          </div>
-        </div>
-      </div>
-
-      <div class="row">
-        <div class="col-lg-3 d-flex">
-          <div class="flex-2" i18n>Lineitems:</div>
-          <div class="flex-3">{{po().lineitem_count()}}</div>
-        </div>
-        <div class="col-lg-9 d-flex">
-          <div class="flex-1" i18n>Provider:</div>
-          <div class="flex-6">
-            <a routerLink="/staff/acq/provider/{{po().provider().id()}}/details">
-              {{po().provider().name()}}
-            </a>
-          </div>
-        </div>
-      </div>
-      <div class="row">
-        <div class="col-lg-3 d-flex">
-          <div class="flex-2" i18n>Activated:</div>
-          <div class="flex-3">
-            <span *ngIf="po().order_date()">{{po().order_date() | date:'short'}}</span>
-            <span *ngIf="!po().order_date()" i18n>N/A</span>
-          </div>
-        </div>
-        <div class="col-lg-9 d-flex">
+        <div class="col-lg-8 d-flex">
           <div class="flex-1" i18n>Status:</div>
           <div class="flex-6">
             <div class="w-50" *ngIf="canActivate === null">
           </div>
         </div>
       </div>
-      <hr class="p-0 m-0 mt-1"/>
-      <div class="row mt-1">
-        <div class="col-lg-12">
-          <a class="" href="javascript:;" (click)="showNotes=!showNotes" 
-            i18n>Notes ({{po().notes().length}})</a>
-          <span class="pl-2 pr-2" i18n> | </span>
-          <a [queryParams]="{f: 'acqpo:id', val1: poId}"
-            routerLink="/staff/acq/search/invoices" i18n>Invoices ({{invoiceCount}})</a>
-          <span class="pl-2 pr-2" i18n> | </span>
-          <a href="/eg/acq/invoice/view?create=1&attach_po={{poId}}"
-            i18n>Create Invoice</a>
-          <span class="pl-2 pr-2" i18n> | </span>
-          <a routerLink="./edi" i18n>EDI Messages ({{ediMessageCount}})</a>
-          <span class="pl-2 pr-2" i18n> | </span>
-          <a routerLink="./history" i18n>History</a>
-          <span class="pl-2 pr-2" i18n> | </span>
-          <a routerLink="./printer" i18n>Print</a>
-          <ng-container *ngIf="po().state() == 'on-order' || po().state() == 'pending'">
-            <span class="pl-2 pr-2" i18n> | </span>
-            <a (click)="cancelPo()" href="javascript:;" i18n>Cancel Order</a>
-          </ng-container>
-          <ng-container *ngIf="canActivate === true">
-            <span class="pl-2 pr-2" i18n> | </span>
-            <a (click)="activatePo()" href="javascript:;" i18n>Activate Order</a>
-          </ng-container>
+
+      <div class="row">
+        <div class="col-lg-4 d-flex">
+          <div class="flex-2" i18n>PO Name:</div>
+          <div class="flex-4">
+            <ng-container *ngIf="editPoName">
+              <input id='pl-name-input' type="text" class="form-control"
+                [(ngModel)]="newPoName" (keyup.enter)="toggleNameEdit(true)" 
+                (blur)="toggleNameEdit()"/>
+            </ng-container>
+            <ng-container *ngIf="!editPoName">
+              <a (click)="toggleNameEdit()" href='javascript:;'
+                class='font-weight-bold'>{{po().name()}}</a>
+            </ng-container>
+          </div> 
+        </div>
+        <div class="col-lg-8 d-flex">
+          <div class="flex-1" i18n>Activated:</div>
+          <div class="flex-6">
+            <span *ngIf="po().order_date()">{{po().order_date() | date:'short'}}</span>
+            <span *ngIf="!po().order_date()" i18n>N/A</span>
+          </div>
+        </div>
+      </div>
+
+      <div class="row">
+        <div class="col-lg-4 d-flex">
+          <div class="flex-2" i18n>Provider:</div>
+          <div class="flex-4">
+            <a routerLink="/staff/acq/provider/{{po().provider().id()}}/details" i18n>
+              {{po().provider().name()}} ({{po().provider().code()}})
+            </a>
+          </div>
+        </div>
+        <div class="col-lg-8 d-flex">
         </div>
       </div>
+
+      <div class="row">
+        <div class="col-lg-4 d-flex">
+          <div class="flex-2" i18n>Lineitems:</div>
+          <div class="flex-4">{{po().lineitem_count()}}</div>
+        </div>
+        <div class="col-lg-8 d-flex">
+          <div class="form-check form-check-inline">
+            <input class="ml-0 form-check-input" type="checkbox" (change)="setCanActivate()"
+              id="zero-copy-cbox" [(ngModel)]="zeroCopyActivate"/>
+            <label class="form-check-label" for="zero-copy-cbox" i18n>
+              Allow Activation with Zero-Copy Lineitems?
+            </label>
+          </div>
+        </div>
+      </div>
+
     </div>
     <div class="col-lg-3">
       <div class="row">
       </div>
     </div>
   </div>
+  <hr class="p-0 m-0 mt-1"/>
+  <div class="row mt-1">
+    <div class="col-lg-12">
+      <a class="" href="javascript:;" (click)="showNotes=!showNotes" 
+        i18n>Notes ({{po().notes().length}})</a>
+      <span class="pl-2 pr-2" i18n> | </span>
+      <a [queryParams]="{f: 'acqpo:id', val1: poId}"
+        routerLink="/staff/acq/search/invoices" i18n>Invoices ({{invoiceCount}})</a>
+      <span class="pl-2 pr-2" i18n> | </span>
+      <a href="/eg/acq/invoice/view?create=1&attach_po={{poId}}"
+        i18n>Create Invoice</a>
+      <span class="pl-2 pr-2" i18n> | </span>
+      <a routerLink="./edi" i18n>EDI Messages ({{ediMessageCount}})</a>
+      <span class="pl-2 pr-2" i18n> | </span>
+      <a routerLink="./history" i18n>History</a>
+      <span class="pl-2 pr-2" i18n> | </span>
+      <a routerLink="./printer" i18n>Print</a>
+      <ng-container *ngIf="po().state() == 'on-order' || po().state() == 'pending'">
+        <span class="pl-2 pr-2" i18n> | </span>
+        <a (click)="cancelPo()" href="javascript:;" i18n>Cancel Order</a>
+      </ng-container>
+      <ng-container *ngIf="canActivate === true">
+        <span class="pl-2 pr-2" i18n> | </span>
+        <a (click)="activatePo()" href="javascript:;" i18n>Activate Order</a>
+      </ng-container>
+      <ng-container *ngIf="canActivate === true">
+        <span class="pl-2 pr-2" i18n> | </span>
+        <a (click)="activatePo(true)" href="javascript:;" i18n>
+          Activate Without Loading Items
+        </a>
+      </ng-container>
+    </div>
+  </div>
+
   <div class="row" *ngIf="showNotes">
     <div class="col-lg-10 offset-lg-1 p-2 mt-2 shadow">
       <eg-po-notes [po]="po()" (closeRequested)="showNotes = false">
index 0a77bb8..21799f2 100644 (file)
@@ -37,6 +37,7 @@ export class PoSummaryComponent implements OnInit {
     ediMessageCount = 0;
     invoiceCount = 0;
     showNotes = false;
+    zeroCopyActivate = false;
     canActivate: boolean = null;
 
     activationBlocks: EgEvent[] = [];
@@ -159,9 +160,13 @@ export class PoSummaryComponent implements OnInit {
             return;
         }
 
+        const options = {
+            zero_copy_activate: this.zeroCopyActivate
+        };
+
         this.net.request('open-ils.acq',
             'open-ils.acq.purchase_order.activate.dry_run',
-            this.auth.token(), this.poId
+            this.auth.token(), this.poId, null, options
 
         ).pipe(tap(resp => {
 
@@ -176,27 +181,30 @@ export class PoSummaryComponent implements OnInit {
             }
 
             this.canActivate = false;
-
-            // TODO More logic likely needed here to handle zero-copy
-            // activation / ACQ_LINEITEM_NO_COPIES
         });
     }
 
-    activatePo() {
-        // TODO This code bypasses the Vandelay UI and force-loads the records.
-
+    activatePo(noAssets?: boolean) {
         this.activationEvent = null;
         this.progressDialog.open();
         this.progressDialog.update({max: this.po().lineitem_count() * 3});
 
+         // Bypass any Vandelay choices and force-load all records.
+         // TODO: Add intermediate Vandelay options.
+        const vandelay = {
+            import_no_match: true,
+            queue_name: `ACQ ${new Date().toISOString()}`
+        };
+
+        const options = {
+            zero_copy_activate: this.zeroCopyActivate,
+            no_assets: noAssets
+        };
+
         this.net.request(
             'open-ils.acq',
             'open-ils.acq.purchase_order.activate',
-            this.auth.token(), this.poId, {
-                // Import all records, no merging, etc.
-                import_no_match: true,
-                queue_name: `ACQ ${new Date().toISOString()}`
-            }
+            this.auth.token(), this.poId, vandelay, options
         ).subscribe(resp => {
             const evt = this.evt.parse(resp);