funds: flesh out more links for the fund debits table
authorGalen Charlton <gmc@equinoxOLI.org>
Thu, 3 Jun 2021 16:09:17 +0000 (12:09 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 3 Jun 2021 16:09:17 +0000 (12:09 -0400)
LH#12

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/admin/acq/funds/fund-details-dialog.component.ts

index a04515b..a078e70 100644 (file)
@@ -145,10 +145,14 @@ export class FundDetailsDialogComponent
                 };
             } else if (idlClass === 'acqfdeb') {
                 search.push({ fund: this.fundId });
-                searchOps['flesh'] = 2;
+                searchOps['flesh'] = 3;
                 searchOps['flesh_fields'] = {
-                    'acqfdeb': ['invoice_entry'],
-                    'acqie': ['invoice', 'purchase_order', 'lineitem']
+                    'acqfdeb': ['invoice_entry','invoice_items','po_items','lineitem_details'],
+                    'acqie': ['invoice', 'purchase_order', 'lineitem'],
+                    'acqii': ['invoice'],
+                    'acqpoi': ['purchase_order'],
+                    'acqlid': ['lineitem'],
+                    'jub': ['purchase_order']
                 };
             }
 
@@ -172,6 +176,9 @@ export class FundDetailsDialogComponent
             row['po_id'] = null;
             row['po_name'] = null;
             row['li_id'] = null;
+            // TODO need to verify this, but we may be able to get away with
+            //      the assumption that a given fund debit never has more than
+            //      one line item, purchase order, or invoice associated with it.
             if (row.invoice_entry()) {
                 if (row.invoice_entry().invoice()) {
                     row['invoice_id'] = row.invoice_entry().invoice().id();
@@ -185,6 +192,25 @@ export class FundDetailsDialogComponent
                     row['li_id'] = row.invoice_entry().lineitem().id();
                 }
             }
+            if (row.lineitem_details() && row.lineitem_details().length) {
+                if (row.lineitem_details()[0].lineitem().purchase_order()) {
+                    row['li_id'] = row.lineitem_details()[0].lineitem().id();
+                    row['po_id'] = row.lineitem_details()[0].lineitem().purchase_order().id();
+                    row['po_name'] = row.lineitem_details()[0].lineitem().purchase_order().name();
+                }
+            }
+            if (row.po_items() && row.po_items().length) {
+                if (row.po_items()[0].purchase_order()) {
+                    row['po_id'] = row.po_items()[0].purchase_order().id();
+                    row['po_name'] = row.po_items()[0].purchase_order().name();
+                }
+            }
+            if (row.invoice_items() && row.invoice_items().length) {
+                if (row.invoice_items()[0].invoice()) {
+                    row['invoice_id'] = row.invoice_items()[0].invoice().id();
+                    row['vendor_invoice_id'] = row.invoice_items()[0].invoice().inv_ident();
+                }
+            }
         }
         return of(row);
     }