- Enhanced `nss-fasteners-pb-import.json` to compute `selling_price` as `cost_price * (1 + 80%)` and included `markup` in the records. - Updated `nss-fasteners-pb-transform.ts` to allow configurable CSV and output file names via environment variables, improving flexibility for different product runs. - Added support for uploading photos in the repair detail page, including validation for file types and sizes, and implemented a dialog for creating customer quotes linked to repairs. - Introduced a new `customer_quote` field in the `Repair` type to link generated quotes back to their respective repairs. These changes streamline the pricing process and enhance the user experience in managing repairs and quotes.
94 lines
No EOL
3.3 KiB
TypeScript
94 lines
No EOL
3.3 KiB
TypeScript
import "./_env";
|
|
import { getAdminPocketBase } from "../src/lib/server/pocketbase-admin";
|
|
|
|
const LOCATION = "NSS Fasteners price list - split pin DIN94";
|
|
|
|
async function main() {
|
|
const pb = await getAdminPocketBase();
|
|
|
|
const total = await pb.collection("stock_items").getList(1, 1, {
|
|
filter: `location = "${LOCATION}"`,
|
|
});
|
|
console.log(`SPLIT PINS imported rows in PB: ${total.totalItems}\n`);
|
|
|
|
const rows = await pb.collection("stock_items").getList(1, 5, {
|
|
filter: `location = "${LOCATION}"`,
|
|
sort: "sku",
|
|
});
|
|
for (const r of rows.items) {
|
|
console.log("SKU: " + r.sku);
|
|
console.log("name: " + JSON.stringify(r.name));
|
|
console.log("description:" + JSON.stringify(r.description));
|
|
console.log("cost_price: " + r.cost_price);
|
|
console.log("selling: " + r.selling_price);
|
|
console.log("markup: " + r.markup);
|
|
console.log("notes: " + JSON.stringify(r.notes?.substring(0, 200)));
|
|
console.log("name == description? " + (r.name === r.description ? "YES ✓" : "NO ✗"));
|
|
console.log("");
|
|
}
|
|
|
|
// Anomalies
|
|
const zeroPrice = await pb.collection("stock_items").getFullList({
|
|
filter: `location = "${LOCATION}" && cost_price = 0`,
|
|
fields: "sku,cost_price,name",
|
|
batch: 500,
|
|
});
|
|
console.log(`Rows with cost_price = 0: ${zeroPrice.length}`);
|
|
if (zeroPrice.length > 0) {
|
|
console.log(" Examples:");
|
|
for (const r of zeroPrice.slice(0, 5)) {
|
|
console.log(` ${r.sku} ${r.name}`);
|
|
}
|
|
}
|
|
|
|
const noMarkup = await pb.collection("stock_items").getFullList({
|
|
filter: `location = "${LOCATION}" && cost_price > 0 && markup = 0`,
|
|
fields: "sku,cost_price,name,selling_price",
|
|
batch: 500,
|
|
});
|
|
console.log(`Rows with cost>0 and markup=0 (anomaly!): ${noMarkup.length}`);
|
|
|
|
const noSelling = await pb.collection("stock_items").getFullList({
|
|
filter: `location = "${LOCATION}" && cost_price > 0 && selling_price = 0`,
|
|
fields: "sku,cost_price,name,selling_price",
|
|
batch: 500,
|
|
});
|
|
console.log(`Rows with cost>0 and selling_price=0 (anomaly!): ${noSelling.length}`);
|
|
|
|
// Diameter / length / split-pin coverage
|
|
const noDiam = await pb.collection("stock_items").getFullList({
|
|
filter: `location = "${LOCATION}" && notes !~ "Diameter:"`,
|
|
fields: "sku",
|
|
batch: 500,
|
|
});
|
|
console.log(`Rows missing 'Diameter:' in notes: ${noDiam.length}`);
|
|
const noLen = await pb.collection("stock_items").getFullList({
|
|
filter: `location = "${LOCATION}" && notes !~ "Length:"`,
|
|
fields: "sku",
|
|
batch: 500,
|
|
});
|
|
console.log(`Rows missing 'Length:' in notes: ${noLen.length}`);
|
|
const noFinish = await pb.collection("stock_items").getFullList({
|
|
filter: `location = "${LOCATION}" && notes !~ "Finish:"`,
|
|
fields: "sku",
|
|
batch: 500,
|
|
});
|
|
console.log(`Rows missing 'Finish:' in notes: ${noFinish.length}`);
|
|
const noSplitPin = await pb.collection("stock_items").getFullList({
|
|
filter: `location = "${LOCATION}" && name !~ "SPLIT PIN"`,
|
|
fields: "sku,name",
|
|
batch: 500,
|
|
});
|
|
console.log(`Rows missing 'SPLIT PIN' in name: ${noSplitPin.length}`);
|
|
if (noSplitPin.length > 0) {
|
|
console.log(" Examples:");
|
|
for (const r of noSplitPin.slice(0, 5)) {
|
|
console.log(` ${r.sku} ${r.name}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
}); |