From 49e63b292dbaafc939ddd67aede66531835ce002 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Thu, 28 Nov 2024 13:20:49 -0500 Subject: [PATCH] Updated BOM script formats dollars and cents properly. Need to format another column for minimum --- README.md | 30 +++++++++++++++--------------- scripts/bom.sh | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 422d237..28189d1 100644 --- a/README.md +++ b/README.md @@ -41,21 +41,21 @@ Actual price of a full build may be higher. | Part | Qty | Cost (USD) | |-------------------------------------|-----|------------| -| M4 hex bolt 40mm | 4 | 2.4 | -| M3 sliding t slot nut | 25 | 1.25 | -| M3 hex cap bolt 8mm | 25 | 2.0 | -| M3 hex cap bolt 6mm | 8 | 0.56 | -| M3 hex cap bolt 12mm | 1 | 0.08 | -| L298N Motor driver module | 1 | 2.87 | -| ESP32 GPIO breakout board | 1 | 5.99 | -| ESP32 Dev board | 1 | 6.66 | -| 608-RS Ball Bearing | 1 | 0.17 | -| 250RPM DC geared motor | 2 | 29.98 | -| 2020 Aluminum extrusion 420mm | 2 | 5.1 | -| 2020 Aluminum extrusion 260mm | 4 | 6.4 | -| 100RPM DC geared motor with encoder | 1 | 16.19 | -|---------|---------------|------------------------------------| -| TOTAL | 76 | 79.65 | +| M4 hex bolt 40mm | 4 | $2.40 | +| M3 sliding t slot nut | 25 | $1.25 | +| M3 hex cap bolt 8mm | 25 | $2.00 | +| M3 hex cap bolt 6mm | 8 | $0.56 | +| M3 hex cap bolt 12mm | 1 | $0.08 | +| L298N Motor driver module | 1 | $2.87 | +| ESP32 GPIO breakout board | 1 | $5.99 | +| ESP32 Dev board | 1 | $6.66 | +| 608-RS Ball Bearing | 1 | $0.17 | +| 250RPM DC geared motor | 2 | $29.98 | +| 2020 Aluminum extrusion 420mm | 2 | $5.10 | +| 2020 Aluminum extrusion 260mm | 4 | $6.40 | +| 100RPM DC geared motor with encoder | 1 | $16.19 | +|---------|---------------|--------------------------------------------------| +| TOTAL | 76 | $79.65 | diff --git a/scripts/bom.sh b/scripts/bom.sh index a5a3425..d3fa236 100644 --- a/scripts/bom.sh +++ b/scripts/bom.sh @@ -55,10 +55,10 @@ sqlite3 :memory: -cmd '.mode csv' -cmd ".import ${DESTINATION} bom" -cmd ".impor 'SELECT SUM(quantity),part,part_id, SUM(quantity) * (COALESCE((SELECT CEIL(prices.price / prices.quantity) FROM prices WHERE prices.part = bom.part LIMIT 1), 0)) as price FROM bom GROUP BY part ORDER BY part DESC;' >> "${TOTAL}" sqlite3 :memory: -cmd '.mode csv' -cmd ".import ${TOTAL} bom" -cmd '.mode markdown' \ - "SELECT part as Part, quantity as Qty, CAST(price / 100.00 as MONEY) as 'Cost (USD)' FROM bom ORDER BY part DESC;" + "SELECT part as Part, quantity as Qty, printf('$%.2f', CAST(price AS FLOAT) / 100) as 'Cost (USD)' FROM bom ORDER BY part DESC;" sqlite3 :memory: -cmd '.mode csv' -cmd ".import ${TOTAL} bom" -cmd '.mode markdown' \ - "SELECT 'TOTAL', SUM(quantity), CAST(SUM(price) / 100.00 as MONEY) FROM bom;" | grep -v 'SUM(' + "SELECT 'TOTAL', SUM(quantity), printf('$%.2f', CAST(SUM(price) AS FLOAT) / 100) FROM bom;" | grep -v 'SUM(' sqlite3 :memory: -cmd '.mode csv' -cmd ".import ${TOTAL} bom"\ "SELECT SUM(quantity), 'TOTAL', 'N/A', SUM(price) FROM bom;" | tr -d '"' >> "${TOTAL}"