@neutron.co.id/pendidikan-operation 1.16.1 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +155 -13
- package/build/index.d.ts +23 -1
- package/build/index.mjs +154 -14
- package/package.json +8 -8
package/build/index.cjs
CHANGED
|
@@ -921,8 +921,8 @@ const presenceSessionStudent = operation.Action.define({
|
|
|
921
921
|
execute: async (input, stream) => {
|
|
922
922
|
guard(stream, "streamRequired");
|
|
923
923
|
guard(input, "inputRequired");
|
|
924
|
-
const
|
|
925
|
-
const sessionResult = await
|
|
924
|
+
const action = stream.actions.data;
|
|
925
|
+
const sessionResult = await action.getOne.execute(
|
|
926
926
|
{
|
|
927
927
|
model: "neu:jadwal:classSession",
|
|
928
928
|
id: input.sessionId || "",
|
|
@@ -936,17 +936,38 @@ const presenceSessionStudent = operation.Action.define({
|
|
|
936
936
|
stream
|
|
937
937
|
);
|
|
938
938
|
const session = sessionResult.value;
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
939
|
+
const attendance = await action.createOne.execute(
|
|
940
|
+
{
|
|
941
|
+
model: "neu:jadwal:classAttendance",
|
|
942
|
+
data: {
|
|
943
|
+
classSessionId: input.sessionId,
|
|
944
|
+
studentId: input.studentId,
|
|
945
|
+
teacherId: input.teacherId,
|
|
946
|
+
classSessionBranchIds: session.branchIds,
|
|
947
|
+
presenceType: "student",
|
|
948
|
+
isAbsent: false,
|
|
949
|
+
sessionType: session.type,
|
|
950
|
+
presenceAt: /* @__PURE__ */ new Date(),
|
|
951
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
952
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
953
|
+
},
|
|
954
|
+
query: query.Query.define({ fields: { id: 1 } })
|
|
955
|
+
},
|
|
956
|
+
stream
|
|
957
|
+
);
|
|
958
|
+
await action.syncMany.execute(
|
|
959
|
+
{
|
|
960
|
+
model: "neu:jadwal:classAttendance",
|
|
961
|
+
// id: payload.input.id,
|
|
962
|
+
useDry: false,
|
|
963
|
+
query: query.Query.define({
|
|
964
|
+
filter: {
|
|
965
|
+
_id: attendance.value.id
|
|
966
|
+
}
|
|
967
|
+
})
|
|
968
|
+
},
|
|
969
|
+
stream
|
|
970
|
+
);
|
|
950
971
|
return core.Result.ok({
|
|
951
972
|
state: "presenceSessionStudent",
|
|
952
973
|
message: "Presensi berhasil!"
|
|
@@ -2211,6 +2232,7 @@ function useJadwal(stream) {
|
|
|
2211
2232
|
return {
|
|
2212
2233
|
getClassSessions,
|
|
2213
2234
|
getManyClassSessions,
|
|
2235
|
+
updateClassSession,
|
|
2214
2236
|
updateBatchClassSessions,
|
|
2215
2237
|
syncManyClassSessions
|
|
2216
2238
|
};
|
|
@@ -2244,6 +2266,18 @@ function useJadwal(stream) {
|
|
|
2244
2266
|
throw result;
|
|
2245
2267
|
return result.value;
|
|
2246
2268
|
}
|
|
2269
|
+
async function updateClassSession(classSession, data) {
|
|
2270
|
+
await stream?.actions.data.updateOne.execute(
|
|
2271
|
+
{
|
|
2272
|
+
model: "neu:jadwal:classSession",
|
|
2273
|
+
id: classSession.id || "",
|
|
2274
|
+
data: {
|
|
2275
|
+
teacherTravelWages: data
|
|
2276
|
+
}
|
|
2277
|
+
},
|
|
2278
|
+
stream
|
|
2279
|
+
);
|
|
2280
|
+
}
|
|
2247
2281
|
async function updateBatchClassSessions(classSessions) {
|
|
2248
2282
|
const operations = [];
|
|
2249
2283
|
for (const classSession of classSessions) {
|
|
@@ -2473,6 +2507,111 @@ const syncClassSessions = operation.Action.define({
|
|
|
2473
2507
|
}
|
|
2474
2508
|
});
|
|
2475
2509
|
|
|
2510
|
+
const SetTravelWageSessionsSchema = z.z.object({
|
|
2511
|
+
classSessionIds: z.z.array(z.z.objectId()).optional().explain({
|
|
2512
|
+
label: "Class Session IDs"
|
|
2513
|
+
})
|
|
2514
|
+
});
|
|
2515
|
+
|
|
2516
|
+
const setTravelWageSessions = operation.Action.define({
|
|
2517
|
+
key: "setTravelWageSessions",
|
|
2518
|
+
name: "Sync Class Sessions",
|
|
2519
|
+
type: "command",
|
|
2520
|
+
category: "domain",
|
|
2521
|
+
execute: async (input, stream) => {
|
|
2522
|
+
const log = useLog("syncClassSessions", false);
|
|
2523
|
+
guard(stream, "streamRequired");
|
|
2524
|
+
const { getActorId } = operation.useStream(stream);
|
|
2525
|
+
const { validate } = operation.useValidation(stream, SetTravelWageSessionsSchema);
|
|
2526
|
+
const { getManyClassSessions, updateClassSession } = useJadwal(stream);
|
|
2527
|
+
const fragment = {
|
|
2528
|
+
id: 1,
|
|
2529
|
+
title: 1,
|
|
2530
|
+
subtitle: 1,
|
|
2531
|
+
type: 1,
|
|
2532
|
+
startedAt: 1,
|
|
2533
|
+
endedAt: 1,
|
|
2534
|
+
buildingId: 1,
|
|
2535
|
+
prevSession: 1,
|
|
2536
|
+
nextSession: 1
|
|
2537
|
+
};
|
|
2538
|
+
try {
|
|
2539
|
+
getActorId({ throw: true });
|
|
2540
|
+
const data = validate(input);
|
|
2541
|
+
log.object("input", data);
|
|
2542
|
+
if (!data.classSessionIds?.length) {
|
|
2543
|
+
return core.Result.ok({
|
|
2544
|
+
state: "noClassSessions",
|
|
2545
|
+
message: "No class sessions.",
|
|
2546
|
+
data: {}
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
let classSessions = [];
|
|
2550
|
+
classSessions = await getManyClassSessions({
|
|
2551
|
+
filter: { _id: { $in: data.classSessionIds } },
|
|
2552
|
+
fragment
|
|
2553
|
+
});
|
|
2554
|
+
for await (const session of classSessions) {
|
|
2555
|
+
const resultData = await _getTravelWage(stream, session);
|
|
2556
|
+
console.log("hasil session wage", resultData);
|
|
2557
|
+
await updateClassSession(session, resultData);
|
|
2558
|
+
}
|
|
2559
|
+
return core.Result.ok({
|
|
2560
|
+
state: "allCompleted",
|
|
2561
|
+
message: "All TravelWages have been set.",
|
|
2562
|
+
data: {}
|
|
2563
|
+
});
|
|
2564
|
+
} catch (error) {
|
|
2565
|
+
if (error?.isFailure)
|
|
2566
|
+
throw error;
|
|
2567
|
+
console.error(error);
|
|
2568
|
+
return core.Result.fail({
|
|
2569
|
+
state: `setTravelWageFailed`,
|
|
2570
|
+
message: `Failed to set travel wages.`,
|
|
2571
|
+
error: error?.toString()
|
|
2572
|
+
});
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
});
|
|
2576
|
+
async function _getTravelWage(stream, classSession) {
|
|
2577
|
+
const destBuildingId = classSession.buildingId;
|
|
2578
|
+
const result = classSession.prevSession?.map(async (item) => {
|
|
2579
|
+
const initialBuildingId = item.session?.buildingId;
|
|
2580
|
+
console.log("hasil initialBuildingId", initialBuildingId);
|
|
2581
|
+
console.log("hasil destBuildingId", destBuildingId);
|
|
2582
|
+
if (!destBuildingId || !initialBuildingId)
|
|
2583
|
+
return {};
|
|
2584
|
+
const cost = await stream.actions.data.getMany.execute(
|
|
2585
|
+
{
|
|
2586
|
+
model: "neu:akademik:travelWage",
|
|
2587
|
+
query: query.Query.define({
|
|
2588
|
+
filter: {
|
|
2589
|
+
departureBuildingId: { $eq: initialBuildingId },
|
|
2590
|
+
arrivalBuildingId: { $eq: destBuildingId }
|
|
2591
|
+
},
|
|
2592
|
+
fields: {
|
|
2593
|
+
amount: 1,
|
|
2594
|
+
maxAmount: 1,
|
|
2595
|
+
increasePercentage: 1
|
|
2596
|
+
}
|
|
2597
|
+
})
|
|
2598
|
+
},
|
|
2599
|
+
stream
|
|
2600
|
+
);
|
|
2601
|
+
console.log("hasil cost", cost.value[0]);
|
|
2602
|
+
return cost.value[0] == null ? {} : {
|
|
2603
|
+
teacherId: item.id,
|
|
2604
|
+
teacherName: item.name,
|
|
2605
|
+
travelWage: cost.value[0]
|
|
2606
|
+
};
|
|
2607
|
+
});
|
|
2608
|
+
const data = await Promise.all(result).then((item) => {
|
|
2609
|
+
return item;
|
|
2610
|
+
});
|
|
2611
|
+
console.log("hasil data", data);
|
|
2612
|
+
return data;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2476
2615
|
const getGradingCount = operation.Action.define({
|
|
2477
2616
|
key: "getGradingCount",
|
|
2478
2617
|
name: "Get GradingCount",
|
|
@@ -3985,6 +4124,7 @@ const actions = {
|
|
|
3985
4124
|
checkClassAttendance,
|
|
3986
4125
|
syncClassSessions,
|
|
3987
4126
|
getClassSessionConflicts,
|
|
4127
|
+
setTravelWageSessions,
|
|
3988
4128
|
// Penilaian
|
|
3989
4129
|
getGradingCount,
|
|
3990
4130
|
// Rasionalisasi
|
|
@@ -4011,6 +4151,7 @@ const actions = {
|
|
|
4011
4151
|
|
|
4012
4152
|
exports.GetClassSessionConflictsSchema = GetClassSessionConflictsSchema;
|
|
4013
4153
|
exports.PrepareExperienceSchema = PrepareExperienceSchema;
|
|
4154
|
+
exports.SetTravelWageSessionsSchema = SetTravelWageSessionsSchema;
|
|
4014
4155
|
exports.SyncClassSessionsSchema = SyncClassSessionsSchema;
|
|
4015
4156
|
exports._calculateComparison = _calculateComparison;
|
|
4016
4157
|
exports.acceptQuestion = acceptQuestion;
|
|
@@ -4046,6 +4187,7 @@ exports.rasionalizeGrading = rasionalizeGrading;
|
|
|
4046
4187
|
exports.registerOfficePendidikanHooks = registerOfficePendidikanHooks;
|
|
4047
4188
|
exports.sendAnswer = sendAnswer;
|
|
4048
4189
|
exports.sendQuestion = sendQuestion;
|
|
4190
|
+
exports.setTravelWageSessions = setTravelWageSessions;
|
|
4049
4191
|
exports.syncClassSessions = syncClassSessions;
|
|
4050
4192
|
exports.syncCommitment = syncCommitment;
|
|
4051
4193
|
exports.syncModel = syncModel;
|
package/build/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ type GetStudentIdAction = typeof getStudentId;
|
|
|
43
43
|
interface PresenceSessionStudentInput {
|
|
44
44
|
sessionId: string;
|
|
45
45
|
studentId: string;
|
|
46
|
+
teacherId: string;
|
|
46
47
|
}
|
|
47
48
|
interface PresenceSessionStudentOutput {
|
|
48
49
|
code: number;
|
|
@@ -280,6 +281,24 @@ declare const syncClassSessions: Action<"syncClassSessions", {
|
|
|
280
281
|
}, SyncClassSessionsOutput, SyncClassSessionsMeta>;
|
|
281
282
|
type SyncClassSessionsAction = typeof syncClassSessions;
|
|
282
283
|
|
|
284
|
+
declare const SetTravelWageSessionsSchema: z.ZodObject<{
|
|
285
|
+
classSessionIds: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
286
|
+
}, "strip", z.ZodTypeAny, {
|
|
287
|
+
classSessionIds?: string[] | undefined;
|
|
288
|
+
}, {
|
|
289
|
+
classSessionIds?: string[] | undefined;
|
|
290
|
+
}>;
|
|
291
|
+
|
|
292
|
+
type SetTravelWageSessionsInput = z.parse<typeof SetTravelWageSessionsSchema>;
|
|
293
|
+
interface SetTravelWageSessionsOutput {
|
|
294
|
+
}
|
|
295
|
+
interface SetTravelWageSessionsMeta {
|
|
296
|
+
}
|
|
297
|
+
declare const setTravelWageSessions: Action<"setTravelWageSessions", {
|
|
298
|
+
classSessionIds?: string[] | undefined;
|
|
299
|
+
}, SetTravelWageSessionsOutput, SetTravelWageSessionsMeta>;
|
|
300
|
+
type SetTravelWageSessionsAction = typeof setTravelWageSessions;
|
|
301
|
+
|
|
283
302
|
interface GetGradingCountInput {
|
|
284
303
|
userId: any;
|
|
285
304
|
}
|
|
@@ -553,6 +572,9 @@ declare const actions: {
|
|
|
553
572
|
getClassSessionConflicts: _neon_id_operation.Action<"getClassSessionConflicts", {
|
|
554
573
|
filter?: any;
|
|
555
574
|
}, GetClassSessionConflictsOutput, GetClassSessionConflictsMeta>;
|
|
575
|
+
setTravelWageSessions: _neon_id_operation.Action<"setTravelWageSessions", {
|
|
576
|
+
classSessionIds?: string[] | undefined;
|
|
577
|
+
}, SetTravelWageSessionsOutput, SetTravelWageSessionsMeta>;
|
|
556
578
|
getGradingCount: _neon_id_operation.Action<"getGradingCount", GetGradingCountInput, GetGradingCountOutput, GetGradingCountMeta>;
|
|
557
579
|
addManyGradingComponent: _neon_id_operation.Action<"addManyGradingComponent", AddManyGradingComponentInput, AddManyGradingComponentOutput, AddManyGradingComponentMeta>;
|
|
558
580
|
calculateGrading: _neon_id_operation.Action<"calculateGrading", CalculateGradingInput, CalculateGradingOutput, CalculateGradingMeta>;
|
|
@@ -574,4 +596,4 @@ declare const actions: {
|
|
|
574
596
|
sendQuestion: _neon_id_operation.Action<"sendQuestion", SendQuestionInput, SendQuestionOutput, SendQuestionMeta>;
|
|
575
597
|
};
|
|
576
598
|
|
|
577
|
-
export { AcceptQuestionAction, AcceptQuestionInput, AcceptQuestionMeta, AcceptQuestionOutput, AddManyGradingComponentAction, AddManyGradingComponentInput, AddManyGradingComponentMeta, AddManyGradingComponentOutput, AllConflictAction, AllConflictInput, AllConflictMeta, AllConflictOutput, CalculateGradingAction, CalculateGradingInput, CalculateGradingMeta, CalculateGradingOutput, CalculateManyComparatorAction, CalculateManyComparatorInput, CalculateManyComparatorMeta, CalculateManyComparatorOutput, CalculateOneComparatorAction, CalculateOneComparatorInput, CalculateOneComparatorMeta, CalculateOneComparatorOutput, CheckClassAttendanceAction, CheckClassAttendanceInput, CheckClassAttendanceMeta, CheckClassAttendanceOutput, ClassSessionInventoryOccursAction, ClassSessionInventoryOccursInput, ClassSessionInventoryOccursMeta, ClassSessionInventoryOccursOutput, ClassSessionInventoryPreparationAction, ClassSessionInventoryPreparationInput, ClassSessionInventoryPreparationMeta, ClassSessionInventoryPreparationOutput, ClearAllOverridesAction, ClearAllOverridesInput, ClearAllOverridesMeta, ClearAllOverridesOutput, ClearGradingAction, ClearGradingInput, ClearGradingMeta, ClearGradingOutput, ClearOneOverridesAction, ClearOneOverridesInput, ClearOneOverridesMeta, ClearOneOverridesOutput, CreateGradingAndScoresAction, CreateGradingAndScoresInput, CreateGradingAndScoresMeta, CreateGradingAndScoresOutput, CreateManySessionAction, CreateManySessionInput, CreateManySessionMeta, CreateManySessionOutput, DeleteManySessionAction, DeleteManySessionInput, DeleteManySessionMeta, DeleteManySessionOutput, EditAnswerAction, EditAnswerInput, EditAnswerMeta, EditAnswerOutput, GenerateGradingAction, GenerateGradingInput, GenerateGradingMeta, GenerateGradingOutput, GetClassSessionConflictsAction, GetClassSessionConflictsInput, GetClassSessionConflictsMeta, GetClassSessionConflictsOutput, GetClassSessionConflictsSchema, GetGradingCountAction, GetGradingCountInput, GetGradingCountMeta, GetGradingCountOutput, GetQuestionCountAction, GetQuestionCountInput, GetQuestionCountMeta, GetQuestionCountOutput, GetStaffIdAction, GetStaffIdInput, GetStaffIdMeta, GetStaffIdOutput, GetStudentIdAction, GetStudentIdInput, GetStudentIdMeta, GetStudentIdOutput, GradingComparator, GradingComparatorComparison, HasUnderstandAction, HasUnderstandInput, HasUnderstandMeta, HasUnderstandOutput, NotUnderstandAction, NotUnderstandInput, NotUnderstandMeta, NotUnderstandOutput, PrepareConflictAction, PrepareConflictInput, PrepareConflictMeta, PrepareConflictOutput, PrepareExperienceAction, PrepareExperienceInput, PrepareExperienceMeta, PrepareExperienceOutput, PrepareExperienceSchema, PresenceSessionStudentAction, PresenceSessionStudentInput, PresenceSessionStudentMeta, PresenceSessionStudentOutput, PresenceSessionTeacherAction, PresenceSessionTeacherInput, PresenceSessionTeacherMeta, PresenceSessionTeacherOutput, RasionalizeGradingAction, RasionalizeGradingInput, RasionalizeGradingMeta, RasionalizeGradingOutput, SendAnswerAction, SendAnswerInput, SendAnswerMeta, SendAnswerOutput, SendQuestionAction, SendQuestionInput, SendQuestionMeta, SendQuestionOutput, SyncClassSessionsAction, SyncClassSessionsInput, SyncClassSessionsMeta, SyncClassSessionsOutput, SyncClassSessionsSchema, SyncCommitmentAction, SyncCommitmentInput, SyncCommitmentMeta, SyncCommitmentOutput, SyncStudentAdmisiAction, SyncStudentAdmisiInput, SyncStudentAdmisiMeta, SyncStudentAdmisiOutput, SyncStudentBranchAction, SyncStudentBranchInput, SyncStudentBranchMeta, SyncStudentBranchOutput, SyncStudentInformationAction, SyncStudentInformationInput, SyncStudentInformationMeta, SyncStudentInformationOutput, UpdateGradingAndScoresAction, UpdateGradingAndScoresInput, UpdateGradingAndScoresMeta, UpdateGradingAndScoresOutput, UserCountStatsAction, UserCountStatsInput, UserCountStatsMeta, UserCountStatsOutput, _calculateComparison, acceptQuestion, actions, addManyGradingComponent, allConflict, calculateGrading, calculateManyComparator, calculateOneComparator, checkClassAttendance, classSessionInventoryOccurs, classSessionInventoryPreparation, clearAllOverrides, clearGrading, clearOneOverrides, createGradingAndScores, createManySession, deleteManySession, editAnswer, generateGrading, getClassSessionConflicts, getGradingCount, getQuestionCount, getStaffId, getStudentId, hasUnderstand, notUnderstand, prepareConflict, prepareExperience, presenceSessionStudent, presenceSessionTeacher, rasionalizeGrading, registerOfficePendidikanHooks, sendAnswer, sendQuestion, syncClassSessions, syncCommitment, syncModel, syncStudentAdmisi, syncStudentBranch, syncStudentInformation, updateGradingAndScores, userCountStats };
|
|
599
|
+
export { AcceptQuestionAction, AcceptQuestionInput, AcceptQuestionMeta, AcceptQuestionOutput, AddManyGradingComponentAction, AddManyGradingComponentInput, AddManyGradingComponentMeta, AddManyGradingComponentOutput, AllConflictAction, AllConflictInput, AllConflictMeta, AllConflictOutput, CalculateGradingAction, CalculateGradingInput, CalculateGradingMeta, CalculateGradingOutput, CalculateManyComparatorAction, CalculateManyComparatorInput, CalculateManyComparatorMeta, CalculateManyComparatorOutput, CalculateOneComparatorAction, CalculateOneComparatorInput, CalculateOneComparatorMeta, CalculateOneComparatorOutput, CheckClassAttendanceAction, CheckClassAttendanceInput, CheckClassAttendanceMeta, CheckClassAttendanceOutput, ClassSessionInventoryOccursAction, ClassSessionInventoryOccursInput, ClassSessionInventoryOccursMeta, ClassSessionInventoryOccursOutput, ClassSessionInventoryPreparationAction, ClassSessionInventoryPreparationInput, ClassSessionInventoryPreparationMeta, ClassSessionInventoryPreparationOutput, ClearAllOverridesAction, ClearAllOverridesInput, ClearAllOverridesMeta, ClearAllOverridesOutput, ClearGradingAction, ClearGradingInput, ClearGradingMeta, ClearGradingOutput, ClearOneOverridesAction, ClearOneOverridesInput, ClearOneOverridesMeta, ClearOneOverridesOutput, CreateGradingAndScoresAction, CreateGradingAndScoresInput, CreateGradingAndScoresMeta, CreateGradingAndScoresOutput, CreateManySessionAction, CreateManySessionInput, CreateManySessionMeta, CreateManySessionOutput, DeleteManySessionAction, DeleteManySessionInput, DeleteManySessionMeta, DeleteManySessionOutput, EditAnswerAction, EditAnswerInput, EditAnswerMeta, EditAnswerOutput, GenerateGradingAction, GenerateGradingInput, GenerateGradingMeta, GenerateGradingOutput, GetClassSessionConflictsAction, GetClassSessionConflictsInput, GetClassSessionConflictsMeta, GetClassSessionConflictsOutput, GetClassSessionConflictsSchema, GetGradingCountAction, GetGradingCountInput, GetGradingCountMeta, GetGradingCountOutput, GetQuestionCountAction, GetQuestionCountInput, GetQuestionCountMeta, GetQuestionCountOutput, GetStaffIdAction, GetStaffIdInput, GetStaffIdMeta, GetStaffIdOutput, GetStudentIdAction, GetStudentIdInput, GetStudentIdMeta, GetStudentIdOutput, GradingComparator, GradingComparatorComparison, HasUnderstandAction, HasUnderstandInput, HasUnderstandMeta, HasUnderstandOutput, NotUnderstandAction, NotUnderstandInput, NotUnderstandMeta, NotUnderstandOutput, PrepareConflictAction, PrepareConflictInput, PrepareConflictMeta, PrepareConflictOutput, PrepareExperienceAction, PrepareExperienceInput, PrepareExperienceMeta, PrepareExperienceOutput, PrepareExperienceSchema, PresenceSessionStudentAction, PresenceSessionStudentInput, PresenceSessionStudentMeta, PresenceSessionStudentOutput, PresenceSessionTeacherAction, PresenceSessionTeacherInput, PresenceSessionTeacherMeta, PresenceSessionTeacherOutput, RasionalizeGradingAction, RasionalizeGradingInput, RasionalizeGradingMeta, RasionalizeGradingOutput, SendAnswerAction, SendAnswerInput, SendAnswerMeta, SendAnswerOutput, SendQuestionAction, SendQuestionInput, SendQuestionMeta, SendQuestionOutput, SetTravelWageSessionsAction, SetTravelWageSessionsInput, SetTravelWageSessionsMeta, SetTravelWageSessionsOutput, SetTravelWageSessionsSchema, SyncClassSessionsAction, SyncClassSessionsInput, SyncClassSessionsMeta, SyncClassSessionsOutput, SyncClassSessionsSchema, SyncCommitmentAction, SyncCommitmentInput, SyncCommitmentMeta, SyncCommitmentOutput, SyncStudentAdmisiAction, SyncStudentAdmisiInput, SyncStudentAdmisiMeta, SyncStudentAdmisiOutput, SyncStudentBranchAction, SyncStudentBranchInput, SyncStudentBranchMeta, SyncStudentBranchOutput, SyncStudentInformationAction, SyncStudentInformationInput, SyncStudentInformationMeta, SyncStudentInformationOutput, UpdateGradingAndScoresAction, UpdateGradingAndScoresInput, UpdateGradingAndScoresMeta, UpdateGradingAndScoresOutput, UserCountStatsAction, UserCountStatsInput, UserCountStatsMeta, UserCountStatsOutput, _calculateComparison, acceptQuestion, actions, addManyGradingComponent, allConflict, calculateGrading, calculateManyComparator, calculateOneComparator, checkClassAttendance, classSessionInventoryOccurs, classSessionInventoryPreparation, clearAllOverrides, clearGrading, clearOneOverrides, createGradingAndScores, createManySession, deleteManySession, editAnswer, generateGrading, getClassSessionConflicts, getGradingCount, getQuestionCount, getStaffId, getStudentId, hasUnderstand, notUnderstand, prepareConflict, prepareExperience, presenceSessionStudent, presenceSessionTeacher, rasionalizeGrading, registerOfficePendidikanHooks, sendAnswer, sendQuestion, setTravelWageSessions, syncClassSessions, syncCommitment, syncModel, syncStudentAdmisi, syncStudentBranch, syncStudentInformation, updateGradingAndScores, userCountStats };
|
package/build/index.mjs
CHANGED
|
@@ -919,8 +919,8 @@ const presenceSessionStudent = Action.define({
|
|
|
919
919
|
execute: async (input, stream) => {
|
|
920
920
|
guard(stream, "streamRequired");
|
|
921
921
|
guard(input, "inputRequired");
|
|
922
|
-
const
|
|
923
|
-
const sessionResult = await
|
|
922
|
+
const action = stream.actions.data;
|
|
923
|
+
const sessionResult = await action.getOne.execute(
|
|
924
924
|
{
|
|
925
925
|
model: "neu:jadwal:classSession",
|
|
926
926
|
id: input.sessionId || "",
|
|
@@ -934,17 +934,38 @@ const presenceSessionStudent = Action.define({
|
|
|
934
934
|
stream
|
|
935
935
|
);
|
|
936
936
|
const session = sessionResult.value;
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
937
|
+
const attendance = await action.createOne.execute(
|
|
938
|
+
{
|
|
939
|
+
model: "neu:jadwal:classAttendance",
|
|
940
|
+
data: {
|
|
941
|
+
classSessionId: input.sessionId,
|
|
942
|
+
studentId: input.studentId,
|
|
943
|
+
teacherId: input.teacherId,
|
|
944
|
+
classSessionBranchIds: session.branchIds,
|
|
945
|
+
presenceType: "student",
|
|
946
|
+
isAbsent: false,
|
|
947
|
+
sessionType: session.type,
|
|
948
|
+
presenceAt: /* @__PURE__ */ new Date(),
|
|
949
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
950
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
951
|
+
},
|
|
952
|
+
query: Query.define({ fields: { id: 1 } })
|
|
953
|
+
},
|
|
954
|
+
stream
|
|
955
|
+
);
|
|
956
|
+
await action.syncMany.execute(
|
|
957
|
+
{
|
|
958
|
+
model: "neu:jadwal:classAttendance",
|
|
959
|
+
// id: payload.input.id,
|
|
960
|
+
useDry: false,
|
|
961
|
+
query: Query.define({
|
|
962
|
+
filter: {
|
|
963
|
+
_id: attendance.value.id
|
|
964
|
+
}
|
|
965
|
+
})
|
|
966
|
+
},
|
|
967
|
+
stream
|
|
968
|
+
);
|
|
948
969
|
return Result.ok({
|
|
949
970
|
state: "presenceSessionStudent",
|
|
950
971
|
message: "Presensi berhasil!"
|
|
@@ -2209,6 +2230,7 @@ function useJadwal(stream) {
|
|
|
2209
2230
|
return {
|
|
2210
2231
|
getClassSessions,
|
|
2211
2232
|
getManyClassSessions,
|
|
2233
|
+
updateClassSession,
|
|
2212
2234
|
updateBatchClassSessions,
|
|
2213
2235
|
syncManyClassSessions
|
|
2214
2236
|
};
|
|
@@ -2242,6 +2264,18 @@ function useJadwal(stream) {
|
|
|
2242
2264
|
throw result;
|
|
2243
2265
|
return result.value;
|
|
2244
2266
|
}
|
|
2267
|
+
async function updateClassSession(classSession, data) {
|
|
2268
|
+
await stream?.actions.data.updateOne.execute(
|
|
2269
|
+
{
|
|
2270
|
+
model: "neu:jadwal:classSession",
|
|
2271
|
+
id: classSession.id || "",
|
|
2272
|
+
data: {
|
|
2273
|
+
teacherTravelWages: data
|
|
2274
|
+
}
|
|
2275
|
+
},
|
|
2276
|
+
stream
|
|
2277
|
+
);
|
|
2278
|
+
}
|
|
2245
2279
|
async function updateBatchClassSessions(classSessions) {
|
|
2246
2280
|
const operations = [];
|
|
2247
2281
|
for (const classSession of classSessions) {
|
|
@@ -2471,6 +2505,111 @@ const syncClassSessions = Action.define({
|
|
|
2471
2505
|
}
|
|
2472
2506
|
});
|
|
2473
2507
|
|
|
2508
|
+
const SetTravelWageSessionsSchema = z.object({
|
|
2509
|
+
classSessionIds: z.array(z.objectId()).optional().explain({
|
|
2510
|
+
label: "Class Session IDs"
|
|
2511
|
+
})
|
|
2512
|
+
});
|
|
2513
|
+
|
|
2514
|
+
const setTravelWageSessions = Action.define({
|
|
2515
|
+
key: "setTravelWageSessions",
|
|
2516
|
+
name: "Sync Class Sessions",
|
|
2517
|
+
type: "command",
|
|
2518
|
+
category: "domain",
|
|
2519
|
+
execute: async (input, stream) => {
|
|
2520
|
+
const log = useLog("syncClassSessions", false);
|
|
2521
|
+
guard(stream, "streamRequired");
|
|
2522
|
+
const { getActorId } = useStream(stream);
|
|
2523
|
+
const { validate } = useValidation(stream, SetTravelWageSessionsSchema);
|
|
2524
|
+
const { getManyClassSessions, updateClassSession } = useJadwal(stream);
|
|
2525
|
+
const fragment = {
|
|
2526
|
+
id: 1,
|
|
2527
|
+
title: 1,
|
|
2528
|
+
subtitle: 1,
|
|
2529
|
+
type: 1,
|
|
2530
|
+
startedAt: 1,
|
|
2531
|
+
endedAt: 1,
|
|
2532
|
+
buildingId: 1,
|
|
2533
|
+
prevSession: 1,
|
|
2534
|
+
nextSession: 1
|
|
2535
|
+
};
|
|
2536
|
+
try {
|
|
2537
|
+
getActorId({ throw: true });
|
|
2538
|
+
const data = validate(input);
|
|
2539
|
+
log.object("input", data);
|
|
2540
|
+
if (!data.classSessionIds?.length) {
|
|
2541
|
+
return Result.ok({
|
|
2542
|
+
state: "noClassSessions",
|
|
2543
|
+
message: "No class sessions.",
|
|
2544
|
+
data: {}
|
|
2545
|
+
});
|
|
2546
|
+
}
|
|
2547
|
+
let classSessions = [];
|
|
2548
|
+
classSessions = await getManyClassSessions({
|
|
2549
|
+
filter: { _id: { $in: data.classSessionIds } },
|
|
2550
|
+
fragment
|
|
2551
|
+
});
|
|
2552
|
+
for await (const session of classSessions) {
|
|
2553
|
+
const resultData = await _getTravelWage(stream, session);
|
|
2554
|
+
console.log("hasil session wage", resultData);
|
|
2555
|
+
await updateClassSession(session, resultData);
|
|
2556
|
+
}
|
|
2557
|
+
return Result.ok({
|
|
2558
|
+
state: "allCompleted",
|
|
2559
|
+
message: "All TravelWages have been set.",
|
|
2560
|
+
data: {}
|
|
2561
|
+
});
|
|
2562
|
+
} catch (error) {
|
|
2563
|
+
if (error?.isFailure)
|
|
2564
|
+
throw error;
|
|
2565
|
+
console.error(error);
|
|
2566
|
+
return Result.fail({
|
|
2567
|
+
state: `setTravelWageFailed`,
|
|
2568
|
+
message: `Failed to set travel wages.`,
|
|
2569
|
+
error: error?.toString()
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
});
|
|
2574
|
+
async function _getTravelWage(stream, classSession) {
|
|
2575
|
+
const destBuildingId = classSession.buildingId;
|
|
2576
|
+
const result = classSession.prevSession?.map(async (item) => {
|
|
2577
|
+
const initialBuildingId = item.session?.buildingId;
|
|
2578
|
+
console.log("hasil initialBuildingId", initialBuildingId);
|
|
2579
|
+
console.log("hasil destBuildingId", destBuildingId);
|
|
2580
|
+
if (!destBuildingId || !initialBuildingId)
|
|
2581
|
+
return {};
|
|
2582
|
+
const cost = await stream.actions.data.getMany.execute(
|
|
2583
|
+
{
|
|
2584
|
+
model: "neu:akademik:travelWage",
|
|
2585
|
+
query: Query.define({
|
|
2586
|
+
filter: {
|
|
2587
|
+
departureBuildingId: { $eq: initialBuildingId },
|
|
2588
|
+
arrivalBuildingId: { $eq: destBuildingId }
|
|
2589
|
+
},
|
|
2590
|
+
fields: {
|
|
2591
|
+
amount: 1,
|
|
2592
|
+
maxAmount: 1,
|
|
2593
|
+
increasePercentage: 1
|
|
2594
|
+
}
|
|
2595
|
+
})
|
|
2596
|
+
},
|
|
2597
|
+
stream
|
|
2598
|
+
);
|
|
2599
|
+
console.log("hasil cost", cost.value[0]);
|
|
2600
|
+
return cost.value[0] == null ? {} : {
|
|
2601
|
+
teacherId: item.id,
|
|
2602
|
+
teacherName: item.name,
|
|
2603
|
+
travelWage: cost.value[0]
|
|
2604
|
+
};
|
|
2605
|
+
});
|
|
2606
|
+
const data = await Promise.all(result).then((item) => {
|
|
2607
|
+
return item;
|
|
2608
|
+
});
|
|
2609
|
+
console.log("hasil data", data);
|
|
2610
|
+
return data;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2474
2613
|
const getGradingCount = Action.define({
|
|
2475
2614
|
key: "getGradingCount",
|
|
2476
2615
|
name: "Get GradingCount",
|
|
@@ -3983,6 +4122,7 @@ const actions = {
|
|
|
3983
4122
|
checkClassAttendance,
|
|
3984
4123
|
syncClassSessions,
|
|
3985
4124
|
getClassSessionConflicts,
|
|
4125
|
+
setTravelWageSessions,
|
|
3986
4126
|
// Penilaian
|
|
3987
4127
|
getGradingCount,
|
|
3988
4128
|
// Rasionalisasi
|
|
@@ -4007,4 +4147,4 @@ const actions = {
|
|
|
4007
4147
|
sendQuestion
|
|
4008
4148
|
};
|
|
4009
4149
|
|
|
4010
|
-
export { GetClassSessionConflictsSchema, PrepareExperienceSchema, SyncClassSessionsSchema, _calculateComparison, acceptQuestion, actions, addManyGradingComponent, allConflict, calculateGrading, calculateManyComparator, calculateOneComparator, checkClassAttendance, classSessionInventoryOccurs, classSessionInventoryPreparation, clearAllOverrides, clearGrading, clearOneOverrides, createGradingAndScores, createManySession, deleteManySession, editAnswer, generateGrading, getClassSessionConflicts, getGradingCount, getQuestionCount, getStaffId, getStudentId, hasUnderstand, notUnderstand, prepareConflict, prepareExperience, presenceSessionStudent, presenceSessionTeacher, rasionalizeGrading, registerOfficePendidikanHooks, sendAnswer, sendQuestion, syncClassSessions, syncCommitment, syncModel, syncStudentAdmisi, syncStudentBranch, syncStudentInformation, updateGradingAndScores, userCountStats };
|
|
4150
|
+
export { GetClassSessionConflictsSchema, PrepareExperienceSchema, SetTravelWageSessionsSchema, SyncClassSessionsSchema, _calculateComparison, acceptQuestion, actions, addManyGradingComponent, allConflict, calculateGrading, calculateManyComparator, calculateOneComparator, checkClassAttendance, classSessionInventoryOccurs, classSessionInventoryPreparation, clearAllOverrides, clearGrading, clearOneOverrides, createGradingAndScores, createManySession, deleteManySession, editAnswer, generateGrading, getClassSessionConflicts, getGradingCount, getQuestionCount, getStaffId, getStudentId, hasUnderstand, notUnderstand, prepareConflict, prepareExperience, presenceSessionStudent, presenceSessionTeacher, rasionalizeGrading, registerOfficePendidikanHooks, sendAnswer, sendQuestion, setTravelWageSessions, syncClassSessions, syncCommitment, syncModel, syncStudentAdmisi, syncStudentBranch, syncStudentInformation, updateGradingAndScores, userCountStats };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neutron.co.id/pendidikan-operation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "Operation package of Neutron Pendidikan.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"contributors": [
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@neon.id/types": "^1.54.0",
|
|
39
39
|
"@neon.id/utils": "^1.17.0",
|
|
40
40
|
"@neon.id/z": "^1.6.0",
|
|
41
|
-
"@neutron.co.id/akademik-models": "^1.
|
|
42
|
-
"@neutron.co.id/jadwal-models": "^1.
|
|
43
|
-
"@neutron.co.id/pendidikan-types": "^1.
|
|
41
|
+
"@neutron.co.id/akademik-models": "^1.10.0",
|
|
42
|
+
"@neutron.co.id/jadwal-models": "^1.12.0",
|
|
43
|
+
"@neutron.co.id/pendidikan-types": "^1.11.0",
|
|
44
44
|
"@neutron.co.id/penilaian-models": "^1.12.0",
|
|
45
45
|
"@neutron.co.id/personalia-models": "^1.9.3",
|
|
46
46
|
"@neutron.co.id/tanya-models": "^1.7.0"
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"@neon.id/types": "^1.54.0",
|
|
70
70
|
"@neon.id/utils": "^1.17.0",
|
|
71
71
|
"@neon.id/z": "^1.6.0",
|
|
72
|
-
"@neutron.co.id/akademik-models": "^1.
|
|
73
|
-
"@neutron.co.id/jadwal-models": "^1.
|
|
74
|
-
"@neutron.co.id/pendidikan-types": "^1.
|
|
72
|
+
"@neutron.co.id/akademik-models": "^1.10.0",
|
|
73
|
+
"@neutron.co.id/jadwal-models": "^1.12.0",
|
|
74
|
+
"@neutron.co.id/pendidikan-types": "^1.11.0",
|
|
75
75
|
"@neutron.co.id/penilaian-models": "^1.12.0",
|
|
76
76
|
"@neutron.co.id/personalia-models": "^1.9.3",
|
|
77
77
|
"@neutron.co.id/tanya-models": "^1.7.0"
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"build":
|
|
82
|
+
"build": 69
|
|
83
83
|
}
|