<commit_before>'use strict'
var helper = require('../../helper');
var UnitReceiptNoteManager = require('../../../src/managers/purchasing/unit-receipt-note-manager');
var codeGenerator = require('../../../src/utils/code-generator');
var unit = require('../master/unit-data-util');
var supplier = require('../master/supplier-data-util');
var deliveryOrder = require('./delivery-order-data-util');

class UnitReceiptNoteDataUtil {
    getNew() {
        return new Promise((resolve, reject) => {
            helper
                .getManager(UnitReceiptNoteManager)
                .then(manager => {
                    Promise.all([unit.getTestData(), supplier.getTestData(), deliveryOrder.getNew()])
                        .then(results => {
                            var dataUnit=results[0];
                            var dataSupplier=results[1];
                            var dataDeliveryOrder=results[2];

                            var doItems = dataDeliveryOrder.items.map(doItem => { 
                                var item = doItem.fulfillments.map(fulfillment => {
                                    return fulfillment.purchaseOrder.items.map(poItem => {
                                        return {
                                            product: fulfillment.product,
                                            deliveredQuantity: fulfillment.deliveredQuantity,
                                            deliveredUom: fulfillment.deliveredUom,
                                            purchaseOrderQuantity: fulfillment.purchaseOrderQuantity,
                                            pricePerDealUnit: poItem.pricePerDealUnit,
                                            currency: poItem.currency,
                                            currencyRate: poItem.currencyRate,
                                            purchaseOrderId: fulfillment.purchaseOrderId,
                                            purchaseOrder: fulfillment.purchaseOrder,
                                            remark: ''
                                        }
                                    })
                                }) 
                                item = [].concat.apply([], item);
                                return item;
                            });

                            doItems = [].concat.apply([], doItems);
                            var data = {
                                no: `UT/URN/${codeGenerator()}`,
                                unitId: dataUnit._id,
                                unit: dataUnit,
                                date: new Date(),
                                supplierId: dataSupplier._id,
                                supplier: dataSupplier,
                                deliveryOrderId: dataDeliveryOrder._id,
                                deliveryOrder: dataDeliveryOrder,
                                remark: 'Unit Test',
                                items: doItems
                            };

                            manager.create(data)
                                .then(id => {
                                    manager.getSingleById(id)<commit_msg>fix value of deliveredUom<commit_after>'use strict'
var helper = require('../../helper');
var UnitReceiptNoteManager = require('../../../src/managers/purchasing/unit-receipt-note-manager');
var codeGenerator = require('../../../src/utils/code-generator');
var unit = require('../master/unit-data-util');
var supplier = require('../master/supplier-data-util');
var deliveryOrder = require('./delivery-order-data-util');

class UnitReceiptNoteDataUtil {
    getNew() {
        return new Promise((resolve, reject) => {
            helper
                .getManager(UnitReceiptNoteManager)
                .then(manager => {
                    Promise.all([unit.getTestData(), supplier.getTestData(), deliveryOrder.getNew()])
                        .then(results => {
                            var dataUnit=results[0];
                            var dataSupplier=results[1];
                            var dataDeliveryOrder=results[2];

                            var doItems = dataDeliveryOrder.items.map(doItem => { 
                                var item = doItem.fulfillments.map(fulfillment => {
                                    return fulfillment.purchaseOrder.items.map(poItem => {
                                        return {
                                            product: fulfillment.product,
                                            deliveredQuantity: fulfillment.deliveredQuantity,
                                            deliveredUom: fulfillment.purchaseOrderUom,
                                            purchaseOrderQuantity: fulfillment.purchaseOrderQuantity,
                                            pricePerDealUnit: poItem.pricePerDealUnit,
                                            currency: poItem.currency,
                                            currencyRate: poItem.currencyRate,
                                            purchaseOrderId: fulfillment.purchaseOrderId,
                                            purchaseOrder: fulfillment.purchaseOrder,
                                            remark: ''
                                        }
                                    })
                                }) 
                                item = [].concat.apply([], item);
                                return item;
                            });

                            doItems = [].concat.apply([], doItems);
                            var data = {
                                no: `UT/URN/${codeGenerator()}`,
                                unitId: dataUnit._id,
                                unit: dataUnit,
                                date: new Date(),
                                supplierId: dataSupplier._id,
                                supplier: dataSupplier,
                                deliveryOrderId: dataDeliveryOrder._id,
                                deliveryOrder: dataDeliveryOrder,
                                remark: 'Unit Test',
                                items: doItems
                            };

                            manager.create(data)
                                .then(id => {
                                    manager.getSingleById(id)
{'fraction_non_alphanumeric': 0.08633093525179857, 'fraction_numerical': 0.0009383797309978105, 'mean_word_length': 0.8920118343195266, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 56, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4227335', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1195, 'n_words': 208}