<commit_before>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2019
 */

/**
 * Methods to create internal records from a requested
 * sync/external record. Used primarily by
 * createOrUpdateRecord in incomingSyncUtils.
 */

import { parseBoolean } from './incomingSyncUtils';

export const createPeriodInternalRecord = (record, database) => ({
  id: record.ID,
  startDate: record.startDate,
  endDate: record.endDate,
  name: record.name,
  periodSchedule: database.getOrCreate('PeriodSchedule', record.periodScheduleID),
});

export const createOptionsInternalRecord = record => ({
  id: record.ID,
  title: record.title,
  type: record.type,
  isActive: parseBoolean(record.isActive),
});

export const createPeriodScheduleInternalRecord = record => ({
  id: record.ID,
  name: record.name,
});
<commit_msg>Add upate to internal record period creation<commit_after>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2019
 */

/**
 * Methods to create internal records from a requested
 * sync/external record. Used primarily by
 * createOrUpdateRecord in incomingSyncUtils.
 */

import { parseBoolean, parseDate } from './incomingSyncUtils';

export const createPeriodInternalRecord = (record, database) => ({
  id: record.ID,
  startDate: record.startDate ? parseDate(record.startDate) : new Date(),
  endDate: record.endDate ? parseDate(record.startDate) : new Date(),
  name: record.name,
  periodSchedule: database.getOrCreate('PeriodSchedule', record.periodScheduleID),
});

export const createOptionsInternalRecord = record => ({
  id: record.ID,
  title: record.title,
  type: record.type,
  isActive: parseBoolean(record.isActive),
});

export const createPeriodScheduleInternalRecord = record => ({
  id: record.ID,
  name: record.name,
});

{'fraction_non_alphanumeric': 0.12033898305084746, 'fraction_numerical': 0.004519774011299435, 'mean_word_length': 4.8256578947368425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '950821', 'n_tokens_mistral': 519, 'n_tokens_neox': 506, 'n_words': 141}