-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from redwoodjs/pp-create-invoice-services
Billable: Create invoice services
- Loading branch information
Showing
22 changed files
with
662 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
experiments/billable/migrations/0004_convert_items_and_taxes_to_json_n.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- DropTable | ||
PRAGMA foreign_keys=off; | ||
DROP TABLE "InvoiceItem"; | ||
PRAGMA foreign_keys=on; | ||
|
||
-- DropTable | ||
PRAGMA foreign_keys=off; | ||
DROP TABLE "InvoiceTaxItem"; | ||
PRAGMA foreign_keys=on; | ||
|
||
-- RedefineTables | ||
PRAGMA defer_foreign_keys=ON; | ||
PRAGMA foreign_keys=OFF; | ||
CREATE TABLE "new_Invoice" ( | ||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
"title" TEXT NOT NULL DEFAULT 'invoice', | ||
"userId" INTEGER NOT NULL, | ||
"number" TEXT NOT NULL, | ||
"date" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"status" TEXT NOT NULL DEFAULT 'draft', | ||
"supplierName" TEXT NOT NULL, | ||
"supplierContact" TEXT NOT NULL, | ||
"customer" TEXT NOT NULL, | ||
"notesA" TEXT, | ||
"notesB" TEXT, | ||
"items" TEXT NOT NULL DEFAULT '[]', | ||
"taxes" TEXT NOT NULL DEFAULT '[]', | ||
CONSTRAINT "Invoice_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE | ||
); | ||
INSERT INTO "new_Invoice" ("customer", "date", "id", "notesA", "notesB", "number", "status", "supplierContact", "supplierName", "title", "userId") SELECT "customer", "date", "id", "notesA", "notesB", "number", "status", "supplierContact", "supplierName", "title", "userId" FROM "Invoice"; | ||
DROP TABLE "Invoice"; | ||
ALTER TABLE "new_Invoice" RENAME TO "Invoice"; | ||
CREATE UNIQUE INDEX "Invoice_userId_number_key" ON "Invoice"("userId", "number"); | ||
PRAGMA foreign_keys=ON; | ||
PRAGMA defer_foreign_keys=OFF; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,7 @@ | |
"description": "", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"build": "npx tsx ./scripts/build.mts", | ||
"dev": "while true; do NODE_ENV=development npx tsx ./scripts/runDevServer.mts; [ $? -eq 0 ] || break; done", | ||
"seed": "pnpm worker:run ./src/scripts/seed.ts", | ||
"migrate:dev": "npx wrangler d1 migrations apply DB --local", | ||
"migrate:prd": "npx wrangler d1 migrations apply DB --remote", | ||
"migrate:new": "npx tsx ./scripts/migrateNew.mts", | ||
"worker:run": "npx tsx ./scripts/runWorkerScript.mts", | ||
"codegen": "npx tsx ./scripts/codegen.mts", | ||
"types": "pnpm codegen:types && tsc", | ||
"deploy": "wrangler deploy", | ||
"preview": "NODE_ENV=${NODE_ENV:-development} PREVIEW=1 npx tsx ./scripts/runPreviewServer.mts", | ||
"format": "npx prettier --write ./src ./scripts" | ||
}, | ||
|
||
"keywords": [], | ||
"author": "", | ||
"license": "UNLICENSED", | ||
|
@@ -73,5 +60,20 @@ | |
"prisma": { | ||
"seed": "npx wrangler d1 execute billable --file prisma/seed.sql --local" | ||
}, | ||
"packageManager": "[email protected]+sha512.c8180b3fbe4e4bca02c94234717896b5529740a6cbadf19fa78254270403ea2f27d4e1d46a08a0f56c89b63dc8ebfd3ee53326da720273794e6200fcf0d184ab" | ||
"packageManager": "[email protected]+sha512.c8180b3fbe4e4bca02c94234717896b5529740a6cbadf19fa78254270403ea2f27d4e1d46a08a0f56c89b63dc8ebfd3ee53326da720273794e6200fcf0d184ab", | ||
"scripts": { | ||
"build": "npx tsx ./scripts/build.mts", | ||
"build:vendor": "npx tsx ./scripts/buildVendorBundles.mts", | ||
"dev": "while true; do NODE_ENV=development npx tsx ./scripts/runDevServer.mts; [ $? -eq 0 ] || break; done", | ||
"seed": "pnpm worker:run ./src/scripts/seed.ts", | ||
"migrate:dev": "npx wrangler d1 migrations apply DB --local", | ||
"migrate:prd": "npx wrangler d1 migrations apply DB --remote", | ||
"migrate:new": "npx tsx ./scripts/migrateNew.mts", | ||
"worker:run": "npx tsx ./scripts/runWorkerScript.mts", | ||
"codegen": "npx tsx ./scripts/codegen.mts", | ||
"types": "pnpm codegen:types && tsc", | ||
"deploy": "wrangler deploy", | ||
"preview": "NODE_ENV=${NODE_ENV:-development} PREVIEW=1 npx tsx ./scripts/runPreviewServer.mts", | ||
"format": "npx prettier --write ./src ./scripts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
DELETE FROM Invoice; | ||
DELETE FROM User; | ||
DELETE FROM sqlite_sequence WHERE name IN ('User', 'Invoice'); | ||
VACUUM; | ||
|
||
INSERT INTO User (id, email) VALUES (1, '[email protected]'); | ||
|
||
INSERT INTO Invoice (id, userId, number, customer, supplierName, supplierContact, notesA) VALUES (1, 1, '1', 'Acme Corp', 'Global Supplies Ltd', '123 Business Ave, Suite 400, Metro City, ST 12345', 'Bank account number 123-456-789, SWIFT: BKCHCNBJ110, IBAN: GB29 NWBK 6016 1331 9268 19'); | ||
INSERT INTO Invoice (id, userId, number, customer, supplierName, supplierContact, notesA, items, taxes) VALUES (1, 1, '1', 'Acme Corp', 'Global Supplies Ltd', '123 Business Ave, Suite 400, Metro City, ST 12345', 'Bank account number 123-456-789, SWIFT: BKCHCNBJ110, IBAN: GB29 NWBK 6016 1331 9268 19', '[{"description": "Professional Web Development Services", "price": 1200.00, "quantity": 1}, {"description": "UI/UX Design Package", "price": 800.00, "quantity": 1}, {"description": "Server Hosting (Monthly)", "price": 99.99, "quantity": 12}, {"description": "Technical Support Hours", "price": 75.00, "quantity": 10}]', '[{"description": "VAT", "amount": 0.14}]'); | ||
|
||
INSERT INTO Invoice (id, userId, number, customer, supplierName, supplierContact, notesA, items, taxes) VALUES (2, 1, '2', 'TechStart Inc', 'Global Supplies Ltd', '123 Business Ave, Suite 400, Metro City, ST 12345', 'Bank account number 123-456-789, SWIFT: BKCHCNBJ110', '[{"description": "Mobile App Development", "price": 3500.00, "quantity": 1}, {"description": "Cloud Infrastructure Setup", "price": 1200.00, "quantity": 1}]', '[{"description": "VAT", "amount": 0.15}, {"description": "City Tax", "amount": 0.02}]'); | ||
|
||
INSERT INTO InvoiceItem (id, invoiceId, description, price, quantity) VALUES (1, 1, 'Professional Web Development Services', 1200.00, 1); | ||
INSERT INTO InvoiceItem (id, invoiceId, description, price, quantity) VALUES (2, 1, 'UI/UX Design Package', 800.00, 1); | ||
INSERT INTO InvoiceItem (id, invoiceId, description, price, quantity) VALUES (3, 1, 'Server Hosting (Monthly)', 99.99, 12); | ||
INSERT INTO InvoiceItem (id, invoiceId, description, price, quantity) VALUES (4, 1, 'Technical Support Hours', 75.00, 10); | ||
INSERT INTO Invoice (id, userId, number, customer, supplierName, supplierContact, notesA, items, taxes) VALUES (3, 1, '3', 'Marketing Masters LLC\nAttn: John Smith\n555 Commerce St\nBusiness City, BZ 54321', 'Global Supplies Ltd', '123 Business Ave, Suite 400, Metro City, ST 12345', NULL, '[{"description": "Digital Marketing Campaign", "price": 2500.00, "quantity": 1}, {"description": "Social Media Management", "price": 800.00, "quantity": 3}, {"description": "Content Creation", "price": 450.00, "quantity": 5}]', '[{"description": "VAT", "amount": 0.14}]'); | ||
|
||
INSERT INTO InvoiceTaxItem (id, invoiceId, description, amount) VALUES (1, 1, 'VAT', 0.14); | ||
INSERT INTO Invoice (id, userId, number, customer, supplierName, supplierContact, notesA, items, taxes) VALUES (4, 1, '4', 'Healthcare Solutions Corp', 'Global Supplies Ltd', '123 Business Ave, Suite 400, Metro City, ST 12345', 'Payment due within 30 days', '[{"description": "Medical Software License", "price": 5000.00, "quantity": 1}, {"description": "Staff Training", "price": 1200.00, "quantity": 2}, {"description": "Support Package", "price": 299.99, "quantity": 12}]', '[{"description": "VAT", "amount": 0.14}, {"description": "Service Tax", "amount": 0.03}]'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.