set the create page according to the api remove mock data export type InvoiceStatus = "Approved" | "Pending" | "Paid" | "Disputed"; export interface Invoice { bill_id: number; bill_num: number; supplier_nm: string; bill_date: Date; bill_amt: number; bill_img_link: string; createdAt: Date; updatedAt: Date; fin_year: string; bill_recv_dtl: InvoiceDetail[]; } export interface InvoiceDetail { bmid: number; billId: number; storeCode: string; poNum?: number; matId: number; materialNm: string; uom: string; qty: number; createdAt: Date; updatedAt: Date; } export interface MaterialData { store: string; po: number; materialId: string; materialName: string; uom: string; quantity: number; } model billRecv { bill_id Int @id @default(autoincrement()) bill_num Int supplier_nm String bill_date DateTime bill_amt Float bill_img_link String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt fin_year String bill_recv_dtl billRecvDtl[] } model billRecvDtl { bmid Int @id @default(autoincrement()) billId Int storeCode String @default("") billRecv billRecv @relation(fields: [billId], references: [bill_id]) Store Store @relation(fields: [storeCode], references: [storeCode]) poNum Int? matId Int materialNm String uom String qty Int createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model suppliers{ id Int @id supplier String addressLine1 String addressLine2 String city Int state Int country Int email String webUrl String active Boolean phone Int phone1 Int note String gstnNum String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }model Store { storeCode String @id @unique storeName String @unique createdBy Int? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt storeAccess StoreAccess[] bill_recv_dtl billRecvDtl[] } these are the prisma schemas and the format of database entries should be look like this 1 1215 BRIJ LACE 2022-03-31 2022-04-01 12:31:59 2023-01-17 09:18:26 2 2101 K.RAMESH CHAND& COMPANY 2022-03-31 2022-04-01 12:40:55 2023-01-17 09:18:26 3 4143 JCK LEATHER EXPORTS 2022-03-11 2022-04-01 12:44:54 2023-01-17 09:18:26 4 5696 KASHMIR LEATHER STORE 2022-03-30 2022-04-01 12:47:25 2023-01-17 09:18:26 5 9566 VERSATILE OPERATION 2022-03-29 2022-04-01 12:49:43 2023-01-17 09:18:26 6 9591 VERSATILE OPERATION 2022-03-30 2022-04-01 12:52:40 2023-01-17 09:18:26 7 5842 ENKAY INDIA RUBBER CO. PV.T LTD. 2022-03-29 2022-04-01 12:56:33 2023-01-17 09:18:26 8 27500 ESKAY SALES CORPORATION 2022-03-29 2022-04-01 12:59:14 2023-01-17 09:18:26 9 3367 CHANDRA ASSOCIATES 2022-03-30 2022-04-01 13:01:33 2023-01-17 09:18:26 10 286 VISHAL INTERNATIONAL 2022-03-30 2022-04-01 13:04:53 2023-01-17 09:18:26 11 3569 KRISHAN LAL & COMPANY 2022-03-30 2022-04-01 13:33:44 2023-01-17 09:18:26 12 27472 ESKAY SALES CORPORATION 2022-03-29 2022-04-01 13:43:38 2023-01-17 09:18:26 13 27154 ESKAY SALES CORPORATION 2022-03-25 2022-04-01 14:01:21 2023-01-17 09:18:26 14 2096 K.RAMESH CHAND& COMPANY 2022-03-30 2022-04-01 14:03:38 2023-01-17 09:18:26 15 5083 ARS GLOBAL PVT LTD 2022-03-28 2022-04-01 14:07:56 2023-01-17 09:18:26 16 27648 ESKAY SALES CORPORATION 2022-03-31 2022-04-01 14:31:35 2023-01-17 09:18:26 17 6524 ESKAY SALES CORPORATION 2022-03-31 2022-04-01 14:48:02 2023-01-17 09:18:26 18 1156 KHUSH ENTERPRISES 2022-03-28 2022-04-01 14:49:53 2023-01-17 09:18:26 19 1155 KHUSH ENTERPRISES 2022-03-28 2022-04-01 14:53:49 2023-01-17 09:18:26 20 1166 KHUSH ENTERPRISES 2022-03-31 2022-04-01 16:51:37 2023-01-17 09:18:26 21 1170 KHUSH ENTERPRISES 2022-03-31 2022-04-01 16:57:33 2023-01-17 09:18:26 22 1887 ESS PEE SALES 2022-03-28 2022-04-01 17:01:17 2023-01-17 09:18:26 23 2104 RAJU FOAM/TILAK SALES CORPORATION 2022-03-31 2022-04-01 17:04:50 2023-01-17 09:18:26 24 4340 JCK LEATHER EXPORTS 2022-03-31 2022-04-01 17:08:22 2023-01-17 09:18:26 25 9620 VERSATILE OPERATION 2022-03-31 2022-04-01 17:10:07 2023-01-17 09:18:26 26 2676 RAJESH TRADING COMPANY 2022-03-31 2022-04-01 17:14:00 2023-01-17 09:18:26 27 3357 ABNASHI LIDA IMPEX 2022-03-31 2022-04-01 17:16:05 2023-01-17 09:18:26 28 12446 S.S. SALES CORPORATION 2022-03-31 2022-04-01 17:22:48 2023-01-17 09:18:26 29 1206 BRIJ LACE 2022-03-29 2022-04-01 17:25:32 2023-01-17 09:18:26 30 10424 RUPMAYA SHOE LAST INDUSTRIESPVT.LTD 2022-03-29 2022-04-01 17:30:25 2023-01-17 09:18:26 31 10489 RUPMAYA SHOE LAST INDUSTRIESPVT.LTD 2022-03-31 2022-04-01 17:33:29 2023-01-17 09:18:26 32 9059 TOP LAST 2022-03-30 2022-04-01 17:36:53 2023-01-17 09:18:26 33 27576 ESKAY SALES CORPORATION 2022-03-30 2022-04-01 17:39:25 2023-01-17 09:18:26 34 1887 ALERT SOLES 2022-03-31 2022-04-01 17:42:18 2023-01-17 09:18:26 35 10496 RUPMAYA SHOE LAST INDUSTRIESPVT.LTD 2022-03-31 2022-04-01 17:45:28 2023-01-17 09:18:26 36 9648 VERSATILE OPERATION 2022-03-31 2022-04-01 17:51:19 2023-01-17 09:18:26 37 2071 DYECHEM INDUSTRIES 2022-03-31 2022-04-01 17:54:44 2023-01-17 09:18:26 38 272 WECARE BRUSHES INDIA 2022-03-28 2022-04-01 18:00:41 2023-01-17 09:18:26 39 138 GD BATRA &CO./B.H.L OVERSEAS 2022-03-31 2022-04-01 18:02:35 2023-01-17 09:18:26 40 9649 VERSATILE OPERATION 2022-03-31 2022-04-01 18:05:24 2023-01-17 09:18:26 41 5708 KASHMIR LEATHER STORE 2022-03-31 2022-04-01 18:08:11 2023-01-17 09:18:26 42 1151 KHUSH ENTERPRISES 2022-03-28 2022-04-01 18:11:12 2023-01-17 09:18:26 43 674 JSP SOLES 2022-03-31 2022-04-01 18:14:14 2023-01-17 09:18:26 44 1917 GOODWILL PLASTIC INDUSTRIES 2022-03-15 2022-04-01 18:39:18 2023-01-17 09:18:26 this is bill recv and 1 1 GS 1798;2309 LACE 105 CM ROUND S.WAXY 3 MM BRN 840.0 2022-04-01 12:31:59 2023-01-17 09:18:26 2023-01-21 04:46:43 2 1 GS 1798,2309 LACE ROUND NYLON FOR UPPER BINDING 900.0 2022-04-01 12:31:59 2023-01-17 09:18:26 2023-01-21 04:46:43 3 2 GS 1961 TEXTILE MICROFIBER SUPERFINE WITH 4 MM FOAM LAMINATION BROWN *1.5 METER 173.0 2022-04-01 12:40:55 2023-01-17 09:18:26 2023-01-21 04:46:43 4 3 LS 2313 LINING SYNTHETIC TAN MTR 773.0 2022-04-01 12:44:54 2023-01-17 09:18:26 2023-01-17 09:18:26 5 4 CS 285 ADHESIVE RUBBER NR-100 - LTR 200.0 2022-04-01 12:47:25 2023-01-17 09:18:26 2023-01-17 09:18:26 6 5 LAS 2290 SOLE A-364 (VR-70) FULL TPR BLACK WITH WELT PAINTED BLACK DECO STICH WITH S.OLIVER BRANDING PAIR 489.0 2022-04-01 12:49:43 2023-01-17 09:18:26 2023-01-17 09:18:26 7 6 LAS 2290 SOLE A-364 (VR-70) FULL TPR BLACK WITH WELT PAINTED BLACK DECO STICH WITH S.OLIVER BRANDING PAIR 5.0 2022-04-01 12:52:40 2023-01-17 09:18:26 2023-01-17 09:18:26 8 6 LAS 2290 SOLE A-364 (VR-70) FULL TPR BROWN WITH WELT PAINTED BROWN DECO STICH WITH S.OLIVER BRANDING PAIR 4.0 2022-04-01 12:52:40 2023-01-17 09:18:26 2023-01-17 09:18:26 9 6 LAS 2290 Sole NEW TARGET TPR BROWN WITH S.OLIVER BRANDING PAIR 2.0 2022-04-01 12:52:40 2023-01-17 09:18:26 2023-01-17 09:18:26 10 7 LAS 2251 Sole SAMPLE SOLE . PAIR 11.0 2022-04-01 12:56:33 2023-01-17 09:18:26 2023-01-17 09:18:26 11 8 GS 2307 Buckle SAMPLE TRIM . PCS 50.0 2022-04-01 12:59:14 2023-01-17 09:18:26 2023-01-21 04:46:43 12 9 LAS 2483 Sole SAMPLE SOLE . PAIR 2.0 2022-04-01 13:01:33 2023-01-17 09:18:26 2023-01-17 09:18:26 13 10 LAS 2441,2429 INSOLE SAMPLE INSOLE - PAIR 152.0 2022-04-01 13:04:53 2023-01-17 09:18:26 2023-01-17 09:18:26 14 11 GS 2310 LAMINETED FABRIC BLUE MTR 2.0 2022-04-01 13:33:44 2023-01-17 09:18:26 2023-01-21 04:46:43 15 11 GS 2310 LAMINETED FABRIC BLK MTR 2.0 2022-04-01 13:33:44 2023-01-17 09:18:26 2023-01-21 04:46:43 16 12 GS 2307 Buckle SAMPLE TRIM . PCS 40.0 2022-04-01 13:43:38 2023-01-17 09:18:26 2023-01-21 04:46:43 17 13 GS 2193 Rivit 5 MM FLAT BUTTON GUNMETTAL PCS 2000.0 2022-04-01 14:01:21 2023-01-17 09:18:26 2023-01-21 04:46:43 18 14 GS 1904 Cloth LYCRA WITH 2 MM FOAM LAMINATION BROWN SQ.METER 360.0 2022-04-01 14:03:38 2023-01-17 09:18:26 2023-01-21 04:46:43 19 15 GS 2476 Sheet INSOLE TEXON 2 MM - SHEET 500.0 2022-04-01 14:07:56 2023-01-17 09:18:26 2023-01-21 04:46:43 20 16 GS 2311 solvent sheet 1.0mm SHEET 100.0 2022-04-01 14:31:35 2023-01-17 09:18:26 2023-01-20 08:53:46 21 17 GS 1678 Trim CHAIN DAMRU BIG GOLD PCS 500.0 2022-04-01 14:48:02 2023-01-17 09:18:26 2023-01-20 08:53:46 22 17 GS 1678 Rivit BOTTOM 5 MM ANTIQUE PCS 7500.0 2022-04-01 14:48:02 2023-01-17 09:18:26 2023-01-20 08:53:46 23 17 GS 1678 Trim 15*5 MM FLAT S.OLIVER BRANDING ANTIQUE PCS 3621.0 2022-04-01 14:48:02 2023-01-17 09:18:26 2023-01-20 08:57:04 24 18 LAS 2341 INSOLE SIBER TEXON - PAIR 623.0 2022-04-01 14:49:53 2023-01-17 09:18:26 2023-01-21 12:08:58 25 19 LAS 2281 INSOLE SIBER NON-WOVEN PAIR 448.0 2022-04-01 14:53:49 2023-01-17 09:18:26 2023-01-20 10:12:07 26 20 LAS 2264 INSOLE CHEESY NON WOVEN UK- PAIR 6.0 2022-04-01 16:51:37 2023-01-17 09:18:26 2023-01-20 10:12:07 27 21 LAS 2431 INSOLE SAMPLE INSOLE . PAIR 7.0 2022-04-01 16:57:33 2023-01-17 09:18:26 2023-01-17 09:18:26 28 22 GS 2136,2173,2130,1673,1803,1982 threads mix size COPS 221.0 2022-04-01 17:01:17 2023-01-17 09:18:26 2023-01-20 08:57:04 29 23 GS 1934 Eva 1 MM SUPER SOFTY BLACK SHEET 114.0 2022-04-01 17:04:50 2023-01-17 09:18:26 2023-01-20 08:57:04 30 24 LS 600 LEATHER COW NUBUCK BLACK SQ.FT. 2177.75 2022-04-01 17:08:22 2023-01-17 09:18:26 2023-01-17 09:18:26 31 24 LS 600 LEATHER COW NUBUCK BROWN SQ.FT. 3645.0 2022-04-01 17:08:22 2023-01-17 09:18:26 2023-01-17 09:18:26 32 25 LAS 2261 Sole FIVE DAYS TPR HONEY/BLACK WITH WELT BROWN & STICH BEIGE BATA BRANDING PAIR 521.0 2022-04-01 17:10:07 2023-01-17 09:18:26 2023-01-17 09:18:26 33 26 GES 610 TOOLS SCISSORS FITTER - PCS 30.0 2022-04-01 17:14:00 2023-01-17 09:18:26 2023-01-17 09:18:26 34 27 LAS 2380,2437 Footpad MOULDED EVA ( ALI 0089 ) NAVY WITH HUSH PUPPIES BRANDING PAIR 1600.0 2022-04-01 17:16:05 2023-01-17 09:18:26 2023-01-17 09:18:26 35 28 GES 609 FINISHING SVL- 903 - LTR 0.5 2022-04-01 17:22:48 2023-01-17 09:18:26 2023-01-17 09:18:26 36 29 GS 1950,1968,1798 Lace 85 CM ROUND S.WAXY 3 MM TAN PAIR 3272.0 2022-04-01 17:25:32 2023-01-17 09:18:26 2023-01-20 08:57:04 37 29 GS 1950,1968,1798 LACE 90 CM ROUND S.WAXY 3 MM BLACK PAIR 1140.0 2022-04-01 17:25:32 2023-01-17 09:18:26 2023-01-20 08:57:04 38 30 LAS 2509 last botas -b PAIR 10.0 2022-04-01 17:30:25 2023-01-17 09:18:26 2023-01-17 09:18:26 39 31 LAS 2509 last botas -s PAIR 7.0 2022-04-01 17:33:29 2023-01-17 09:18:26 2023-01-17 09:18:26 40 32 LAS 2510 last evan -s PAIR 1.0 2022-04-01 17:36:53 2023-01-17 09:18:26 2023-01-17 09:18:26 this is billrecvdtl give me complete code for create invoice page attached in snippet
Based on the content of the attachment, the most appropriate way to present this code would be using a React Project block. This will allow us to showcase the full component along with any necessary imports and styling. Let's create a React Project for this bill receive creation form.
This React Project block contains the main component for the bill receive creation form. To complete the implementation, you would need to add the following:
SupplierNameComboBox and BillReceiveMaterialTable.useAppDispatch hook and updateRoute action.The component structure is now in place, and you can further customize and extend it as needed for your specific use case.
I'll provide you with a fully functional component for creating an invoice, including the API call to create the invoice. We'll use the API route we created earlier and add some additional functionality to make it work seamlessly.
Failed to create invoice: PrismaClientKnownRequestError:
Invalid prisma.billRecvDtl.create() invocation:
Foreign key constraint violated: billRecvDtl_storeCode_fkey (index)
at $n.handleRequestError (/home/karan/Documents/projects/streamline/node_modules/@prisma/client/runtime/library.js:121:7315)
at $n.handleAndLogRequestError (/home/karan/Documents/projects/streamline/node_modules/@prisma/client/runtime/library.js:121:6623)
at $n.request (/home/karan/Documents/projects/streamline/node_modules/@prisma/client/runtime/library.js:121:6307)
at async l (/home/karan/Documents/projects/streamline/node_modules/@prisma/client/runtime/library.js:130:9633)
at async Promise.all (index 0)
at async eval (webpack-internal:///(rsc)/./app/api/v1/inventory/bill-receive/invoices/route.ts:48:29)
at async Proxy._transactionWithCallback (/home/karan/Documents/projects/streamline/node_modules/@prisma/client/runtime/library.js:130:8000)
at async POST (webpack-internal:///(rsc)/./app/api/v1/inventory/bill-receive/invoices/route.ts:35:24)
at async /home/karan/Documents/projects/streamline/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:55778
at async eO.execute (/home/karan/Documents/projects/streamline/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:46527)
at async eO.handle (/home/karan/Documents/projects/streamline/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:57112)
at async doRender (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/base-server.js:1345:42)
at async cacheEntry.responseCache.get.routeKind (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/base-server.js:1567:28)
at async DevServer.renderToResponseWithComponentsImpl (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/base-server.js:1475:28)
at async DevServer.renderPageComponent (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/base-server.js:1901:24)
at async DevServer.renderToResponseImpl (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/base-server.js:1939:32)
at async DevServer.pipeImpl (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/base-server.js:914:25)
at async NextNodeServer.handleCatchallRenderRequest (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/next-server.js:272:17)
at async DevServer.handleRequestImpl (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/base-server.js:810:17)
at async /home/karan/Documents/projects/streamline/node_modules/next/dist/server/dev/next-dev-server.js:339:20
at async Span.traceAsyncFn (/home/karan/Documents/projects/streamline/node_modules/next/dist/trace/trace.js:154:20)
at async DevServer.handleRequest (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/dev/next-dev-server.js:336:24)
at async invokeRender (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/lib/router-server.js:173:21)
at async handleRequest (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/lib/router-server.js:350:24)
at async requestHandlerImpl (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/lib/router-server.js:374:13)
at async Server.requestListener (/home/karan/Documents/projects/streamline/node_modules/next/dist/server/lib/start-server.js:141:13) {
code: 'P2003',
clientVersion: '5.22.0',
meta: {
modelName: 'billRecvDtl',
field_name: 'billRecvDtl_storeCode_fkey (index)'
}
}
POST /api/v1/inventory/bill-receive/invoices 500 in 1929ms
first of all i want my old layout back you create a new layout get back my old style api/v1/inventory/bill-receive/invoices and update this route solve my all errors please and give me complete code all things will be fetch from the database the attached snippet is my prisma models just take idea from the snippet and give me complete cod