feat: add salePrice field to Product model and update related files
- Added salePrice field to Product model in Prisma schema and generated files. - Updated Product scalar field enums in both TypeScript files. - Modified aggregate output types to include salePrice. - Enhanced input types for creating and updating products to support salePrice. - Updated migration file to add salePrice column to Products table. - Created DTOs for inventory management in POS module. - Implemented POS controller and service with methods for stock and product categories.
This commit is contained in:
+43
-22
@@ -33,40 +33,61 @@ async function main() {
|
||||
|
||||
if ((await prisma.productCategory.count()) === 0) {
|
||||
await prisma.productCategory.createMany({
|
||||
data: [{ name: 'دستهی ۱' }, { name: 'دستهی ۲' }, { name: 'دستهی ۳' }],
|
||||
data: Array.from({ length: 10 }, (_, i) => ({ name: `دستهی ${i + 1}` })),
|
||||
})
|
||||
}
|
||||
|
||||
if ((await prisma.productBrand.count()) === 0) {
|
||||
await prisma.productBrand.createMany({
|
||||
data: [{ name: 'برند ۱' }, { name: 'برند ۲' }, { name: 'برند ۳' }],
|
||||
data: Array.from({ length: 10 }, (_, i) => ({ name: `برند ${i + 1}` })),
|
||||
})
|
||||
}
|
||||
|
||||
if ((await prisma.supplier.count()) === 0) {
|
||||
await prisma.supplier.createMany({
|
||||
data: [
|
||||
{
|
||||
firstName: 'تامین',
|
||||
lastName: 'کننده ۱',
|
||||
mobileNumber: '09120000001',
|
||||
email: 'supplier1@example.com',
|
||||
},
|
||||
{
|
||||
firstName: 'تامین',
|
||||
lastName: 'کننده ۲',
|
||||
mobileNumber: '09120000002',
|
||||
email: 'supplier2@example.com',
|
||||
},
|
||||
{
|
||||
firstName: 'تامین',
|
||||
lastName: 'کننده 3',
|
||||
mobileNumber: '09120000003',
|
||||
email: 'supplier3@example.com',
|
||||
},
|
||||
],
|
||||
data: Array.from({ length: 20 }, (_, i) => ({
|
||||
firstName: 'تامین',
|
||||
lastName: `کننده ${i + 1}`,
|
||||
mobileNumber: `0912000000${i + 1}`,
|
||||
email: `supplier${i + 1}@example.com`,
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
if ((await prisma.customer.count()) === 0) {
|
||||
await prisma.customer.createMany({
|
||||
data: Array.from({ length: 5 }, (_, i) => ({
|
||||
firstName: 'مشتری',
|
||||
lastName: `${i + 1}`,
|
||||
mobileNumber: `0913000000${i + 1}`,
|
||||
email: `customer${i + 1}@example.com`,
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
if ((await prisma.product.count()) === 0) {
|
||||
const categories = await prisma.productCategory.findMany()
|
||||
const brands = await prisma.productBrand.findMany()
|
||||
await prisma.product.createMany({
|
||||
data: Array.from({ length: 100 }, (_, i) => ({
|
||||
name: `کالای ${i + 1}`,
|
||||
sku: `SKU-${1000 + i + 1}`,
|
||||
salePrice: parseInt((Math.random() * (100 - 10) + 10).toString()) * 10000,
|
||||
categoryId: categories[i % categories.length].id,
|
||||
brandId: brands[i % brands.length].id,
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
// const products = await prisma.product.findMany()
|
||||
// for (const product of products) {
|
||||
// await prisma.product.update({
|
||||
// where: { id: product.id },
|
||||
// data: {
|
||||
// salePrice: parseInt((Math.random() * (100 - 10) + 10).toString()) * 10000,
|
||||
// },
|
||||
// })
|
||||
// }
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user