summaryrefslogtreecommitdiff
path: root/src/services/waybills.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/waybills.service.ts')
-rw-r--r--src/services/waybills.service.ts6
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 => {