Skip to content

Commit

Permalink
fix: [DHIS2-17131] schedule dates with format DD-MM-YYYY (#3584)
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Apr 29, 2024
1 parent 8c5ba72 commit 3237698
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// @flow
import { pipe } from 'capture-core-utils';
import moment from 'moment';
import { dataElementTypes, ProgramStage } from '../../../../../metaData';
import { convertFormToClient, convertClientToServer } from '../../../../../converters';
import { convertClientToServer } from '../../../../../converters';
import { convertCategoryOptionsToServer } from '../../../../../converters/clientToServer';

const convertFn = pipe(convertFormToClient, convertClientToServer);

const ignoreAutoGenerateIfApplicable = (stage, firstStageDuringRegistrationEvent) =>
!firstStageDuringRegistrationEvent || firstStageDuringRegistrationEvent.id !== stage.id;

Expand Down Expand Up @@ -56,15 +53,17 @@ export const deriveAutoGenerateEvents = ({
const eventInfo = openAfterEnrollment
? {
status: 'ACTIVE',
occurredAt: convertFn(dateToUseInActiveStatus, dataElementTypes.DATE),
scheduledAt: convertFn(dateToUseInActiveStatus, dataElementTypes.DATE),
occurredAt: dateToUseInActiveStatus,
scheduledAt: dateToUseInActiveStatus,
}
: {
status: 'SCHEDULE',
// for schedule type of events we want to add the standard interval days to the date
scheduledAt: moment(convertFn(dateToUseInScheduleStatus, dataElementTypes.DATE))
.add(minDaysFromStart, 'days')
.format('YYYY-MM-DD'),
scheduledAt: convertClientToServer(
moment(dateToUseInScheduleStatus)
.add(minDaysFromStart, 'days')
.format('YYYY-MM-DD'),
dataElementTypes.DATE),
};

return {
Expand Down

0 comments on commit 3237698

Please sign in to comment.