changing logger

This commit is contained in:
Dzmitry_Tamashevich@epam.com
2020-11-25 20:41:28 +03:00
committed by Daniel Hutzel
parent f439119e73
commit d9b607919a
3 changed files with 15 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import React, { useState, useEffect, useMemo, useCallback } from "react"; import React, { useState, useEffect, useMemo, useCallback } from "react";
import { Button, message, Divider, Tag, Collapse, Table, Spin } from "antd"; import { Button, message, Tag, Collapse, Table, Spin } from "antd";
import moment from "moment"; import moment from "moment";
import { useErrors } from "../hooks/useErrors"; import { useErrors } from "../hooks/useErrors";
import { useAppState } from "../hooks/useAppState"; import { useAppState } from "../hooks/useAppState";

View File

@@ -29,7 +29,11 @@ cds.on("served", async ({ db, messaging, ...servedServices }) => {
// add logging current user before any request // add logging current user before any request
for (let i in servedServices) { for (let i in servedServices) {
servedServices[i].prepend((srv) => servedServices[i].prepend((srv) =>
srv.before("*", (req) => console.log("[USER]:", req.user)) srv.before("*", (req) => {
if (req.user) {
console.log("[USER]:", req.user.id, req.user.attr, req.user._roles);
}
})
); );
} }
}); });

View File

@@ -3,6 +3,7 @@ const moment = require("moment");
const LEVERAGE_DURATION = 1; // in hours. should be the same in the frontend const LEVERAGE_DURATION = 1; // in hours. should be the same in the frontend
const CANCEL_STATUS = -1; const CANCEL_STATUS = -1;
const SHIPPED_STATUS = 1;
const UTC_DATE_TIME_FORMAT = "YYYY-MM-DDThh:mm:ss"; const UTC_DATE_TIME_FORMAT = "YYYY-MM-DDThh:mm:ss";
// the same function there is in the frontend // the same function there is in the frontend
@@ -41,7 +42,7 @@ module.exports = async function () {
"invoice_ID in", "invoice_ID in",
SELECT("ID").from(Invoices).where({ SELECT("ID").from(Invoices).where({
customer_ID: req.user.attr.ID, customer_ID: req.user.attr.ID,
status: 1, status: SHIPPED_STATUS,
}) })
) )
); );
@@ -51,7 +52,6 @@ module.exports = async function () {
if (isNewInvoiceHasInvoicedTracks) { if (isNewInvoiceHasInvoicedTracks) {
await transaction.rollback(); await transaction.rollback();
req.reject(400, "Invoice contains already owned values"); req.reject(400, "Invoice contains already owned values");
return;
} }
// getting last ids for new records // getting last ids for new records
@@ -62,6 +62,9 @@ module.exports = async function () {
SELECT.one(InvoiceItems).columns("ID").orderBy({ ID: "desc" }) SELECT.one(InvoiceItems).columns("ID").orderBy({ ID: "desc" })
); );
console.log("lastInvoiceId", lastInvoiceId);
console.log("lastInvoiceId", lastInvoiceId);
// creating invoice // creating invoice
const { const {
results: [{ lastID: invoiceID }], results: [{ lastID: invoiceID }],
@@ -71,8 +74,10 @@ module.exports = async function () {
.values(++lastInvoiceId, customerId, total, utcNowDateTime) .values(++lastInvoiceId, customerId, total, utcNowDateTime)
); );
console.log("invoiceID", invoiceID);
// creating invoice items // creating invoice items
await transaction.run( const result = await transaction.run(
INSERT.into(InvoiceItems) INSERT.into(InvoiceItems)
.columns("ID", "invoice_ID", "track_ID", "unitPrice") .columns("ID", "invoice_ID", "track_ID", "unitPrice")
.rows( .rows(
@@ -84,6 +89,7 @@ module.exports = async function () {
]) ])
) )
); );
console.log("insert result", result);
await transaction.commit(); await transaction.commit();
}); });