Commit inicial - Sistema de Gestion Hotelera Hacienda San Angel
- Backend Node.js/Express con PostgreSQL - Frontend React 19 con Vite - Docker Compose para orquestacion - Documentacion completa en README.md - Scripts SQL para base de datos - Configuracion de ejemplo (.env.example)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
const pool = require('../db/connection');
|
||||
|
||||
|
||||
const getpurchases = async (req, res) =>
|
||||
{
|
||||
try{
|
||||
const result = await pool.query('SELECT * From getpurchases()');
|
||||
const purchases = result.rows.map(re => ({
|
||||
id_purchase_dt: re.id_purchase_dt,
|
||||
id_expense :re.id_expense ,
|
||||
id_product :re.id_product ,
|
||||
product_name: re.product_name,
|
||||
quantity: re.quantity ,
|
||||
delivered: re.delivered ,
|
||||
id_tax :re.id_tax ,
|
||||
total : re.total
|
||||
|
||||
}));
|
||||
|
||||
res.json({
|
||||
message: "Se obtuvieron todos los Purchases details",
|
||||
data:purchases
|
||||
});
|
||||
|
||||
}catch(error)
|
||||
{
|
||||
console.error(error);
|
||||
res.status(500).json({ message: 'Error al obtener los purchases details.',error });
|
||||
}
|
||||
};
|
||||
const purchaseid = async (req, res) =>
|
||||
{
|
||||
try{
|
||||
const {id} = req.params;
|
||||
const {checking} = req.body;
|
||||
|
||||
console.log(id,checking);
|
||||
const result = await pool.query('SELECT * FROM purchaseentry($1,$2) as status',[id,checking]);;
|
||||
const newentry = result.rows[0].status;
|
||||
res.json({
|
||||
message: 'Se obtuvo el Purchases details', newentry
|
||||
|
||||
});
|
||||
}catch(error)
|
||||
{
|
||||
console.error(error);
|
||||
res.status(500).json({ message: 'Error al obtener el Purchases details',error });
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {getpurchases,purchaseid};
|
||||
Reference in New Issue
Block a user