Skip to content

Commit

Permalink
stock movement depot to depot done
Browse files Browse the repository at this point in the history
  • Loading branch information
DedrickEnc committed Jul 31, 2017
1 parent 9426a8c commit ec81f5c
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 33 deletions.
1 change: 1 addition & 0 deletions client/src/i18n/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"DEBTOR_GROUP_FORM": "Form debtor group record",
"DEFINE_UNTIL_DATE": "Define a limit date",
"DEFAULT_QUANTITY": "Default Quantity",
"DEPOT": "Depot",
"DESCRIPTION": "Description",
"DESIGNATION": "Designation",
"DETAIL_PREVIOUS": "Previous Year Details",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"DEBTOR_GROUP_FORM": "Formulaire d'enregistrement de groupe débiteur",
"DEBTOR_CREDITOR": "Débiteur/Créditeur",
"DEFINE_UNTIL_DATE": "Définir une date limite",
"DEPOT": "Depot",
"DESCRIPTION": "Description",
"DETAILS": "Details",
"DEFAULTS": "Filtres par défaut",
Expand Down
10 changes: 5 additions & 5 deletions client/src/modules/stock/entry/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ function StockEntryController(Depots, Inventory, Notify,
inventory : inventory,
entry_type : vm.movement.entry_type,
})
.then(function (rows) {
if (!rows) { return; }
inventory.lots = rows.lots;
inventory.givenQuantity = rows.quantity;
.then(function (row) {
if (!row) { return; }
inventory.lots = row.lots;
inventory.givenQuantity = row.quantity;
vm.hasValidInput = hasValidInput();
})
.catch(Notify.handleError);
Expand Down Expand Up @@ -314,7 +314,7 @@ function StockEntryController(Depots, Inventory, Notify,
var lots = vm.Stock.store.data.map(function (row) {
return {
uuid: row.lot_uuid,
quantity: row.quantity,
quantity: row.lots[0].quantity,
unit_cost: row.unit_cost,
};
});
Expand Down
19 changes: 13 additions & 6 deletions client/src/modules/stock/entry/modals/findTransfer.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ function StockFindTransferModalController(Instance, StockService, Notify,
var filtering = new Filtering(vm.gridOptions);

var columns = [
{
field: 'reference',
displayName: 'TABLE.COLUMNS.REFERENCE',
headerCellFilter: 'translate',
cellTemplate: 'modules/stock/entry/modals/templates/transfer_reference.tmpl.html'
},
{
field: 'date',
cellFilter: 'date',
Expand All @@ -39,6 +33,18 @@ function StockFindTransferModalController(Instance, StockService, Notify,
displayName: 'FORM.LABELS.DEPOT',
headerCellFilter: 'translate'
},
{
field: 'description',
displayName: 'FORM.LABELS.DESCRIPTION',
headerCellFilter: 'translate'
},
{
field: 'action',
displayName: '',
enableFiltering: false,
enableSorting: false,
cellTemplate: 'modules/stock/entry/modals/templates/transfer_view.tmpl.html'
}
];

vm.gridOptions.columnDefs = columns;
Expand Down Expand Up @@ -90,6 +96,7 @@ function StockFindTransferModalController(Instance, StockService, Notify,

return StockService.movements.read(null, {
document_uuid: vm.selectedRow.document_uuid,
is_exit: 1,
})
.then(function (transfers) {
Instance.close(transfers);
Expand Down
8 changes: 7 additions & 1 deletion client/src/modules/stock/entry/modals/lots.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,17 @@ function StockDefineLotsModalController(Instance, Notify, uiGridConstants, Data,
return;
}
vm.gridOptions.data.push({
is_valid : vm.entryType === 'transfer_reception' ? true : false,
is_valid : false,
lot : vm.inventory.lot || '',
expiration_date : new Date(vm.inventory.expiration_date) || new Date(),
quantity : vm.remainingQuantity,
});

// if it is a transfer reception, so force the validation on the single element
if(vm.entryType === 'transfer_reception') {
handleChange(vm.gridOptions.data[0]);
}

}

// remove lot
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="ui-grid-cell-contents">
<a ng-click="grid.appScope.showReceipt(row.entity.document_uuid)" href>{{ row.entity.reference }}</a>
<a ng-click="grid.appScope.showReceipt(row.entity.document_uuid)" href translate>TABLE.COLUMNS.RECEIPT</a>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
</span>
</div>
</div>

</div>
</div>
</button>
Expand Down
2 changes: 1 addition & 1 deletion test/end-to-end/shared/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ module.exports = {
fiscalPeriodSelect : require('./bhFiscalPeriodSelect'),
debtorGroupSelect : require('./bhDebtorGroupSelect'),
multipleDebtorGroupSelect : require('./bhMultipleDebtorGroupSelect'),
stockDistributionDestination : require('./bhStockDistributionDestination')
stockEntryExitType : require('./bhStockEntryExitType')
};
29 changes: 21 additions & 8 deletions test/end-to-end/stock/stock.entry.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,29 @@ function StockEntryPage() {

/**
* @method setPurchase
* @param {string} reference - the patient reference
* @param {string} rowNumber - the purchase line on the modal
*/
page.setPurchase = function setPurchase(rowNumber) {
element(by.css('[name="btn-purchase"]')).click();
components.stockEntryExitType.set('entry-exit-type-purchase');
GU.selectRow('PurchaseGrid', rowNumber);
FU.modal.submit();
};

/**
* @method setTransfer
* @param {string} rowNumber - movement line on the modal grid
*/
page.setTransfer = function setTransfer(rowNumber) {
components.stockEntryExitType.set('entry-exit-type-transfer-reception');
GU.selectRow('TransferGrid', rowNumber);
FU.modal.submit();
};

/**
* @method setIntegration
*/
page.setIntegration = function setIntegration() {
element(by.css('[name="btn-integration"]')).click();
components.stockEntryExitType.set('entry-exit-type-integration');
};

/**
Expand Down Expand Up @@ -86,7 +96,7 @@ function StockEntryPage() {
* { label: '...', quantity: '...', expiration_date: '...' }
* ]
*/
page.setLots = function setLots(inventoryRowNumber, lotsArray, inventoryQuantity, inventoryUnitCost) {
page.setLots = function setLots(inventoryRowNumber, lotsArray, isTransferReception, inventoryQuantity, inventoryUnitCost) {
// lots column
const launchLots = GU.getCell(gridId, inventoryRowNumber, 3);

Expand All @@ -107,20 +117,23 @@ function StockEntryPage() {

$('[data-add-lot]').click();
}

lotsArray.forEach((lot, index) => {
lotCell = GU.getCell(lotGridId, index, 1);
quantityCell = GU.getCell(lotGridId, index, 2);
expirationDateCell = GU.getCell(lotGridId, index, 3);

// enter lot label
FU.input('row.entity.lot', lot.label, lotCell);
if(!isTransferReception){
FU.input('row.entity.lot', lot.label, lotCell);
}

// enter lot quantity
FU.input('row.entity.quantity', lot.quantity, quantityCell);

// enter lot expiration date
components.datePicker.set(lot.expiration_date, expirationDateCell);
if(!isTransferReception){
components.datePicker.set(lot.expiration_date, expirationDateCell);
}

if (index < lotsArray.length - 1) {
// Add another lot line
Expand Down
20 changes: 19 additions & 1 deletion test/end-to-end/stock/stock.entry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function StockExiTests() {
{ label: 'LX-THREE', quantity: 200, expiration_date: '2018-09-15' },
];

page.setLots(0, lots);
page.setLots(0, lots, false);

// submit
page.submit();
Expand Down Expand Up @@ -63,6 +63,24 @@ function StockExiTests() {

page.setLots(0, lots, 1500, 0.09);

// submit
page.submit();
});

it('Should entry stock from a transfer reception', () => {
// select the movement
page.setTransfer(0);

page.setDate(new Date());

page.setDescription(DESCRIPTION.concat(' - Transfer reception'));

const lots = [
{ quantity: 75}
];

page.setLots(0, lots, true);

// submit
page.submit();
});
Expand Down
10 changes: 5 additions & 5 deletions test/end-to-end/stock/stock.exit.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function StockExitPage() {
* @method setPatient
* @param {string} reference - the patient reference
*/
page.setPatient = function setDepot(reference) {
components.stockDistributionDestination.set('exit-type-patient');
page.setPatient = function setPatient(reference) {
components.stockEntryExitType.set('entry-exit-type-patient');
components.findPatient.findById(reference);
FU.modal.submit();
};
Expand All @@ -35,7 +35,7 @@ function StockExitPage() {
* @param {string} service - the service name
*/
page.setService = function setService(service) {
components.stockDistributionDestination.set('exit-type-service');
components.stockEntryExitType.set('entry-exit-type-service');
const modalContent = element(by.css('[class="modal-content"]'));
FU.uiSelect('$ctrl.selected', service, modalContent);
FU.modal.submit();
Expand All @@ -46,7 +46,7 @@ function StockExitPage() {
* @param {string} depot - the depot name
*/
page.setDestinationDepot = function setDestinationDepot(depot) {
components.stockDistributionDestination.set('exit-type-depot');
components.stockEntryExitType.set('entry-exit-type-depot');
const modalContent = element(by.css('[class="modal-content"]'));
FU.uiSelect('$ctrl.selected', depot, modalContent);
FU.modal.submit();
Expand All @@ -56,7 +56,7 @@ function StockExitPage() {
* @method setLoss
*/
page.setLoss = function setLoss() {
components.stockDistributionDestination.set('exit-type-loss');
components.stockEntryExitType.set('entry-exit-type-loss');
};

/**
Expand Down
8 changes: 4 additions & 4 deletions test/integration/stock.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('(/stock/) The Stock HTTP API', () => {
// ==============================================================================

const depot_principal_uuid = 'f9caeb16-1684-43c5-a6c4-47dbac1df296';
const depot_principal_mvt = 14; // 10 initial plus 4 distributions
const depot_principal_mvt = 12; // 10 initial plus 2 distributions
const lot_quinine_uuid = 'ae735e99-8faf-417b-aa63-9b404fca99ac';

// create new stock lots
Expand Down Expand Up @@ -162,16 +162,16 @@ describe('(/stock/) The Stock HTTP API', () => {
.catch(helpers.handler));

// list all movement relatives to 'Depot Principal'
it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (14: 10 IN + 4 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depot_principal_uuid}`)
it('GET /stock/lots/movements?depot_uuid=... returns movements for Depot Principal (12: 8 IN + 2 OUT)', () => agent.get(`/stock/lots/movements?depot_uuid=${depot_principal_uuid}`)
.then((res) => {
helpers.api.listed(res, depot_principal_mvt);
})
.catch(helpers.handler));

// list all stock exit relatives to 'Depot Principal'
it('GET /stock/lots/movements?is_exit=1&depot_uuid=... returns exits for Depot Principal (4 OUT)', () => agent.get(`/stock/lots/movements?is_exit=1&depot_uuid=${depot_principal_uuid}`)
it('GET /stock/lots/movements?is_exit=1&depot_uuid=... returns exits for Depot Principal (2 OUT)', () => agent.get(`/stock/lots/movements?is_exit=1&depot_uuid=${depot_principal_uuid}`)
.then((res) => {
helpers.api.listed(res, 4);
helpers.api.listed(res, 2);
})
.catch(helpers.handler));

Expand Down

0 comments on commit ec81f5c

Please sign in to comment.