diff options
author | eug-vs <eug-vs@keemail.me> | 2021-03-18 22:10:29 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2021-03-18 22:10:29 +0300 |
commit | 3109e25f2cabb85bbccf4ba509e112e49f5c0120 (patch) | |
tree | 32dc6d10575debbd970a9936e196638f3a1354f1 /src/services | |
parent | 93e5f7eda2f9bf0d274d793f7e823e35502f4763 (diff) | |
download | commercel-api-3109e25f2cabb85bbccf4ba509e112e49f5c0120.tar.gz |
feat: add date to Waybill
Diffstat (limited to 'src/services')
-rw-r--r-- | src/services/waybills.service.ts | 6 |
1 files changed, 4 insertions, 2 deletions
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<HookContext> => { 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 => { |