/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2020
 */

import Realm from 'realm';

export class LocationMovement extends Realm.Object {}

LocationMovement.schema = {
  name: 'LocationMovement',
  primaryKey: 'id',
  properties: {
    id: 'string',
    location: { type: 'Location', optional: true },
    itemBatch: { type: 'ItemBatch', optional: true },
    enterTimestamp: { type: 'date', default: new Date() },
    exitTimestamp: { type: 'date', optional: true },
  },
};

export default LocationMovement;

@@ -140,16 +140,265 @@
 Object %7B
+%0A  get breaches() %7B%0A    return (%0A      this.location?.breaches?.filtered(%0A        'startTimestamp %3C= $0 && (endTimestamp %3E= $1 %7C%7C endTimestamp == null)',%0A        this.enterTimestamp,%0A        this.exitTimestamp ?? new Date()%0A      ) ?? %5B%5D%0A    );%0A  %7D%0A
 %7D%0A%0ALocat

Add breaches LocationMovement method