create-cactus 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +31 -0
- package/package.json +26 -0
- package/template/backend-project/.env +2 -0
- package/template/backend-project/1.drawio +392 -0
- package/template/backend-project/controllers/productsController.js +17 -0
- package/template/backend-project/controllers/reportController.js +59 -0
- package/template/backend-project/controllers/stocktransactionController.js +70 -0
- package/template/backend-project/controllers/userController.js +112 -0
- package/template/backend-project/controllers/warehouseController.js +17 -0
- package/template/backend-project/db/connectDb.js +12 -0
- package/template/backend-project/middleware/authMiddleware.js +15 -0
- package/template/backend-project/models/products.js +13 -0
- package/template/backend-project/models/stocktransaction.js +17 -0
- package/template/backend-project/models/user.js +10 -0
- package/template/backend-project/models/warehouse.js +10 -0
- package/template/backend-project/package-lock.json +1563 -0
- package/template/backend-project/package.json +24 -0
- package/template/backend-project/routes/productsRoutes.js +11 -0
- package/template/backend-project/routes/reportRoutes.js +8 -0
- package/template/backend-project/routes/stocktransactionRoutes.js +13 -0
- package/template/backend-project/routes/userRoutes.js +14 -0
- package/template/backend-project/routes/warehouseRoutes.js +9 -0
- package/template/backend-project/server.js +29 -0
- package/template/frontend-project/README.md +16 -0
- package/template/frontend-project/eslint.config.js +21 -0
- package/template/frontend-project/index.html +13 -0
- package/template/frontend-project/package-lock.json +3050 -0
- package/template/frontend-project/package.json +31 -0
- package/template/frontend-project/public/download.jpg +0 -0
- package/template/frontend-project/public/favicon.svg +1 -0
- package/template/frontend-project/public/icons.svg +24 -0
- package/template/frontend-project/src/App.jsx +31 -0
- package/template/frontend-project/src/api/api.js +13 -0
- package/template/frontend-project/src/assets/hero.png +0 -0
- package/template/frontend-project/src/assets/react.svg +1 -0
- package/template/frontend-project/src/assets/vite.svg +1 -0
- package/template/frontend-project/src/index.css +1 -0
- package/template/frontend-project/src/layout/Pagelayout.jsx +23 -0
- package/template/frontend-project/src/main.jsx +10 -0
- package/template/frontend-project/src/pages/Dashboard.jsx +10 -0
- package/template/frontend-project/src/pages/Login.jsx +54 -0
- package/template/frontend-project/src/pages/Product.jsx +48 -0
- package/template/frontend-project/src/pages/Register.jsx +61 -0
- package/template/frontend-project/src/pages/Reports.jsx +84 -0
- package/template/frontend-project/src/pages/Transactions.jsx +49 -0
- package/template/frontend-project/src/pages/Warehouse.jsx +39 -0
- package/template/frontend-project/vite.config.js +8 -0
package/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const templateDir = path.join(__dirname, 'template');
|
|
9
|
+
|
|
10
|
+
let projectName = process.argv[2];
|
|
11
|
+
|
|
12
|
+
if (!projectName) {
|
|
13
|
+
projectName = 'my-stock-system';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.log(`🚀 Creating Cactus Stock Management System...`);
|
|
17
|
+
console.log(`📁 Project: ${projectName}\n`);
|
|
18
|
+
|
|
19
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
20
|
+
|
|
21
|
+
if (fs.existsSync(targetDir)) {
|
|
22
|
+
console.error(`❌ Error: Folder "${projectName}" already exists!`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fs.copySync(templateDir, targetDir);
|
|
27
|
+
|
|
28
|
+
console.log(`✅ Success! Project created successfully.\n`);
|
|
29
|
+
console.log(`📌 Next: cd ${projectName}`);
|
|
30
|
+
console.log(`Then install dependencies in both backend-project and frontend-project.`);
|
|
31
|
+
console.log(`🎉 Happy Coding with Cactus!`);
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-cactus",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Create a new Stock Management System (Cactus)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"cactus": "./index.js",
|
|
9
|
+
"create-cactus": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"template"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"cactus",
|
|
17
|
+
"stock-management",
|
|
18
|
+
"inventory"
|
|
19
|
+
],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"fs-extra": "^11.3.5"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
<mxfile host="65bd71144e">
|
|
2
|
+
<diagram id="PQ5hsovL6DdM_u9k81B_" name="Page-1">
|
|
3
|
+
<mxGraphModel dx="3047" dy="863" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
|
4
|
+
<root>
|
|
5
|
+
<mxCell id="0"/>
|
|
6
|
+
<mxCell id="1" parent="0"/>
|
|
7
|
+
<mxCell id="2" value="<b>PRODUCT</b>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
8
|
+
<mxGeometry x="-650" y="250" width="120" height="60" as="geometry"/>
|
|
9
|
+
</mxCell>
|
|
10
|
+
<mxCell id="4" value="STOCK<div>TRANSACTION</div>" style="rounded=0;whiteSpace=wrap;html=1;fontStyle=1" vertex="1" parent="1">
|
|
11
|
+
<mxGeometry x="-130" y="635" width="120" height="60" as="geometry"/>
|
|
12
|
+
</mxCell>
|
|
13
|
+
<mxCell id="5" value="WAREHOUSE" style="rounded=0;whiteSpace=wrap;html=1;fontStyle=1" vertex="1" parent="1">
|
|
14
|
+
<mxGeometry x="-640" y="640" width="120" height="60" as="geometry"/>
|
|
15
|
+
</mxCell>
|
|
16
|
+
<mxCell id="6" value="<u>ProductCode</u>" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
17
|
+
<mxGeometry x="-760" y="180" width="120" height="30" as="geometry"/>
|
|
18
|
+
</mxCell>
|
|
19
|
+
<mxCell id="7" value="ProductName" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
20
|
+
<mxGeometry x="-860" y="210" width="120" height="40" as="geometry"/>
|
|
21
|
+
</mxCell>
|
|
22
|
+
<mxCell id="8" value="Category" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
23
|
+
<mxGeometry x="-820" y="265" width="120" height="30" as="geometry"/>
|
|
24
|
+
</mxCell>
|
|
25
|
+
<mxCell id="9" value="QuantityIn<div>Stock</div>" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
26
|
+
<mxGeometry x="-610" y="170" width="120" height="30" as="geometry"/>
|
|
27
|
+
</mxCell>
|
|
28
|
+
<mxCell id="10" value="UnitPrice" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
29
|
+
<mxGeometry x="-860" y="330" width="120" height="20" as="geometry"/>
|
|
30
|
+
</mxCell>
|
|
31
|
+
<mxCell id="11" value="DateReceived" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
32
|
+
<mxGeometry x="-500" y="203" width="120" height="30" as="geometry"/>
|
|
33
|
+
</mxCell>
|
|
34
|
+
<mxCell id="12" value="SupplierName" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
35
|
+
<mxGeometry x="-850" y="390" width="120" height="30" as="geometry"/>
|
|
36
|
+
</mxCell>
|
|
37
|
+
<mxCell id="21" value="<u>TransactionId</u>" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
38
|
+
<mxGeometry x="40" y="535" width="120" height="40" as="geometry"/>
|
|
39
|
+
</mxCell>
|
|
40
|
+
<mxCell id="22" value="WarehouseCode(FK)" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
41
|
+
<mxGeometry x="70" y="605" width="120" height="30" as="geometry"/>
|
|
42
|
+
</mxCell>
|
|
43
|
+
<mxCell id="23" value="TransactionType" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
44
|
+
<mxGeometry x="10" y="665" width="120" height="40" as="geometry"/>
|
|
45
|
+
</mxCell>
|
|
46
|
+
<mxCell id="24" value="QuantityMoved" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
47
|
+
<mxGeometry x="-10" y="740" width="120" height="30" as="geometry"/>
|
|
48
|
+
</mxCell>
|
|
49
|
+
<mxCell id="25" value="TransactionDate" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
50
|
+
<mxGeometry x="-120" y="715" width="120" height="30" as="geometry"/>
|
|
51
|
+
</mxCell>
|
|
52
|
+
<mxCell id="26" value="ProductCode(FK)" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
53
|
+
<mxGeometry x="-250" y="730" width="120" height="40" as="geometry"/>
|
|
54
|
+
</mxCell>
|
|
55
|
+
<mxCell id="27" value="WarehouseLocation" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
56
|
+
<mxGeometry x="-560" y="760" width="120" height="30" as="geometry"/>
|
|
57
|
+
</mxCell>
|
|
58
|
+
<mxCell id="28" value="WarehouseName" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
59
|
+
<mxGeometry x="-690" y="770" width="120" height="40" as="geometry"/>
|
|
60
|
+
</mxCell>
|
|
61
|
+
<mxCell id="29" value="<u>WarehouseCode</u>" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
62
|
+
<mxGeometry x="-780" y="655" width="120" height="30" as="geometry"/>
|
|
63
|
+
</mxCell>
|
|
64
|
+
<mxCell id="30" value="has" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
65
|
+
<mxGeometry x="-405" y="240" width="80" height="80" as="geometry"/>
|
|
66
|
+
</mxCell>
|
|
67
|
+
<mxCell id="31" value="records" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
68
|
+
<mxGeometry x="-425" y="630" width="80" height="80" as="geometry"/>
|
|
69
|
+
</mxCell>
|
|
70
|
+
<mxCell id="33" value="contains" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
71
|
+
<mxGeometry x="-630" y="480" width="80" height="80" as="geometry"/>
|
|
72
|
+
</mxCell>
|
|
73
|
+
<mxCell id="36" value="" style="endArrow=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="31" target="5">
|
|
74
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
75
|
+
<mxPoint x="-380" y="590" as="sourcePoint"/>
|
|
76
|
+
<mxPoint x="-330" y="540" as="targetPoint"/>
|
|
77
|
+
</mxGeometry>
|
|
78
|
+
</mxCell>
|
|
79
|
+
<mxCell id="39" value="" style="endArrow=none;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="33" target="2">
|
|
80
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
81
|
+
<mxPoint x="-569" y="411.02" as="sourcePoint"/>
|
|
82
|
+
<mxPoint x="-570" y="330" as="targetPoint"/>
|
|
83
|
+
</mxGeometry>
|
|
84
|
+
</mxCell>
|
|
85
|
+
<mxCell id="40" value="" style="endArrow=none;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" target="33">
|
|
86
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
87
|
+
<mxPoint x="-590" y="640" as="sourcePoint"/>
|
|
88
|
+
<mxPoint x="-590.36" y="620" as="targetPoint"/>
|
|
89
|
+
</mxGeometry>
|
|
90
|
+
</mxCell>
|
|
91
|
+
<mxCell id="41" value="" style="endArrow=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="31" target="4">
|
|
92
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
93
|
+
<mxPoint x="-250" y="665" as="sourcePoint"/>
|
|
94
|
+
<mxPoint x="-135" y="665" as="targetPoint"/>
|
|
95
|
+
<Array as="points">
|
|
96
|
+
<mxPoint x="-175" y="665"/>
|
|
97
|
+
</Array>
|
|
98
|
+
</mxGeometry>
|
|
99
|
+
</mxCell>
|
|
100
|
+
<mxCell id="42" value="" style="endArrow=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="2" target="30">
|
|
101
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
102
|
+
<mxPoint x="-380" y="210" as="sourcePoint"/>
|
|
103
|
+
<mxPoint x="-370" y="230" as="targetPoint"/>
|
|
104
|
+
</mxGeometry>
|
|
105
|
+
</mxCell>
|
|
106
|
+
<mxCell id="44" value="" style="endArrow=none;html=1;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1">
|
|
107
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
108
|
+
<mxPoint x="-60.00493141924167" y="399.99506858075836" as="sourcePoint"/>
|
|
109
|
+
<mxPoint x="-60" y="309" as="targetPoint"/>
|
|
110
|
+
</mxGeometry>
|
|
111
|
+
</mxCell>
|
|
112
|
+
<mxCell id="46" value="" style="endArrow=none;html=1;entryX=0.638;entryY=1.071;entryDx=0;entryDy=0;exitX=0.75;exitY=0;exitDx=0;exitDy=0;entryPerimeter=0;" edge="1" parent="1" source="2" target="9">
|
|
113
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
114
|
+
<mxPoint x="-630" y="310" as="sourcePoint"/>
|
|
115
|
+
<mxPoint x="-390" y="150" as="targetPoint"/>
|
|
116
|
+
</mxGeometry>
|
|
117
|
+
</mxCell>
|
|
118
|
+
<mxCell id="47" value="" style="endArrow=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;exitX=-0.017;exitY=0.15;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="2" target="7">
|
|
119
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
120
|
+
<mxPoint x="-440" y="200" as="sourcePoint"/>
|
|
121
|
+
<mxPoint x="-390" y="150" as="targetPoint"/>
|
|
122
|
+
</mxGeometry>
|
|
123
|
+
</mxCell>
|
|
124
|
+
<mxCell id="48" value="" style="endArrow=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="2" target="8">
|
|
125
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
126
|
+
<mxPoint x="-440" y="200" as="sourcePoint"/>
|
|
127
|
+
<mxPoint x="-690" y="280" as="targetPoint"/>
|
|
128
|
+
</mxGeometry>
|
|
129
|
+
</mxCell>
|
|
130
|
+
<mxCell id="49" value="" style="endArrow=none;html=1;entryX=0.667;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.192;exitY=-0.05;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="2" target="6">
|
|
131
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
132
|
+
<mxPoint x="-630" y="240" as="sourcePoint"/>
|
|
133
|
+
<mxPoint x="-390" y="150" as="targetPoint"/>
|
|
134
|
+
</mxGeometry>
|
|
135
|
+
</mxCell>
|
|
136
|
+
<mxCell id="55" value="" style="endArrow=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="4" target="26">
|
|
137
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
138
|
+
<mxPoint x="-510" y="585" as="sourcePoint"/>
|
|
139
|
+
<mxPoint x="-460" y="535" as="targetPoint"/>
|
|
140
|
+
</mxGeometry>
|
|
141
|
+
</mxCell>
|
|
142
|
+
<mxCell id="56" value="" style="endArrow=none;html=1;entryX=0.367;entryY=-0.05;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.25;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="5" target="28">
|
|
143
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
144
|
+
<mxPoint x="-1010" y="860" as="sourcePoint"/>
|
|
145
|
+
<mxPoint x="-960" y="810" as="targetPoint"/>
|
|
146
|
+
</mxGeometry>
|
|
147
|
+
</mxCell>
|
|
148
|
+
<mxCell id="57" value="" style="endArrow=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;exitX=-0.005;exitY=0.345;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="5" target="29">
|
|
149
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
150
|
+
<mxPoint x="-1010" y="860" as="sourcePoint"/>
|
|
151
|
+
<mxPoint x="-960" y="810" as="targetPoint"/>
|
|
152
|
+
</mxGeometry>
|
|
153
|
+
</mxCell>
|
|
154
|
+
<mxCell id="58" value="" style="endArrow=none;html=1;exitX=0;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="2">
|
|
155
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
156
|
+
<mxPoint x="-600" y="200" as="sourcePoint"/>
|
|
157
|
+
<mxPoint x="-770" y="329" as="targetPoint"/>
|
|
158
|
+
</mxGeometry>
|
|
159
|
+
</mxCell>
|
|
160
|
+
<mxCell id="59" value="" style="endArrow=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.293;exitY=1.024;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="2" target="12">
|
|
161
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
162
|
+
<mxPoint x="-600" y="200" as="sourcePoint"/>
|
|
163
|
+
<mxPoint x="-550" y="150" as="targetPoint"/>
|
|
164
|
+
</mxGeometry>
|
|
165
|
+
</mxCell>
|
|
166
|
+
<mxCell id="60" value="" style="endArrow=none;html=1;exitX=1;exitY=0.25;exitDx=0;exitDy=0;" edge="1" parent="1" source="2">
|
|
167
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
168
|
+
<mxPoint x="-602" y="310" as="sourcePoint"/>
|
|
169
|
+
<mxPoint x="-480" y="230" as="targetPoint"/>
|
|
170
|
+
</mxGeometry>
|
|
171
|
+
</mxCell>
|
|
172
|
+
<mxCell id="62" value="" style="endArrow=none;html=1;entryX=0.042;entryY=0.725;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.808;exitY=0.017;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="4" target="21">
|
|
173
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
174
|
+
<mxPoint x="-190" y="565" as="sourcePoint"/>
|
|
175
|
+
<mxPoint x="-140" y="515" as="targetPoint"/>
|
|
176
|
+
</mxGeometry>
|
|
177
|
+
</mxCell>
|
|
178
|
+
<mxCell id="63" value="" style="endArrow=none;html=1;entryX=0.083;entryY=0.7;entryDx=0;entryDy=0;entryPerimeter=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="4" target="22">
|
|
179
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
180
|
+
<mxPoint x="-190" y="565" as="sourcePoint"/>
|
|
181
|
+
<mxPoint x="-140" y="515" as="targetPoint"/>
|
|
182
|
+
</mxGeometry>
|
|
183
|
+
</mxCell>
|
|
184
|
+
<mxCell id="64" value="" style="endArrow=none;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="4" target="23">
|
|
185
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
186
|
+
<mxPoint x="-190" y="565" as="sourcePoint"/>
|
|
187
|
+
<mxPoint x="-140" y="515" as="targetPoint"/>
|
|
188
|
+
</mxGeometry>
|
|
189
|
+
</mxCell>
|
|
190
|
+
<mxCell id="65" value="" style="endArrow=none;html=1;entryX=0.35;entryY=0;entryDx=0;entryDy=0;entryPerimeter=0;exitX=1;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="4" target="24">
|
|
191
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
192
|
+
<mxPoint x="-190" y="565" as="sourcePoint"/>
|
|
193
|
+
<mxPoint x="-140" y="515" as="targetPoint"/>
|
|
194
|
+
</mxGeometry>
|
|
195
|
+
</mxCell>
|
|
196
|
+
<mxCell id="66" value="" style="endArrow=none;html=1;entryX=0.375;entryY=0.033;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.442;exitY=0.983;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="4" target="25">
|
|
197
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
198
|
+
<mxPoint x="-190" y="565" as="sourcePoint"/>
|
|
199
|
+
<mxPoint x="-140" y="515" as="targetPoint"/>
|
|
200
|
+
</mxGeometry>
|
|
201
|
+
</mxCell>
|
|
202
|
+
<mxCell id="67" value="" style="endArrow=none;html=1;entryX=0.21;entryY=-0.024;entryDx=0;entryDy=0;entryPerimeter=0;exitX=0.698;exitY=1.071;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="5" target="27">
|
|
203
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
204
|
+
<mxPoint x="-550" y="710" as="sourcePoint"/>
|
|
205
|
+
<mxPoint x="-640" y="790" as="targetPoint"/>
|
|
206
|
+
</mxGeometry>
|
|
207
|
+
</mxCell>
|
|
208
|
+
<mxCell id="69" value="" style="endArrow=none;html=1;entryX=0;entryY=0.25;entryDx=0;entryDy=0;" edge="1" parent="1" target="4">
|
|
209
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
210
|
+
<mxPoint x="-150" y="665" as="sourcePoint"/>
|
|
211
|
+
<mxPoint x="-340" y="515" as="targetPoint"/>
|
|
212
|
+
</mxGeometry>
|
|
213
|
+
</mxCell>
|
|
214
|
+
<mxCell id="70" value="" style="endArrow=none;html=1;exitX=0.62;exitY=1.048;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="2">
|
|
215
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
216
|
+
<mxPoint x="-480" y="180" as="sourcePoint"/>
|
|
217
|
+
<mxPoint x="-590" y="350" as="targetPoint"/>
|
|
218
|
+
</mxGeometry>
|
|
219
|
+
</mxCell>
|
|
220
|
+
<mxCell id="71" value="" style="endArrow=none;html=1;" edge="1" parent="1">
|
|
221
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
222
|
+
<mxPoint x="-600" y="310" as="sourcePoint"/>
|
|
223
|
+
<mxPoint x="-590" y="350" as="targetPoint"/>
|
|
224
|
+
</mxGeometry>
|
|
225
|
+
</mxCell>
|
|
226
|
+
<mxCell id="72" value="" style="endArrow=none;html=1;entryX=0;entryY=0.75;entryDx=0;entryDy=0;" edge="1" parent="1" target="4">
|
|
227
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
228
|
+
<mxPoint x="-150" y="665" as="sourcePoint"/>
|
|
229
|
+
<mxPoint x="-340" y="515" as="targetPoint"/>
|
|
230
|
+
</mxGeometry>
|
|
231
|
+
</mxCell>
|
|
232
|
+
<mxCell id="73" value="" style="endArrow=none;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="30">
|
|
233
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
234
|
+
<mxPoint x="-520" y="290" as="sourcePoint"/>
|
|
235
|
+
<mxPoint x="-130" y="280" as="targetPoint"/>
|
|
236
|
+
</mxGeometry>
|
|
237
|
+
</mxCell>
|
|
238
|
+
<mxCell id="74" value="" style="endArrow=none;html=1;" edge="1" parent="1">
|
|
239
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
240
|
+
<mxPoint x="-80" y="630" as="sourcePoint"/>
|
|
241
|
+
<mxPoint x="-60" y="615" as="targetPoint"/>
|
|
242
|
+
</mxGeometry>
|
|
243
|
+
</mxCell>
|
|
244
|
+
<mxCell id="75" value="" style="endArrow=none;html=1;" edge="1" parent="1">
|
|
245
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
246
|
+
<mxPoint x="-60" y="615" as="sourcePoint"/>
|
|
247
|
+
<mxPoint x="-50" y="630" as="targetPoint"/>
|
|
248
|
+
</mxGeometry>
|
|
249
|
+
</mxCell>
|
|
250
|
+
<mxCell id="76" value="" style="endArrow=none;html=1;" edge="1" parent="1">
|
|
251
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
252
|
+
<mxPoint x="-150" y="270" as="sourcePoint"/>
|
|
253
|
+
<mxPoint x="-150" y="290" as="targetPoint"/>
|
|
254
|
+
<Array as="points"/>
|
|
255
|
+
</mxGeometry>
|
|
256
|
+
</mxCell>
|
|
257
|
+
<mxCell id="80" value="USER" style="rounded=0;whiteSpace=wrap;html=1;fontStyle=1" vertex="1" parent="1">
|
|
258
|
+
<mxGeometry x="-130" y="248" width="120" height="60" as="geometry"/>
|
|
259
|
+
</mxCell>
|
|
260
|
+
<mxCell id="81" value="password" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
261
|
+
<mxGeometry x="-250" y="233" width="120" height="20" as="geometry"/>
|
|
262
|
+
</mxCell>
|
|
263
|
+
<mxCell id="82" value="email" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
264
|
+
<mxGeometry x="-20" y="208" width="120" height="25" as="geometry"/>
|
|
265
|
+
</mxCell>
|
|
266
|
+
<mxCell id="83" value="username" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
267
|
+
<mxGeometry x="-110" y="188" width="120" height="20" as="geometry"/>
|
|
268
|
+
</mxCell>
|
|
269
|
+
<mxCell id="84" value="<span style="font-weight: 400;"><u>UserId</u></span>" style="ellipse;whiteSpace=wrap;html=1;fontStyle=1" vertex="1" parent="1">
|
|
270
|
+
<mxGeometry x="-220" y="208" width="120" height="20" as="geometry"/>
|
|
271
|
+
</mxCell>
|
|
272
|
+
<mxCell id="85" value="" style="endArrow=none;html=1;entryX=0.383;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="80" target="83">
|
|
273
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
274
|
+
<mxPoint x="70" y="468" as="sourcePoint"/>
|
|
275
|
+
<mxPoint x="120" y="418" as="targetPoint"/>
|
|
276
|
+
</mxGeometry>
|
|
277
|
+
</mxCell>
|
|
278
|
+
<mxCell id="86" value="" style="endArrow=none;html=1;entryX=1;entryY=1;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="80" target="81">
|
|
279
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
280
|
+
<mxPoint x="70" y="468" as="sourcePoint"/>
|
|
281
|
+
<mxPoint x="120" y="418" as="targetPoint"/>
|
|
282
|
+
</mxGeometry>
|
|
283
|
+
</mxCell>
|
|
284
|
+
<mxCell id="87" value="" style="endArrow=none;html=1;entryX=0.725;entryY=0.9;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" target="84">
|
|
285
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
286
|
+
<mxPoint x="-100" y="248" as="sourcePoint"/>
|
|
287
|
+
<mxPoint x="120" y="418" as="targetPoint"/>
|
|
288
|
+
</mxGeometry>
|
|
289
|
+
</mxCell>
|
|
290
|
+
<mxCell id="88" value="" style="endArrow=none;html=1;entryX=0.325;entryY=0.96;entryDx=0;entryDy=0;entryPerimeter=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="80" target="82">
|
|
291
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
292
|
+
<mxPoint x="70" y="468" as="sourcePoint"/>
|
|
293
|
+
<mxPoint x="120" y="418" as="targetPoint"/>
|
|
294
|
+
</mxGeometry>
|
|
295
|
+
</mxCell>
|
|
296
|
+
<mxCell id="89" value="" style="endArrow=none;html=1;" edge="1" parent="1">
|
|
297
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
298
|
+
<mxPoint x="-80" y="330" as="sourcePoint"/>
|
|
299
|
+
<mxPoint x="-40" y="330" as="targetPoint"/>
|
|
300
|
+
</mxGeometry>
|
|
301
|
+
</mxCell>
|
|
302
|
+
<mxCell id="90" value="" style="endArrow=none;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" target="98">
|
|
303
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
304
|
+
<mxPoint x="-60" y="630" as="sourcePoint"/>
|
|
305
|
+
<mxPoint x="-49.15506858075878" y="448.28493141924184" as="targetPoint"/>
|
|
306
|
+
</mxGeometry>
|
|
307
|
+
</mxCell>
|
|
308
|
+
<mxCell id="91" value="" style="endArrow=none;html=1;" edge="1" parent="1">
|
|
309
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
310
|
+
<mxPoint x="-600" y="620" as="sourcePoint"/>
|
|
311
|
+
<mxPoint x="-580" y="620" as="targetPoint"/>
|
|
312
|
+
</mxGeometry>
|
|
313
|
+
</mxCell>
|
|
314
|
+
<mxCell id="92" value="" style="endArrow=none;html=1;entryX=1;entryY=0.25;entryDx=0;entryDy=0;" edge="1" parent="1" target="2">
|
|
315
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
316
|
+
<mxPoint x="-500" y="280" as="sourcePoint"/>
|
|
317
|
+
<mxPoint x="-330" y="350" as="targetPoint"/>
|
|
318
|
+
</mxGeometry>
|
|
319
|
+
</mxCell>
|
|
320
|
+
<mxCell id="93" value="" style="endArrow=none;html=1;entryX=1;entryY=0.75;entryDx=0;entryDy=0;" edge="1" parent="1" target="2">
|
|
321
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
322
|
+
<mxPoint x="-500" y="280" as="sourcePoint"/>
|
|
323
|
+
<mxPoint x="-330" y="350" as="targetPoint"/>
|
|
324
|
+
</mxGeometry>
|
|
325
|
+
</mxCell>
|
|
326
|
+
<mxCell id="98" value="performs" style="rhombus;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
327
|
+
<mxGeometry x="-100" y="400" width="80" height="80" as="geometry"/>
|
|
328
|
+
</mxCell>
|
|
329
|
+
<mxCell id="100" value="involvedIn" style="rhombus;whiteSpace=wrap;html=1;rotation=45;" vertex="1" parent="1">
|
|
330
|
+
<mxGeometry x="-360" y="460" width="80" height="80" as="geometry"/>
|
|
331
|
+
</mxCell>
|
|
332
|
+
<mxCell id="101" value="" style="endArrow=none;html=1;entryX=1;entryY=1;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="100" target="2">
|
|
333
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
334
|
+
<mxPoint x="-440" y="540" as="sourcePoint"/>
|
|
335
|
+
<mxPoint x="-390" y="490" as="targetPoint"/>
|
|
336
|
+
</mxGeometry>
|
|
337
|
+
</mxCell>
|
|
338
|
+
<mxCell id="102" value="" style="endArrow=none;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;exitX=0;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="4" target="100">
|
|
339
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
340
|
+
<mxPoint x="-440" y="540" as="sourcePoint"/>
|
|
341
|
+
<mxPoint x="-390" y="490" as="targetPoint"/>
|
|
342
|
+
</mxGeometry>
|
|
343
|
+
</mxCell>
|
|
344
|
+
<mxCell id="103" value="" style="endArrow=none;html=1;" edge="1" parent="1">
|
|
345
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
346
|
+
<mxPoint x="-500" y="690" as="sourcePoint"/>
|
|
347
|
+
<mxPoint x="-500" y="650" as="targetPoint"/>
|
|
348
|
+
</mxGeometry>
|
|
349
|
+
</mxCell>
|
|
350
|
+
<mxCell id="104" value="<u>Key</u><div>Primary keys:-UserId</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -WarehouseCode</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ProductCode</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-TransactionId</div><div><br></div><div>Foreign keys:-WarehouseCode</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -ProductCode</div><div>&nbsp; &nbsp; &nbsp; &nbsp;-UserId</div>" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
|
|
351
|
+
<mxGeometry x="-1170" y="640" width="370" height="370" as="geometry"/>
|
|
352
|
+
</mxCell>
|
|
353
|
+
<mxCell id="105" value="UserId(FK)" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
354
|
+
<mxGeometry x="150" y="650" width="120" height="30" as="geometry"/>
|
|
355
|
+
</mxCell>
|
|
356
|
+
<mxCell id="106" value="" style="endArrow=none;html=1;exitX=1;exitY=0.25;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="4" target="105">
|
|
357
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
358
|
+
<mxPoint x="20" y="640" as="sourcePoint"/>
|
|
359
|
+
<mxPoint x="70" y="590" as="targetPoint"/>
|
|
360
|
+
</mxGeometry>
|
|
361
|
+
</mxCell>
|
|
362
|
+
<mxCell id="107" value="" style="endArrow=none;html=1;" edge="1" parent="1">
|
|
363
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
364
|
+
<mxPoint x="-530" y="330" as="sourcePoint"/>
|
|
365
|
+
<mxPoint x="-500" y="310" as="targetPoint"/>
|
|
366
|
+
</mxGeometry>
|
|
367
|
+
</mxCell>
|
|
368
|
+
<mxCell id="108" value="" style="endArrow=none;html=1;entryX=0.094;entryY=-0.05;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" target="4">
|
|
369
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
370
|
+
<mxPoint x="-150" y="620" as="sourcePoint"/>
|
|
371
|
+
<mxPoint x="-430" y="580" as="targetPoint"/>
|
|
372
|
+
</mxGeometry>
|
|
373
|
+
</mxCell>
|
|
374
|
+
<mxCell id="109" value="" style="endArrow=none;html=1;entryX=0;entryY=0.25;entryDx=0;entryDy=0;" edge="1" parent="1" target="4">
|
|
375
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
376
|
+
<mxPoint x="-160" y="620" as="sourcePoint"/>
|
|
377
|
+
<mxPoint x="-430" y="580" as="targetPoint"/>
|
|
378
|
+
</mxGeometry>
|
|
379
|
+
</mxCell>
|
|
380
|
+
<mxCell id="110" value="TransactionId(FK)" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
|
381
|
+
<mxGeometry x="-465" y="720" width="120" height="30" as="geometry"/>
|
|
382
|
+
</mxCell>
|
|
383
|
+
<mxCell id="111" value="" style="endArrow=none;html=1;exitX=1;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="1" source="5" target="110">
|
|
384
|
+
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
|
385
|
+
<mxPoint x="-480" y="630" as="sourcePoint"/>
|
|
386
|
+
<mxPoint x="-430" y="580" as="targetPoint"/>
|
|
387
|
+
</mxGeometry>
|
|
388
|
+
</mxCell>
|
|
389
|
+
</root>
|
|
390
|
+
</mxGraphModel>
|
|
391
|
+
</diagram>
|
|
392
|
+
</mxfile>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import products from "../models/products.js";
|
|
2
|
+
|
|
3
|
+
export const addProduct=async(req,res)=>{
|
|
4
|
+
try {
|
|
5
|
+
const {ProductCode,ProductName,Category,QuantityInStock,UnitPrice,SupplierName}=req.body;
|
|
6
|
+
const productExists=await products.findOne({ProductCode});
|
|
7
|
+
if(productExists){
|
|
8
|
+
return res.status(400).json({message:"product already inserted"})
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
await new products({ProductCode,ProductName,Category,QuantityInStock,UnitPrice,SupplierName}).save();
|
|
12
|
+
res.status(201).json({message:"new product added successfully"})
|
|
13
|
+
|
|
14
|
+
} catch (error) {
|
|
15
|
+
res.status(500).json({message:"internal server error",error:error.message})
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import stocktransaction from "../models/stocktransaction.js";
|
|
2
|
+
import products from "../models/products.js";
|
|
3
|
+
|
|
4
|
+
export const getReports = async (req, res) => {
|
|
5
|
+
try {
|
|
6
|
+
const today = new Date();
|
|
7
|
+
const daily = new Date();
|
|
8
|
+
daily.setDate(today.getDate() - 1);
|
|
9
|
+
const weekly = new Date();
|
|
10
|
+
weekly.setDate(today.getDate() - 7);
|
|
11
|
+
const monthly = new Date();
|
|
12
|
+
monthly.setMonth(today.getMonth() - 1);
|
|
13
|
+
const dailyStockIn = await stocktransaction.find({
|
|
14
|
+
TransactionType: "IN",
|
|
15
|
+
TransactionDate: { $gte: daily }
|
|
16
|
+
});
|
|
17
|
+
const dailyStockOut = await stocktransaction.find({
|
|
18
|
+
TransactionType: "OUT",
|
|
19
|
+
TransactionDate: { $gte: daily }
|
|
20
|
+
});
|
|
21
|
+
const weeklyStockIn = await stocktransaction.find({
|
|
22
|
+
TransactionType: "IN",
|
|
23
|
+
TransactionDate: { $gte: weekly }
|
|
24
|
+
});
|
|
25
|
+
const weeklyStockOut = await stocktransaction.find({
|
|
26
|
+
TransactionType: "OUT",
|
|
27
|
+
TransactionDate: { $gte: weekly }
|
|
28
|
+
});
|
|
29
|
+
const monthlyStockIn = await stocktransaction.find({
|
|
30
|
+
TransactionType: "IN",
|
|
31
|
+
TransactionDate: { $gte: monthly }
|
|
32
|
+
});
|
|
33
|
+
const monthlyStockOut = await stocktransaction.find({
|
|
34
|
+
TransactionType: "OUT",
|
|
35
|
+
TransactionDate: { $gte: monthly }
|
|
36
|
+
}); const availableStock = await products.find();
|
|
37
|
+
res.status(200).json({
|
|
38
|
+
dailyStockIn,
|
|
39
|
+
dailyStockOut,
|
|
40
|
+
|
|
41
|
+
weeklyStockIn,
|
|
42
|
+
weeklyStockOut,
|
|
43
|
+
|
|
44
|
+
monthlyStockIn,
|
|
45
|
+
monthlyStockOut,
|
|
46
|
+
|
|
47
|
+
availableStock
|
|
48
|
+
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
} catch (error) {
|
|
52
|
+
|
|
53
|
+
res.status(500).json({
|
|
54
|
+
message: "internal server error",
|
|
55
|
+
error: error.message
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import stocktransaction from "../models/stocktransaction.js";
|
|
2
|
+
|
|
3
|
+
export const addStock=async(req,res)=>{
|
|
4
|
+
try {
|
|
5
|
+
const{TransactionId,TransactionDate,QuantityMoved,TransactionType,UserId,WarehouseCode,ProductCode}=req.body;
|
|
6
|
+
const stockExists=await stocktransaction.findOne({TransactionId});
|
|
7
|
+
|
|
8
|
+
if(stockExists){
|
|
9
|
+
return res.status(400).json({message:"stockTransaction already exists"})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
await new stocktransaction({TransactionId,TransactionDate,QuantityMoved,TransactionType,UserId,WarehouseCode,ProductCode}).save();
|
|
13
|
+
|
|
14
|
+
res.status(201).json({message:"new stockTransaction created"})
|
|
15
|
+
} catch (error) {
|
|
16
|
+
res.status(500).json({message:"internal server error",error:error.message})
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const getstock=async(req,res)=>{
|
|
22
|
+
try {
|
|
23
|
+
const stockExists=await stocktransaction.findById(req.params.id);
|
|
24
|
+
|
|
25
|
+
if (!stockExists) {
|
|
26
|
+
return res.status(404).json({ message: "stock transaction not found" });
|
|
27
|
+
}
|
|
28
|
+
res.status(200).json(stockExists);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
res.status(500).json({message:"internal server error",error:error.message})
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const getAllStocks=async(req,res)=>{
|
|
35
|
+
try {
|
|
36
|
+
const stockExists=await stocktransaction.find();
|
|
37
|
+
|
|
38
|
+
if (!stockExists) {
|
|
39
|
+
return res.status(404).json({ message: "stock transaction not found" });
|
|
40
|
+
}
|
|
41
|
+
res.status(200).json(stockExists);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
res.status(500).json({message:"internal server error",error:error.message})
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const updateStock=async(req,res)=>{
|
|
48
|
+
try {
|
|
49
|
+
const stockExists=await stocktransaction.findByIdAndUpdate(req.params.id,req.body,{new:true});
|
|
50
|
+
|
|
51
|
+
if (!stockExists) {
|
|
52
|
+
return res.status(404).json({ message: "stock transaction not found" });
|
|
53
|
+
}
|
|
54
|
+
res.status(200).json(stockExists);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
res.status(500).json({message:"internal server error",error:error.message})
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export const deleteStock=async(req,res)=>{
|
|
60
|
+
try {
|
|
61
|
+
const stockExists=await stocktransaction.findByIdAndDelete(req.params.id);
|
|
62
|
+
|
|
63
|
+
if (!stockExists) {
|
|
64
|
+
return res.status(404).json({ message: "stock transaction not found" });
|
|
65
|
+
}
|
|
66
|
+
res.status(200).json({message:"stock transaction deleted"});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
res.status(500).json({message:"internal server error",error:error.message})
|
|
69
|
+
}
|
|
70
|
+
}
|