From 3109e25f2cabb85bbccf4ba509e112e49f5c0120 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 18 Mar 2021 22:10:29 +0300 Subject: feat: add date to Waybill --- src/services/waybills.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/services/waybills.service.ts') diff --git a/src/services/waybills.service.ts b/src/services/waybills.service.ts index ce820bc..e36e4f9 100644 --- a/src/services/waybills.service.ts +++ b/src/services/waybills.service.ts @@ -4,6 +4,7 @@ import service from 'feathers-mongoose'; import { populate, alterItems } from 'feathers-hooks-common'; import Bluebird from 'bluebird'; import _ from 'lodash'; +import moment from 'moment'; import Model from '../models/waybill/waybill.model'; import { WaybillSchema } from '../models/waybill/waybill.schema'; @@ -54,11 +55,12 @@ const reflectStatus = async (context: HookContext): Promise => { const addFields = (item: WaybillSchema) => { - const { operation, records } = item; + const { operation, records, date } = item; const total = item.records.reduce((sum, record) => sum + record.price * record.quantity, 0); const op = operation === 'in' ? 'приход' : 'расход'; const name = `Накладная: ${op} $${total}`; - return { name, total, ...item }; + const formattedDate = moment(date).format('YYYY-MM-DD'); + return { ...item, name, total, date: formattedDate }; }; export default (app: Application): void => { -- cgit v1.2.3