-
Notifications
You must be signed in to change notification settings - Fork 105
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
Refactor Stock distribution #1905
Conversation
45fe7e0
to
8c2d7f6
Compare
@mbayopanda @sfount |
782c0c8
to
5be31bd
Compare
@IMA-WorldHealth/bhima-core |
5be31bd
to
7791e65
Compare
This PR is a refactor based on the functionality review we made, so it should be reviewed. |
@DedrickEnc, I can give you a review. Can you rebase to master first? |
Thanks @jniles , doing that |
5c0cd27
to
3a7a071
Compare
@jniles |
3a7a071
to
b395465
Compare
There was a problem hiding this 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", |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: '<' |
There was a problem hiding this comment.
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: '&?', |
There was a problem hiding this comment.
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 (&
).
server/controllers/stock/index.js
Outdated
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), |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
8a73799
to
08ed8b4
Compare
…n from receipt, use moment for expiration date
…ic to filter stock movement by
08ed8b4
to
8123855
Compare
@jniles |
There was a problem hiding this 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'; |
There was a problem hiding this comment.
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.
8123855
to
fb2ec1f
Compare
bors r+ |
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.
Build succeeded |
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 inexit.html
andentry.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:
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!