'use strict'
var helper = require("../../helper");
var InventoryMovementManager = require("../../../src/managers/inventory/inventory-movement-manager");
var productDataUtil = require('../master/product-data-util');
var storageDataUtil = require('../master/storage-data-util');
var uomDataUtil = require('../master/uom-data-util');

var codeGenerator = require('../../../src/utils/code-generator');

var Models = require("dl-models");
var Map = Models.map;
var InventoryMovementModel = Models.inventory.InventoryMovement;


class InventoryMovementDataUtil {
    getNewData() {
        return Promise.all([productDataUtil.getTestData(), storageDataUtil.getTestData(), uomDataUtil.getTestData()])
            .then(result => {
                var product = result[0];
                var storage = result[1];
                var uom = result[2];
                var code =codeGenerator() 
                var data = {
                    code: code,
                    referenceNo:`RFNO-${code}`,
                    referenceType:'unit-test-doc',
                    date:new Date(),
                    productId: product._id,
                    storageId: storage._id,
                    uomId: uom._id,
                    quantity: 1000 
                };

                return data;
            })
    }

    getNewTestData() {
        return helper
            .getManager(InventoryMovementManager)
            .then((manager) => {
                return this.getNewData().then((data) => {
                    return manager.create(data)
                        .then((id) => {
                            return manager.getSingleById(id)
                        });
                });
            });
    }
}
module.exports = new InventoryMovementDataUtil();

@@ -141,24 +141,100 @@
 t-manager%22);
+%0A%0Avar inventoryDocumentDataUtil = require(%22./inventory-document-data-util%22);
 %0Avar product
@@ -760,16 +760,60 @@
 stData()
+, inventoryDocumentDataUtil.getNewTestData()
 %5D)%0A     
@@ -956,16 +956,67 @@
 ult%5B2%5D;%0A
+                var inventoryDocument = result%5B3%5D;%0A
         
@@ -1033,16 +1033,17 @@
 r code =
+ 
 codeGene
@@ -1049,17 +1049,16 @@
 erator()
- 
 %0A       
@@ -1147,22 +1147,38 @@
 eNo:
-%60RFNO-$%7Bcode%7D%60
+ inventoryDocument.referenceNo
 ,%0A  
@@ -1213,23 +1213,40 @@
 ype:
-'unit-test-doc'
+ inventoryDocument.referenceType
 ,%0A  
@@ -1268,16 +1268,17 @@
    date:
+ 
 new Date
@@ -1439,17 +1439,16 @@
 ty: 1000
- 
 %0A       

update inventory movement data util