Lots of updates and added functionality.
Added TODO list to readme as well as instructions.
This commit is contained in:
1 parent
ada1b1a27d
commit
45cb9fac99
13 files changed
+269
-2
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
const { DataTypes } = require('sequelize');
|
||||||
|
const sequelize = require('../db.ts');
|
||||||
|
|
||||||
|
const Boxes = sequelize.define('Boxes', {
|
||||||
|
number: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
unique: true,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
product_sku: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
unique: false,
|
||||||
|
allowNull: true
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
timestamps: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = Boxes;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
const { DataTypes } = require('sequelize');
|
const { DataTypes } = require('sequelize');
|
||||||
const sequelize = require('../db.ts');
|
const sequelize = require('../db.ts');
|
||||||
|
const Boxes = require('./Boxes.ts');
|
||||||
|
|
||||||
const Inventory = sequelize.define('Inventory', {
|
const Inventory = sequelize.define('Inventory', {
|
||||||
sku: {
|
sku: {
|
||||||
@@ -21,19 +22,31 @@ const Inventory = sequelize.define('Inventory', {
|
|||||||
},
|
},
|
||||||
websiteQuantity: {
|
websiteQuantity: {
|
||||||
type: DataTypes.INTEGER,
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: true
|
||||||
},
|
},
|
||||||
ebayQuantity: {
|
ebayQuantity: {
|
||||||
type: DataTypes.INTEGER,
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: true
|
||||||
},
|
},
|
||||||
image: {
|
image: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
|
allowNull: true,
|
||||||
},
|
},
|
||||||
ebayPrice: {
|
ebayPrice: {
|
||||||
type: DataTypes.FLOAT,
|
type: DataTypes.FLOAT,
|
||||||
|
allowNull: true
|
||||||
},
|
},
|
||||||
wooCommercePrice: {
|
wooCommercePrice: {
|
||||||
type: DataTypes.FLOAT,
|
type: DataTypes.FLOAT,
|
||||||
|
allowNull: true
|
||||||
},
|
},
|
||||||
|
total_sold: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Inventory.hasMany(Boxes, { foreignKey: 'product_sku' });
|
||||||
|
Boxes.belongsTo(Inventory, { foreignKey: 'product_sku', onDelete: '' });
|
||||||
|
|
||||||
module.exports = Inventory;
|
module.exports = Inventory;
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
const { DataTypes } = require('sequelize');
|
||||||
|
const sequelize = require('../db.ts');
|
||||||
|
|
||||||
|
const Orders = sequelize.define('Orders', {
|
||||||
|
order_number: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
unique: true,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
platform: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
buyer: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
address: {
|
||||||
|
type: DataTypes.TEXT,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
tracking_number: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: true
|
||||||
|
},
|
||||||
|
contact_email: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: true
|
||||||
|
},
|
||||||
|
contact_phone: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: true
|
||||||
|
},
|
||||||
|
contents: {
|
||||||
|
type: DataTypes.JSON,
|
||||||
|
allowNull: true
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: true
|
||||||
|
},
|
||||||
|
date: {
|
||||||
|
type: DataTypes.DATE,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
net: {
|
||||||
|
type: DataTypes.FLOAT,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
product_cost: {
|
||||||
|
type: DataTypes.FLOAT,
|
||||||
|
allowNull: true
|
||||||
|
},
|
||||||
|
shipping_cost: {
|
||||||
|
type: DataTypes.FLOAT,
|
||||||
|
allowNull: true
|
||||||
|
},
|
||||||
|
fulfillment_cost: {
|
||||||
|
type: DataTypes.VIRTUAL, // Virtual column for calculation in queries
|
||||||
|
allowNull: true,
|
||||||
|
get() {
|
||||||
|
return parseFloat(this.shipping_cost) + parseFloat(this.product_cost);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
profit: {
|
||||||
|
type: DataTypes.VIRTUAL, // Virtual column for calculation in queries
|
||||||
|
allowNull: true,
|
||||||
|
get() {
|
||||||
|
return parseFloat(this.net) - parseFloat(this.fulfillment_cost);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
}, {
|
||||||
|
timestamps: true
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = Orders;
|
||||||
@@ -1,3 +1,36 @@
|
|||||||
# Inventory-Manager
|
# Inventory-Manager
|
||||||
|
|
||||||
Inventory manager to sync eBay & WooCommerce inventories with true inventory value
|
Inventory manager to sync eBay & WooCommerce inventories with true inventory value
|
||||||
|
|
||||||
|
## Running Inventory Manager
|
||||||
|
To use, ensure packages are installed by navigating to the project root and running:
|
||||||
|
`npm install`
|
||||||
|
|
||||||
|
Once required packages have been installe, generate any required TypeScript files, the tsconfig.json file has been set up to compile all files inside the `src` folder, and output them as Javascript to `public/javscripts`.
|
||||||
|
|
||||||
|
For example, creating an `index.ts` file in `src` will compile to `./public/javascripts/indexjs`. To compile your files, simply run `tsc` in the project root directory.
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
## Index
|
||||||
|
- [ ] Add some basic info to a sheet or graph to display:
|
||||||
|
- [ ] Sales Today
|
||||||
|
- [ ] Sales Value Today (If Authenticated)
|
||||||
|
- [ ] Top 5 Best Selling Products
|
||||||
|
|
||||||
|
## Inventory Page
|
||||||
|
- [ ] Add funtionality to enable edit button
|
||||||
|
- [ ] Add functionality to the Sync Inventory button (It needs to sync the true quantity and prices to the platforms.)
|
||||||
|
|
||||||
|
## Add SKU Page
|
||||||
|
- [ ] Clean up layout
|
||||||
|
- [ ] Add more fields to create a better view of the product
|
||||||
|
|
||||||
|
## Boxes Page
|
||||||
|
- [ ] Add buttons to Boxes to allow changing of contained SKU
|
||||||
|
- [ ] Add
|
||||||
|
|
||||||
|
## Orders Page
|
||||||
|
- [ ] Create a table on the Orders page to display any orders, if there are any
|
||||||
|
|
||||||
|
## Settings Page
|
||||||
|
- [ ]
|
||||||
@@ -13,6 +13,8 @@ const { loadSettings, getSetting } = require('./settings.ts');
|
|||||||
const Inventory = require('./Models/Inventory.ts');
|
const Inventory = require('./Models/Inventory.ts');
|
||||||
const User = require('./Models/User.ts');
|
const User = require('./Models/User.ts');
|
||||||
const Settings = require('./Models/Settings.ts');
|
const Settings = require('./Models/Settings.ts');
|
||||||
|
const Orders = require('./Models/Orders.ts');
|
||||||
|
const Boxes = require('./Models/Boxes.ts');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = process.env.PORT || 3000;
|
const PORT = process.env.PORT || 3000;
|
||||||
@@ -66,6 +68,8 @@ app.use('/login', require('./routes/login.ts'));
|
|||||||
app.use('/register', require('./routes/register.ts'));
|
app.use('/register', require('./routes/register.ts'));
|
||||||
app.use('/inventory', ensureAuthenticated, require('./routes/inventory.ts'));
|
app.use('/inventory', ensureAuthenticated, require('./routes/inventory.ts'));
|
||||||
app.use('/settings', ensureAuthenticated, require('./routes/settings.ts'));
|
app.use('/settings', ensureAuthenticated, require('./routes/settings.ts'));
|
||||||
|
app.use('/boxes', ensureAuthenticated, require('./routes/boxes.ts'));
|
||||||
|
app.use('/orders', ensureAuthenticated, require('./routes/orders.ts'));
|
||||||
|
|
||||||
// Database Sync
|
// Database Sync
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www"
|
"start": "node ./app.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"argon2": "^0.41.1",
|
"argon2": "^0.41.1",
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
window.location.href = '/settings';
|
window.location.href = '/settings';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const ordersNav = document.querySelector('#ordersNav');
|
||||||
|
if (ordersNav) {
|
||||||
|
ordersNav.addEventListener('click', () => {
|
||||||
|
window.location.href = '/orders';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const boxesNav = document.querySelector('#boxesNav');
|
||||||
|
if (boxesNav) {
|
||||||
|
boxesNav.addEventListener('click', () => {
|
||||||
|
window.location.href = '/boxes';
|
||||||
|
});
|
||||||
|
}
|
||||||
const logoutNav = document.querySelector('#logoutNav');
|
const logoutNav = document.querySelector('#logoutNav');
|
||||||
if (logoutNav) {
|
if (logoutNav) {
|
||||||
logoutNav.addEventListener('click', (event) => {
|
logoutNav.addEventListener('click', (event) => {
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
const Boxes = require('../Models/Boxes.ts');
|
||||||
|
const Inventory = require('../Models/Inventory.ts');
|
||||||
|
|
||||||
|
router.get('/', async (req, res) => {
|
||||||
|
// get boxes and pass them to the
|
||||||
|
const boxes = await Boxes.findAll({include: Inventory}); // retrieve all inventory records
|
||||||
|
// await console.log(boxes);
|
||||||
|
await res.render('boxes', { boxes });
|
||||||
|
});
|
||||||
|
|
||||||
|
router.post('/:skuToEdit', async (req, res) => {
|
||||||
|
const skuToEdit = req.params.skuToEdit;
|
||||||
|
// update or retrieve data for this SKU and redirect back to boxes page with updated information
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
const Orders = require('../Models/Orders.ts');
|
||||||
|
|
||||||
|
router.get('/', async (req, res) => {
|
||||||
|
// get orders and pass them to the orders.ejs view
|
||||||
|
const orders = await Orders.findAll();
|
||||||
|
res.render('orders', { orders: orders });
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
@@ -34,6 +34,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ordersNav = document.querySelector('#ordersNav');
|
||||||
|
if (ordersNav) {
|
||||||
|
ordersNav.addEventListener('click', () => {
|
||||||
|
window.location.href = '/orders';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const boxesNav = document.querySelector('#boxesNav');
|
||||||
|
if (boxesNav) {
|
||||||
|
boxesNav.addEventListener('click', () => {
|
||||||
|
window.location.href = '/boxes';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const logoutNav = document.querySelector('#logoutNav');
|
const logoutNav = document.querySelector('#logoutNav');
|
||||||
if (logoutNav) {
|
if (logoutNav) {
|
||||||
logoutNav.addEventListener('click', (event) => {
|
logoutNav.addEventListener('click', (event) => {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<section>
|
||||||
|
<h1>Boxes</h1>
|
||||||
|
|
||||||
|
<% if (boxes.length > 0) { %>
|
||||||
|
<div class="row">
|
||||||
|
<% boxes.forEach(box => { %>
|
||||||
|
<script>console.log(<%_box%>)</script>
|
||||||
|
<div class="col-sm-6 col-md-3 mb-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title"><%= box.number %></h5>
|
||||||
|
<p class="card-text"><%= box.product_sku %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% }) %>
|
||||||
|
</div>
|
||||||
|
<% } else { %>
|
||||||
|
<p>No boxes found.</p>
|
||||||
|
<% } %></source_context>
|
||||||
|
</section>
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
<% if (user) { %>
|
<% if (user) { %>
|
||||||
<a class="nav-link" id="inventoryNav">Inventory</a>
|
<a class="nav-link" id="inventoryNav">Inventory</a>
|
||||||
<a class="nav-link" id="settingsNav">Settings</a>
|
<a class="nav-link" id="settingsNav">Settings</a>
|
||||||
|
<a class="nav-link" id="ordersNav">Orders</a>
|
||||||
|
<a class="nav-link" id="boxesNav">Boxes</a>
|
||||||
<a class="nav-link" id="logoutNav">Logout</a>
|
<a class="nav-link" id="logoutNav">Logout</a>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<a class="nav-link" id="loginNav">Login</a>
|
<a class="nav-link" id="loginNav">Login</a>
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<section>
|
||||||
|
<h1>Orders</h1>
|
||||||
|
<% if (orders.length > 0) { %>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Order ID</th>
|
||||||
|
<th>Platform</th>
|
||||||
|
<th>Buyer Name</th>
|
||||||
|
<th>Profit</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% orders.forEach(order => { %>
|
||||||
|
<tr>
|
||||||
|
<td><a href="/orders/<%= order._id %>"><%= order.orderId %></a></td>
|
||||||
|
<td><%= order.platform %></td>
|
||||||
|
<td><%= order.buyerName %></td>
|
||||||
|
<td><% if (order.profit > 0) { %><span class="text-success"><%= order.profit %></span><% } else { %><span class="text-danger"><%= order.profit %></span><% } %></td>
|
||||||
|
</tr>
|
||||||
|
<% }) %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h1>Orders</h1>
|
||||||
|
|
||||||
|
<% if (orders.length) { %>
|
||||||
|
<ul class="list-group mb-3">
|
||||||
|
<% orders.forEach(order => { %>
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
<%= order._id %> - <%= order.platform %> - <%= order.buyerName %><br>
|
||||||
|
<small class="text-muted"><span class="badge bg-primary rounded-pill me-2">Profit: $<%= order.profit %></span><a href="/orders/<%= order._id %>" class="btn btn-sm btn-primary ml-auto">View Details</a></small>
|
||||||
|
</li>
|
||||||
|
<% }) %>
|
||||||
|
</ul>
|
||||||
|
<% }} else { %>
|
||||||
|
<p>No orders found.</p>
|
||||||
|
<% } %>
|
||||||
Reference in new issue
Block a user