generated from lucien/api-template
Added companies and shareholders main loop
This commit is contained in:
parent
8f11c56d1a
commit
b002d0d730
4 changed files with 32 additions and 22 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue