LP#1929749: insert current year as FY if no fiscal years are actually defined
authorGalen Charlton <gmc@equinoxOLI.org>
Tue, 17 May 2022 15:19:22 +0000 (15:19 +0000)
committerGalen Charlton <gmc@equinoxOLI.org>
Tue, 17 May 2022 15:19:22 +0000 (15:19 +0000)
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/acq/picklist/upload.service.ts

index 2a61d5d..8e555ae 100644 (file)
@@ -142,6 +142,15 @@ export class PicklistUploadService {
           {atomic: true}
         ).toPromise().then(years => {
             this.fiscalYears = years.filter( y => y.calendar() === this.org.get(org).fiscal_calendar());
+            // if there are no entries, inject a special entry for the current year
+            if (!this.fiscalYears.length) {
+                const afy = this.idl.create('acqfy');
+                afy.id(-1);
+                afy.calendar(-1);
+                const now = new Date();
+                afy.year(now.getFullYear());
+                this.fiscalYears = [ afy ];
+            }
             return this.fiscalYears;
         });
     }