Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDR Peremption Reporting Tool #5558

Conversation

mbayopanda
Copy link
Collaborator

@mbayopanda mbayopanda commented Apr 2, 2021

This PR adds a module for reporting expired rate from CDR

image

To test it, please import these files :

  • MouvementStock
  • Article
  • ArticleLot
  • LigneLotDansDoc

Article.xlsx
ArticleLot.xlsx
LigneLotDansDoc.xlsx
MouvementStock.xlsx

@mbayopanda mbayopanda requested a review from jniles April 2, 2021 10:35
Copy link
Collaborator

@jniles jniles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbayopanda I've made a few comments. I wonder how we should deploy this. In the short run, we can definitely put it on the online deployment, but it doesn't really make sense for hospital deployments. Do you have any ideas?

@@ -0,0 +1,5 @@
<div class="ui-grid-cell-contents">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this template?

</tr>
<tr class="highlighted delimitter">
{{!-- <td class="first">{{date periodKey}}</td> --}}
<td class="first">Tx de péremption</td>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to translate these values?

const directory = path.join(fsdir, hasTrailingSlash ? prefix : `${prefix}/`);

// configure the storage space using multer's diskStorage. This will allow
const storage = multer.diskStorage({
Copy link
Collaborator

@jniles jniles Apr 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I am wrong, but this looks nearly identical to the uploader definition above.

Could you move the common items out into their own function/object?

I'm imagining:

function setupDiskStorage(prefix, fields) {
  // format the upload directory.  Add a trailing slash for consistency
  const hasTrailingSlash = (prefix[prefix.length - 1] === '/');
  const directory = path.join(dir, hasTrailingSlash ? prefix : `${prefix}/`);
  // configure the storage space using multer's diskStorage.  This will allow
  const storage = multer.diskStorage({
    destination : async (req, file, cb) => {
      try {
        // NOTE: need absolute path here for mkdirp
        const fullFolderPath = path.join(fsdir, directory);
        debug(`creating upload directory ${fullFolderPath}.`);
        await mkdirp(fullFolderPath);
        cb(null, fullFolderPath);
      } catch (err) {
        cb(err);
      }
    },
    filename : (req, file, cb) => {
      const id = uuid();
      // ensure that a link is passed to the req.file object
      file.link = `${directory}${id}`;
      debug(`Storing file in ${file.link}.`);
      cb(null, id);
    },
  });
}

// then...

function Uploader(prefix, fields) {
  const storage  = setupDiskStorage(prefix, fields);
  return multer({ storage }).array(fields);
}

function multipleFields(prefix, fields) {
  const storage  = setupDiskStorage(prefix, fields);
  return multer({ storage }).fields(fields);
}

Copy link
Collaborator

@jniles jniles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also have the migration script in here, could you remove it?

@mbayopanda mbayopanda closed this Sep 13, 2021
@mbayopanda mbayopanda deleted the cdr-peremption-reporting branch September 13, 2021 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants