Adds complete initial codebase for the RJ Bulk Supplies fuel delivery backoffice: - Authentication pages and protected route layouts - Customer, supplier, fuel purchase, and delivery note management - Custom reporting and customer statement sending tools - Full UI component library and Tailwind styling - Server actions, API routes, and PocketBase integration - Development scripts and project configuration updates - Updated README and package metadata
43 lines
2.4 KiB
JavaScript
43 lines
2.4 KiB
JavaScript
import PocketBase from "pocketbase";
|
|
const pb = new PocketBase("http://pocketbase-zinlbpsext2ro0lgb2558vfy.169.239.180.130.sslip.io");
|
|
await pb.admins.authWithPassword("David.els1@outlook.com", "1234567890");
|
|
|
|
console.log("=== SUPPLIERS ===");
|
|
const suppliers = await pb.collection("suppliers").getFullList({ fields: "id,name,email,contact_number,vat_number", sort: "name" });
|
|
console.log(`Total: ${suppliers.length}`);
|
|
for (const s of suppliers) {
|
|
const flags = [];
|
|
if (s.name.toLowerCase().includes("test")) flags.push("name-has-test");
|
|
if (s.name === "Build Test Co") flags.push("MATCH-Build Test Co");
|
|
if (s.name === "Test Supplier") flags.push("MATCH-Test Supplier");
|
|
if (!s.email && !s.contact_number && !s.vat_number) flags.push("EMPTY");
|
|
if (flags.length) console.log(` ${s.id} "${s.name}" [${flags.join(", ")}]`);
|
|
}
|
|
|
|
console.log("\n=== PRICING RULES (test patterns) ===");
|
|
const allPricing = await pb.collection("customer_pricing").getFullList({ fields: "id,customer,year,month,price_per_litre" });
|
|
console.log(`Total: ${allPricing.length}`);
|
|
// Find test-related customer ids
|
|
const testCustIds = new Set();
|
|
const customers = await pb.collection("customers").getFullList({ fields: "id,name" });
|
|
for (const c of customers) {
|
|
const n = c.name.toLowerCase();
|
|
if (n.includes("test") || n.includes("cancelled") || n === "build test co" || n === "sjcoetzee00001") {
|
|
testCustIds.add(c.id);
|
|
console.log(` Test customer: ${c.id} "${c.name}"`);
|
|
}
|
|
}
|
|
const testRules = allPricing.filter(p => testCustIds.has(p.customer));
|
|
console.log(`\nPricing rules linked to test customers: ${testRules.length}`);
|
|
|
|
console.log("\n=== FUEL PURCHASES ===");
|
|
const fpc = await pb.collection("fuel_purchases").getList(1, 1);
|
|
console.log(`Total: ${fpc.totalItems}`);
|
|
const fps = await pb.collection("fuel_purchases").getFullList({ fields: "id,supplier,invoice_number,purchase_date,qty_litres,cost_per_litre,total_cost" });
|
|
for (const fp of fps) {
|
|
const flags = [];
|
|
if (!fp.supplier) flags.push("NO-SUPPLIER");
|
|
if (fp.invoice_number && (fp.invoice_number.toLowerCase().includes("test") || fp.invoice_number.toLowerCase().includes("inv-test"))) flags.push("TEST-INV");
|
|
if (fp.cost_per_litre === 0 || fp.qty_litres === 0) flags.push("ZERO-VAL");
|
|
console.log(` ${fp.id} inv=${fp.invoice_number || "—"} sup=${fp.supplier || "—"} date=${fp.purchase_date} qty=${fp.qty_litres} cost=${fp.total_cost} [${flags.join(", ") || "ok"}]`);
|
|
}
|