Skip to content

Commit

Permalink
fix(Stock): Fix the financial writting to avoid multiple transaction …
Browse files Browse the repository at this point in the history
…for one movement and refactor t
  • Loading branch information
DedrickEnc committed Sep 21, 2017
1 parent bf1181e commit aa505c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
15 changes: 1 addition & 14 deletions client/src/modules/stock/entry/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,23 +324,10 @@ function StockEntryController(
flux_id : bhConstants.flux.FROM_INTEGRATION,
user_id : Session.user.id,
};

var lots = vm.Stock.store.data.reduce(function (current, previous) {
return previous.lots.map(function (lot) {
return {
label : lot.lot,
initial_quantity : lot.quantity,
quantity : lot.quantity,
unit_cost : previous.unit_cost,
expiration_date : lot.expiration_date,
inventory_uuid : previous.inventory.uuid
};
}).concat(current);
}, []);

var entry = {
integration : { date : vm.movement.date, description : vm.movement.description },
lots : lots,
lots : processLotsFromStore(vm.Stock.store.data, movement.entity_uuid),
movement : movement
}

Expand Down
6 changes: 3 additions & 3 deletions server/controllers/stock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ function createIntegration(req, res, next) {
const params = req.body;
const identifier = uuid.v4();
const documentUuid = uuid.v4();
let commonInfos;

const integration = {
uuid : db.bid(identifier),
Expand Down Expand Up @@ -381,10 +380,12 @@ function createIntegration(req, res, next) {
unit_cost : lot.unit_cost,
is_exit : 0,
user_id : params.movement.user_id,
description : integration.description,
});
});

// An arry of common info, to send to the store procedure in order to insert to the posting journal
commonInfos = [
const commonInfos = [
db.bid(documentUuid),
new Date(params.movement.date),
req.session.enterprise.id,
Expand All @@ -398,7 +399,6 @@ function createIntegration(req, res, next) {

// transaction - movement reference
transaction.addQuery('CALL ComputeMovementReference(?);', [db.bid(documentUuid)]);
});

// execute all operations as one transaction
transaction.execute()
Expand Down

0 comments on commit aa505c5

Please sign in to comment.