add status to invoices
This commit is contained in:
committed by
Daniel Hutzel
parent
9a63f406ec
commit
52f00c62b7
@@ -74,6 +74,11 @@ entity Invoices {
|
|||||||
total : Decimal(10, 2);
|
total : Decimal(10, 2);
|
||||||
invoiceItems : Association to many InvoiceItems
|
invoiceItems : Association to many InvoiceItems
|
||||||
on invoiceItems.invoice = $self;
|
on invoiceItems.invoice = $self;
|
||||||
|
status : Integer enum {
|
||||||
|
submitted = 1;
|
||||||
|
shipped = 2;
|
||||||
|
canceled = -1;
|
||||||
|
} default 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity InvoiceItems {
|
entity InvoiceItems {
|
||||||
@@ -81,7 +86,7 @@ entity InvoiceItems {
|
|||||||
invoice : Association to Invoices;
|
invoice : Association to Invoices;
|
||||||
track : Association to Tracks;
|
track : Association to Tracks;
|
||||||
unitPrice : Decimal(10, 2);
|
unitPrice : Decimal(10, 2);
|
||||||
quantity : Integer;
|
quantity : Integer default 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity Tracks {
|
entity Tracks {
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sap/cds": "^4",
|
"@sap/cds": "^4",
|
||||||
"express": "^4",
|
"express": "^4"
|
||||||
"passport": "^0.4.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"sqlite3": "^5"
|
"sqlite3": "^5"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using {sap.capire.media.store as my} from '../db/schema';
|
|||||||
@(requires : 'authenticated-user')
|
@(requires : 'authenticated-user')
|
||||||
service Invoices {
|
service Invoices {
|
||||||
@readonly
|
@readonly
|
||||||
entity Invoices as projection on my.Invoices;
|
entity MyInvoices as projection on my.Invoices;
|
||||||
|
|
||||||
action invoice(tracks : array of {
|
action invoice(tracks : array of {
|
||||||
ID : Integer;
|
ID : Integer;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports = async function () {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.on("READ", "Invoices", async (req) => {
|
this.on("READ", "MyInvoices", async (req) => {
|
||||||
return await db.run(req.query.where({ customer_ID: req.user.attr.ID }));
|
return await db.run(req.query.where({ customer_ID: req.user.attr.ID }));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ const SRC_STORAGE_NAME = args[FIRST_INDEX];
|
|||||||
const TARGET_STORAGE_NAME = args[SECOND_INDEX];
|
const TARGET_STORAGE_NAME = args[SECOND_INDEX];
|
||||||
const TARGET_SCHEMA_PATH = args[THIRD_INDEX];
|
const TARGET_SCHEMA_PATH = args[THIRD_INDEX];
|
||||||
|
|
||||||
|
function getRandomInt(min, max) {
|
||||||
|
min = Math.ceil(min);
|
||||||
|
max = Math.floor(max);
|
||||||
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
}
|
||||||
|
|
||||||
const camelCaseToSnake = (str) =>
|
const camelCaseToSnake = (str) =>
|
||||||
str.replace(
|
str.replace(
|
||||||
/[a-z][A-Z]/g,
|
/[a-z][A-Z]/g,
|
||||||
@@ -120,6 +126,14 @@ const logProcessArgs = () => {
|
|||||||
password: "some",
|
password: "some",
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
// for mock invoice data
|
||||||
|
if (srcEntityName === "Invoices") {
|
||||||
|
columns.push("status");
|
||||||
|
srcResultRows = srcResultRows.map((row) => ({
|
||||||
|
...row,
|
||||||
|
status: getRandomInt(-1, 2),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
const transaction = await targetStorage.tx();
|
const transaction = await targetStorage.tx();
|
||||||
await transaction.run(
|
await transaction.run(
|
||||||
|
|||||||
Reference in New Issue
Block a user