Skip to content

Commit

Permalink
Bump to 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Jan 24, 2024
1 parent 8c749dc commit b390541
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
25 changes: 13 additions & 12 deletions ui/src/app/social-service-editor/social-service-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { CachedApiService } from '../cached-api.service';
import { ObudgetApiService } from '../obudget-api.service';
import { ApiService } from 'etl-server';

export const MIN_YEAR = 2017;
export const MAX_YEAR = 2023;

export class SocialServiceUtils {

offices: any[] = [];
Expand Down Expand Up @@ -31,8 +34,6 @@ export class SocialServiceUtils {
)`;

clearModal = new Subject<void>();
MIN_YEAR = 2017;
MAX_YEAR = 2022;

constructor(private datarecord: any, private def: any,
private cachedApi: CachedApiService, private api: ObudgetApiService, private etlApi: ApiService) {
Expand Down Expand Up @@ -114,7 +115,7 @@ export class SocialServiceUtils {
}
this.datarecord.budgetItems = (this.datarecord.budgetItems as any[]).sort(
(a, b) => b.year - a.year
).filter((item) => item.year >= this.MIN_YEAR);
).filter((item) => item.year >= MIN_YEAR);
this.datarecord.manualBudget = this.datarecord.manualBudget || [];

const existingManualYears = {};
Expand All @@ -123,7 +124,7 @@ export class SocialServiceUtils {
});
this.datarecord.budgetItems.forEach((item) => {
const year = item.year;
if (year >= this.MIN_YEAR && year <= this.MAX_YEAR && !existingManualYears[year]) {
if (year >= MIN_YEAR && year <= MAX_YEAR && !existingManualYears[year]) {
const rec = {year: year, approved: null, executed: null};
this.datarecord.manualBudget.push(rec);
existingManualYears[year] = rec;
Expand All @@ -137,7 +138,7 @@ export class SocialServiceUtils {

this.datarecord.manualBudget = (this.datarecord.manualBudget as any[]).sort(
(a, b) => b.year - a.year
).filter((x) => x.approved || x.year >= this.MIN_YEAR);
).filter((x) => x.approved || x.year >= MIN_YEAR);

const conditions = [];
const budgets = [];
Expand Down Expand Up @@ -363,7 +364,7 @@ export class SocialServiceUtils {
});

// // Min year for manualBudget
// let firstYear: any = this.MAX_YEAR;
// let firstYear: any = MAX_YEAR;
// for (const mb of this.datarecord.manualBudget) {
// if (mb.year < firstYear && mb.approved) {
// firstYear = mb.year;
Expand All @@ -375,7 +376,7 @@ export class SocialServiceUtils {
if (supplier.year_activity_end < supplier.year_activity_start) {
supplier.year_activity_start = supplier.year_activity_end - 1;
}
if (supplier.year_activity_start > this.MAX_YEAR) {
if (supplier.year_activity_start > MAX_YEAR) {
supplier.year_activity_start = null;
}
// if (supplier.year_activity_start > firstYear) {
Expand All @@ -385,7 +386,7 @@ export class SocialServiceUtils {
}

refreshExistingBeneficiaries() {
const firstYear = this.MIN_YEAR;
const firstYear = MIN_YEAR;
const lastYear = (new Date()).getFullYear();
const existingYears = this.datarecord.beneficiaries.map((x) => x.year);
const num_beneficiaries = null;
Expand Down Expand Up @@ -469,7 +470,7 @@ export class SocialServiceUtils {
}
}
}
// row.year_activity_start = row.year_activity_start || this.MAX_YEAR;
// row.year_activity_start = row.year_activity_start || MAX_YEAR;
} else if (row.related === 'no') {
this.datarecord.non_suppliers.push(row);
} else if (row.related === 'suggestion') {
Expand All @@ -484,7 +485,7 @@ export class SocialServiceUtils {
if (row.active === 'yes') {
row.year_activity_end = null;
} else {
row.year_activity_end = this.MAX_YEAR;
row.year_activity_end = MAX_YEAR;
}
}
}
Expand All @@ -504,7 +505,7 @@ export class SocialServiceUtils {
if (item.history) {
for (let historyItem of Object.keys(item.history)) {
const year = parseInt(historyItem);
if (year < this.MIN_YEAR) continue;
if (year < MIN_YEAR) continue;
for (const codeTitleItem of item.history[historyItem].code_titles) {
const codeTitle = codeTitleItem.split(':');
const code = codeTitle[0];
Expand Down Expand Up @@ -536,7 +537,7 @@ export class SocialServiceUtils {
}
const sql = `
SELECT code, title, year from raw_budget
where (${conditions.join('')}) and net_revised != 0 and year >= ${this.MIN_YEAR}
where (${conditions.join('')}) and net_revised != 0 and year >= ${MIN_YEAR}
order by year desc, code
`;
this.api.query(sql)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
import { ListStateService } from '../list-state.service';
import { FILTERS, ItemFilter } from '../social-service-list/item-filters';
import { MAX_YEAR } from '../social-service-editor/social-service-utils';

@Component({
selector: 'app-social-service-list-item',
Expand Down Expand Up @@ -31,7 +32,7 @@ export class SocialServiceListItemComponent implements OnChanges {
let ret: any = null;
if (item.item) {
const updated = item.item.manualBudget && item.item.manualBudget.length > 0 &&
item.item.manualBudget[0].year >= 2022;
item.item.manualBudget[0].year >= MAX_YEAR;
// && (item.item.tenders || []).every((tender) => !tender.survey || tender.survey.submitted);
const complete = !!item.item.complete && !item.item.deleted;
const keepPrivate = !!item.item.keepPrivate;
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/social-service-list/item-filters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import { MAX_YEAR } from '../social-service-editor/social-service-utils';
export class ItemFilter {
public condition(item: any): boolean {
return true;
Expand Down Expand Up @@ -27,7 +27,7 @@ export class ItemFilterUpdateNeeded extends ItemFilter {
public condition(item: any): boolean {
const tenders = item.tenders || [];
return !item.deleted && item.complete && (
(item.manualBudget && item.manualBudget.length > 0 && item.manualBudget[0].year < 2022)
(item.manualBudget && item.manualBudget.length > 0 && item.manualBudget[0].year < MAX_YEAR)
// || tenders.any((tender) => tender.survey && !tender.survey.submitted)
);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '2021.05.26.18';
export const VERSION = '2024.01.24.01';

0 comments on commit b390541

Please sign in to comment.