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

Refactor Stock distribution #1905

Merged
merged 13 commits into from
Aug 17, 2017

Conversation

DedrickEnc
Copy link
Contributor

@DedrickEnc DedrickEnc commented Jul 29, 2017

This PR refactor the stock distribution page and closes #1854

Most of the work is about addressing points listed in #1854 and some refactor in order to reduce the code.
A new component bhStockEntryExitType has been introduced to remove repeated code found in exit.html and entry.html for selecting the type of entry or exit.

The main change is about stock distribution from depot to an other depot (Stock transfer)
Now the stock transfer is a set of two processes which are a stock exit to depot and a stock entry from depot. Both of them are independent in other to avoid mistakes and guaranty the data integrity.
Each time the stock in the depot will match the stock in the system.

Thank you for contributing!

Before submitting this pull request, please verify that you have:

  • Run your code through eslint.
  • Run integration tests.
  • Run end-to-end tests.
  • Accurately described the changes your are making in this pull request.

For a more detailed checklist, see the online review checklist that this PR will be evaluated against.

Ensuring that the above checkboxes are completed will help speed the review process and help build a stronger application. Thanks!

@DedrickEnc
Copy link
Contributor Author

@mbayopanda @sfount
Can I get a review?

@DedrickEnc DedrickEnc force-pushed the dedrick-stock-dist branch 2 times, most recently from 782c0c8 to 5be31bd Compare August 4, 2017 12:03
@DedrickEnc
Copy link
Contributor Author

@IMA-WorldHealth/bhima-core
Can I get a review for this pull request?

@DedrickEnc
Copy link
Contributor Author

This PR is a refactor based on the functionality review we made, so it should be reviewed.
Can I get a review for this pull request ?
@IMA-WorldHealth/bhima-core

@jniles
Copy link
Collaborator

jniles commented Aug 14, 2017

@DedrickEnc, I can give you a review. Can you rebase to master first?

@DedrickEnc
Copy link
Contributor Author

Thanks @jniles , doing that

@DedrickEnc DedrickEnc force-pushed the dedrick-stock-dist branch 4 times, most recently from 5c0cd27 to 3a7a071 Compare August 15, 2017 10:59
@DedrickEnc
Copy link
Contributor Author

@jniles
The branch is rebased

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.

@DedrickEnc, I've done an initial review. There's a few broken pieces and a few optimizations to make.

Let me know if you have any questions.

"DESCRIPTION": "Ce module vous permet de Lister, Creer, Modifier et Supprimer un dépôt",
"EDIT_DEPOT": "Editer les informations d'un dépôt",
"ENTITY" : "Depot",
Copy link
Collaborator

Choose a reason for hiding this comment

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

DEPOT.ENTITY needs to be translated into English.

I haven't checked further, but make sure all your translation keys have a definition in both languages. If you need any help with the English, feel free to ask.

$ctrl.display = function () {
if ($ctrl.isEntry) {
return $ctrl.reference || '';
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since you have return, this else is unnecessary. It will increase readability to remove it.

</button>
</div>

<bh-stock-entry-exit-type
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was a great idea to make a component 👍

onEntryExitTypeSelectCallback: '&?',
reference: '<?',
displayName: '<?',
isEntry: '<'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should probably be @. The < is for binding a variable from the parent scope, but it doesn't look like the bindings are ever expected to change.

templateUrl: 'modules/templates/bhStockEntryExitType.tmpl.html',
controller: StockEntryExitTypeController,
bindings: {
onEntryExitTypeSelectCallback: '&?',
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably want to make this callback required (&).

entity_uuid : null,
is_exit : 0,
flux_id : core.flux.FROM_OTHER_DEPOT,
entity_uuid : isExit ? db.bid(parameters.to_depot) : db.bid(parameters.from_depot),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of doing this on every turn of the loop, can you do something like this:

const depot_uuid =  db.bid(isExit ? parameters.from_depot : parameters.to_depot);
const entity_uuid = db.bid(isExit ? parameters.to_depot : parameters.from_depot);
const is_exit = isExit ? 1 : 0;
const flux_id = isExit ? core.flux.TO_OTHER_DEPOT : core.flux.FROM_OTHER_DEPOT;

parameters.lots.forEach((lot) => {
    record = {
      depot_uuid,
      is_exit,
      entity_uuid,
      // ... etc ...
    };
});

@@ -36,15 +36,15 @@
</div>
<div class="col-xs-6">
<h4>{{translate 'STOCK.TO'}}</h4>
<span class="text-capitalize">{{translate 'STOCK.DEPOT'}}</span>: <strong>{{entry.details.depot_name}}</strong> <br>
<span class="text-capitalize">{{translate 'FORM.LABELS.DOCUMENT'}}</span>: <strong>{{entry.details.document_reference}}</strong> <br>
<span class="text-capitalize">{{translate 'STOCK.DEPOT'}}</span>: <strong>{{exit.details.otherDepotName}}</strong> <br>
Copy link
Collaborator

Choose a reason for hiding this comment

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

💃

@@ -52,4 +52,4 @@ function StockAdjustmentTests() {
});
}

describe('Stock Adustment Test', StockAdjustmentTests);
describe('Stock Adjustment Test', StockAdjustmentTests);
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

FORM.BUTTONS.CLOSE
</button>

<bh-loading-button loading-state="FindForm.$loading">
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can submit this without any choices and it loads every lot. Is this intended behavior?

ui-grid-resize-columns
ui-grid-selection>
<bh-grid-loading-indicator
loading-state="$ctrl.loading"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this loading property ever defined? I couldn't find it.

@DedrickEnc DedrickEnc force-pushed the dedrick-stock-dist branch 2 times, most recently from 8a73799 to 08ed8b4 Compare August 17, 2017 12:09
@DedrickEnc
Copy link
Contributor Author

@jniles
Changes has been integrated

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.

Just one more thing. After that, LGTM.

function StockEntryExitTypeController() {
var $ctrl = this;
$ctrl.selectedEntryExitType = null;
$ctrl.isEntry === 'true';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this actually work?

I think you might be missing an assignment - this is just an evaluation. Maybe...

$ctrl.isEntry = $ctrl.isEntry === 'true'

?

Either way, this should probably go in an $onInit method to make sure the bindings are correctly initialized.

@jniles
Copy link
Collaborator

jniles commented Aug 17, 2017

bors r+

bors bot added a commit that referenced this pull request Aug 17, 2017
1905: Refactor Stock distribution r=jniles

This PR refactor the stock distribution page and closes #1854

Most of the work is about addressing points listed in #1854 and some refactor in order to reduce the code.
A new component ```bhStockEntryExitType``` has been introduced to remove repeated code found in ```exit.html``` and ```entry.html``` for selecting the type of entry or exit.

The main change is about stock distribution from depot to an other depot (Stock transfer)
Now the stock transfer is a set of two processes which are a stock exit to depot and a stock entry from depot. Both of them are independent in other to avoid mistakes and guaranty the data integrity.
Each time the stock in the depot will match the stock in the system.
@bors
Copy link
Contributor

bors bot commented Aug 17, 2017

Build succeeded

@bors bors bot merged commit fb2ec1f into Third-Culture-Software:master Aug 17, 2017
@DedrickEnc DedrickEnc deleted the dedrick-stock-dist branch August 18, 2017 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(refactor) Stock distribution
3 participants