|
| 1 | +load('../../../utils/uuid.js'); |
| 2 | +load('../../../utils/audit.js'); |
| 3 | +load('../../../utils/program.js'); |
| 4 | +load("../../../utils/addService.js") |
| 5 | + |
| 6 | +const adminUserId = "system"; |
| 7 | +const invoiceScoreId = '72dK3150f-763b-4taf-j49f-60a2dbda4398'; |
| 8 | +const scoreId = '5803150k-653q-ubag-s49d-60a2dbda0784'; |
| 9 | +var serviceName = "Establishing Agreements" |
| 10 | +var newOutputs = [ |
| 11 | + {formName: "NHT Output Report", sectionName: serviceName}, |
| 12 | + {formName: "Grants and Others Progress Report", sectionName: serviceName}, |
| 13 | + {formName: "Procurement Output Report", sectionName: serviceName} |
| 14 | +]; |
| 15 | + |
| 16 | + |
| 17 | +addService(serviceName, NumberInt(48), undefined, undefined, newOutputs, adminUserId) |
| 18 | + |
| 19 | +let scores = [ |
| 20 | + { |
| 21 | + scoreId: invoiceScoreId, |
| 22 | + entityTypes: undefined, |
| 23 | + tags: [], |
| 24 | + displayType: '', |
| 25 | + entity: 'Activity', |
| 26 | + outputType: serviceName, |
| 27 | + isOutputTarget: false, |
| 28 | + category: "Reporting", |
| 29 | + status: 'active', |
| 30 | + label: 'Invoiced number of agreements established', |
| 31 | + description: '', |
| 32 | + configuration: { |
| 33 | + childAggregations: [ |
| 34 | + { |
| 35 | + filter: { |
| 36 | + property: 'name', |
| 37 | + filterValue: serviceName, |
| 38 | + type: 'filter' |
| 39 | + }, |
| 40 | + childAggregations: [ |
| 41 | + { |
| 42 | + property: 'data.numberAgreementsEstablishedInvoiced', |
| 43 | + type: 'SUM' |
| 44 | + } |
| 45 | + ] |
| 46 | + } |
| 47 | + ] |
| 48 | + } |
| 49 | + } |
| 50 | + , |
| 51 | + { |
| 52 | + _id: ObjectId('576ddg76a458s30890b60jlk5'), |
| 53 | + scoreId: scoreId, |
| 54 | + label: 'Number of agreements established', |
| 55 | + status: 'active', |
| 56 | + isOutputTarget: true, |
| 57 | + category: "Natural Heritage Trust", |
| 58 | + outputType: serviceName, |
| 59 | + configuration: { |
| 60 | + childAggregations: [ |
| 61 | + { |
| 62 | + filter: { |
| 63 | + property: 'name', |
| 64 | + filterValue: serviceName, |
| 65 | + type: 'filter' |
| 66 | + }, |
| 67 | + childAggregations: [ |
| 68 | + { |
| 69 | + property: 'data.numberAgreementsEstablished', |
| 70 | + type: 'SUM' |
| 71 | + } |
| 72 | + ] |
| 73 | + } |
| 74 | + ] |
| 75 | + }, |
| 76 | + dateCreated: ISODate('2025-03-13T04:40:11.160Z'), |
| 77 | + lastUpdated: ISODate('2025-03-13T04:40:11.160Z'), |
| 78 | + relatedScores: [ |
| 79 | + { |
| 80 | + description: 'Invoiced by', |
| 81 | + scoreId: invoiceScoreId |
| 82 | + } |
| 83 | + ] |
| 84 | + }]; |
| 85 | + |
| 86 | + |
| 87 | +for (let i=0; i<scores.length; i+=2) { |
| 88 | + let invoiced = scores[i]; |
| 89 | + let delivered = scores[i+1]; |
| 90 | + |
| 91 | + let savedInvoiced = db.score.findOne({scoreId: invoiced.scoreId}); |
| 92 | + if (!savedInvoiced) { |
| 93 | + audit(invoiced, invoiced.scoreId, 'au.org.ala.ecodata.Score', adminUserId, null, 'Insert'); |
| 94 | + db.score.insertOne(invoiced); |
| 95 | + } |
| 96 | + |
| 97 | + let savedDelivered = db.score.findOne({scoreId: delivered.scoreId}); |
| 98 | + if (!savedDelivered) { |
| 99 | + audit(delivered, delivered.scoreId, 'au.org.ala.ecodata.Score', adminUserId, null, 'Insert'); |
| 100 | + db.score.insertOne(delivered); |
| 101 | + } |
| 102 | +} |
| 103 | + |
| 104 | +var excludedPrograms = [] |
| 105 | +var programServices = [ |
| 106 | + { |
| 107 | + serviceTargets: [scoreId], |
| 108 | + serviceId: NumberInt(49) |
| 109 | + } |
| 110 | +]; |
| 111 | + |
0 commit comments