Added companies and shareholders main loop

This commit is contained in:
Lukian 2024-12-29 14:52:50 +01:00
parent 8f11c56d1a
commit b002d0d730
4 changed files with 32 additions and 22 deletions

View file

@ -45,6 +45,10 @@ router.post('/buy', async (req, res) => {
return res.status(500).send({message: "This shareholder already owns that share."})
}
if (shareholder[0].capital < price) {
return res.status(500).send({message: "Insufficient founds."})
}
await addTransaction(connection, price, share[0].owner_id, buyer_id, share_id)
await setShareOwner(connection, share_id, buyer_id)
if (share[0].owner != -1) {