Skip to content

Commit

Permalink
Se sube correccion en base a observacion
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio-Ramirez committed Dec 6, 2024
1 parent fd96cce commit 0499d64
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions scripts/IN-598.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import moment = require('moment');
async function egresosDuplicados(done) {
const paramInicio = process.argv[3];
const paramFin = process.argv[4];
const start = paramInicio ?
const start = moment(paramInicio, 'YYYY-MM-DD', true).isValid() ?
moment(new Date(paramInicio).setHours(0, 0, 0, 0)).format('YYYY-MM-DD HH:mm:ss') :
moment(new Date().setHours(0, 0, 0, 0)).subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss');
const end = paramFin ?
moment(new Date(paramFin).setHours(23, 59, 0, 0)).format('YYYY-MM-DD HH:mm:ss') :
moment(new Date().setHours(23, 59, 0, 0)).subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss');
const end = moment(paramFin, 'YYYY-MM-DD', true).isValid()
? moment(paramFin).endOf('day').format('YYYY-MM-DD HH:mm:ss')
: moment().subtract(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss');

const registroPrevios = CamaEstados.find({
$and: [{
Expand All @@ -31,11 +31,10 @@ async function egresosDuplicados(done) {
const createdAt = estado.createdAt;

if (fecha && idInternacion) {

const existeEstadoIndex = estadoSinDuplicar.findIndex(e => {
const fechaConvertida = moment(e.fecha).format('YYYY-MM-DD');
return (fechaConvertida === fecha && e.extras.idInternacion.toString() === idInternacion.toString()
&& e.createdAt < createdAt);
return (fechaConvertida === fecha && e.extras?.idInternacion?.toString() === idInternacion.toString()
&& e.createdAt <= createdAt);
});

if (existeEstadoIndex >= 0) {
Expand Down

0 comments on commit 0499d64

Please sign in to comment.