Skip to content

Commit

Permalink
Merge pull request #89 from TKOaly/weight-removal
Browse files Browse the repository at this point in the history
Remove weight column from the database
  • Loading branch information
ArktinenKarpalo authored Mar 6, 2024
2 parents ee3d117 + 8be1864 commit 7a7e356
Show file tree
Hide file tree
Showing 11 changed files with 903 additions and 1,854 deletions.
14 changes: 0 additions & 14 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ components:
- barcode
- name
- category
- weight
- sellPrice
- stock
properties:
Expand All @@ -63,10 +62,6 @@ components:
description: Human readable and user facing name of the product.
category:
'$ref': '#/components/schemas/Category'
weight:
type: integer
example: 370
description: Weight of the product in grams.
sellPrice:
type: integer
example: 310
Expand Down Expand Up @@ -1355,7 +1350,6 @@ paths:
- barcode
- name
- categoryId
- weight
- buyPrice
- sellPrice
- stock
Expand All @@ -1373,10 +1367,6 @@ paths:
type: integer
example: 10
minimum: 0
weight:
type: integer
example: 350
minimum: 0
buyPrice:
type: integer
example: 210
Expand Down Expand Up @@ -1466,10 +1456,6 @@ paths:
type: integer
example: 10
minimum: 0
weight:
type: integer
example: 350
minimum: 0
buyPrice:
type: integer
example: 210
Expand Down
7 changes: 0 additions & 7 deletions src/db/boxStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const rowToBox = (row) => {
categoryId: row.pgrpid,
description: row.pgrpdescr
},
weight: row.weight,
buyPrice: row.buyprice,
sellPrice: row.sellprice,
stock: row.count
Expand All @@ -39,7 +38,6 @@ module.exports.getBoxes = async () => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.buyprice',
'PRICE.sellprice',
'PRICE.count'
Expand All @@ -63,7 +61,6 @@ module.exports.findByBoxBarcode = async (boxBarcode) => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.buyprice',
'PRICE.sellprice',
'PRICE.count'
Expand Down Expand Up @@ -100,7 +97,6 @@ module.exports.insertBox = async (boxData) => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.buyprice',
'PRICE.sellprice',
'PRICE.count'
Expand All @@ -119,7 +115,6 @@ module.exports.insertBox = async (boxData) => {
categoryId: productRow.pgrpid,
description: productRow.pgrpdescr
},
weight: productRow.weight,
buyPrice: productRow.buyprice,
sellPrice: productRow.sellprice,
stock: productRow.count
Expand Down Expand Up @@ -152,7 +147,6 @@ module.exports.updateBox = async (boxBarcode, boxData) => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.buyprice',
'PRICE.sellprice',
'PRICE.count'
Expand All @@ -178,7 +172,6 @@ module.exports.deleteBox = async (boxBarcode) => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.buyprice',
'PRICE.sellprice',
'PRICE.count'
Expand Down
2 changes: 0 additions & 2 deletions src/db/historyStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const rowToProduct = (row) => {
categoryId: row.pgrpid,
description: row.pgrpdescr
},
weight: row.weight,
buyPrice: row.buyprice,
sellPrice: row.sellprice,
stock: row.stock
Expand Down Expand Up @@ -60,7 +59,6 @@ const createPurchaseHistoryQuery = () =>
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.barcode',
'PRICE.sellprice',
'PRICE.buyprice',
Expand Down
5 changes: 0 additions & 5 deletions src/db/migrations/20180217113920_prodgroup_rvitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ exports.up = async (knex) => {
.string('descr', 64)
.notNullable()
.comment('Textual product description (name)');
table
.integer('weight')
.unsigned()
.notNullable()
.comment('Product weight');
});
}
};
Expand Down
15 changes: 3 additions & 12 deletions src/db/productStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const rowToProduct = (row) => {
categoryId: row.pgrpid,
description: row.pgrpdescr
},
weight: row.weight,
buyPrice: row.buyprice,
sellPrice: row.sellprice,
stock: row.count
Expand All @@ -31,7 +30,6 @@ module.exports.searchProducts = async (query) => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.barcode',
'PRICE.buyprice',
'PRICE.sellprice',
Expand All @@ -53,7 +51,6 @@ module.exports.getProducts = async () => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.barcode',
'PRICE.buyprice',
'PRICE.sellprice',
Expand All @@ -75,7 +72,6 @@ module.exports.findByBarcode = async (barcode) => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.barcode',
'PRICE.buyprice',
'PRICE.sellprice',
Expand All @@ -101,8 +97,7 @@ module.exports.insertProduct = async (productData, userId) => {
.transacting(trx)
.insert({
pgrpid: productData.categoryId,
descr: productData.name,
weight: productData.weight
descr: productData.name
})
.returning(['itemid']);

Expand Down Expand Up @@ -132,7 +127,6 @@ module.exports.insertProduct = async (productData, userId) => {
categoryId: productData.categoryId,
description: categoryRow.descr
},
weight: productData.weight,
buyPrice: productData.buyPrice,
sellPrice: productData.sellPrice,
stock: productData.stock
Expand All @@ -144,12 +138,11 @@ module.exports.insertProduct = async (productData, userId) => {
* Updates a product's information
*/
module.exports.updateProduct = async (barcode, productData, userId) => {
/* productData may have fields { name, categoryId, weight, buyPrice, sellPrice, stock } */
/* productData may have fields { name, categoryId, buyPrice, sellPrice, stock } */
return await knex.transaction(async (trx) => {
const rvitemFields = deleteUndefinedFields({
pgrpid: productData.categoryId,
descr: productData.name,
weight: productData.weight
descr: productData.name
});
if (Object.keys(rvitemFields).length > 0) {
const priceRow = await knex('PRICE')
Expand Down Expand Up @@ -210,7 +203,6 @@ module.exports.updateProduct = async (barcode, productData, userId) => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.barcode',
'PRICE.buyprice',
'PRICE.sellprice',
Expand Down Expand Up @@ -305,7 +297,6 @@ module.exports.deleteProduct = async (barcode) => {
'RVITEM.descr',
'RVITEM.pgrpid',
'PRODGROUP.descr as pgrpdescr',
'RVITEM.weight',
'PRICE.barcode',
'PRICE.buyprice',
'PRICE.sellprice',
Expand Down
Loading

0 comments on commit 7a7e356

Please sign in to comment.