func (VS *Server) makeSale(c *gin.Context, sale Sale) {
	// The worker pays for the materials
	worker := VS.getUserByID(c, sale.IDWorker, "h_transactions", "makeSale", "worker := VS.getUserByID")
	worker.Balance -= sale.Price
	VS.addUserToDatabase(c, worker, "h_transactions", "makeSale", "VS.addUserToDatabase")

	// The Workshop gets money for the materials
	wk := VS.getServiceByID(c, sale.IDService, "h_transactions", "makeSale", "wk := VS.getOurWorkshop", true)
	wk.Balance += sale.Price
	VS.addServiceToDatabase(c, wk, "h_transactions", "makeSale", "VS.addServiceToDatabase")

	// Make the stock (if you are selling it there is already a stock created)
	stock, b := VS.getStockByItemAndService(c, sale.IDStock, sale.IDService, "h_transactions", "makeStockDelivery", "stock := VS.getStockByItemAndService")
	if !b {
		fmt.Println("Error, stock not found")
		fmt.Print("this is sale.IDStock")
		fmt.Println(sale.IDStock)
		fmt.Print("this is sale.IDService")
		fmt.Println(sale.IDStock)
		return
	}
	stockOriginal := stock
	VS.editElementInDatabaseWithRegister(c, stock, stockOriginal, stock.ID, sale.IDService, "VS.addStockToDatabase", "makeStockDelivery", "stock := VS.getStockByItemAndService")
}
// Make all the changes in the Wallet, Inventory, User balance and Service balance
Make all the changes in the Wallet, Inventory, User balance and Service balance
// Make all the changes in the Wallet Inventory User balance and Service balance
func (VS *Server) makeSale(c *gin.Context, sale Sale) {
	worker := VS.getUserByID(c, sale.IDWorker, "h_transactions", "makeSale", "worker := VS.getUserByID")
	worker.Balance -= sale.Price
	VS.addUserToDatabase(c, worker, "h_transactions", "makeSale", "VS.addUserToDatabase")
	wk := VS.getServiceByID(c, sale.IDService, "h_transactions", "makeSale", "wk := VS.getOurWorkshop", true)
	wk.Balance += sale.Price
	VS.addServiceToDatabase(c, wk, "h_transactions", "makeSale", "VS.addServiceToDatabase")
	stock, b := VS.getStockByItemAndService(c, sale.IDStock, sale.IDService, "h_transactions", "makeStockDelivery", "stock := VS.getStockByItemAndService")
	if !b {
		fmt.Println("Error, stock not found")
		fmt.Print("this is sale.IDStock")
		fmt.Println(sale.IDStock)
		fmt.Print("this is sale.IDService")
		fmt.Println(sale.IDStock)
		return
	}
	stockOriginal := stock
	VS.editElementInDatabaseWithRegister(c, stock, stockOriginal, stock.ID, sale.IDService, "VS.addStockToDatabase", "makeStockDelivery", "stock := VS.getStockByItemAndService")
}
func ( VS * Server ) makeSale ( c * gin . Context , sale Sale ) { worker := VS . getUserByID ( c , sale . IDWorker , " " , " " , " " ) worker . Balance -= sale . Price VS . addUserToDatabase ( c , worker , " " , " " , " " ) wk := VS . getServiceByID ( c , sale . IDService , " " , " " , " " , true ) wk . Balance += sale . Price VS . addServiceToDatabase ( c , wk , " " , " " , " " ) stock , b := VS . getStockByItemAndService ( c , sale . IDStock , sale . IDService , " " , " " , " " ) if ! b { fmt . Println ( " " ) fmt . Print ( " " ) fmt . Println ( sale . IDStock ) fmt . Print ( " " ) fmt . Println ( sale . IDStock ) return } stockOriginal := stock VS . editElementInDatabaseWithRegister ( c , stock , stockOriginal , stock . ID , sale . IDService , " " , " " , " " ) }
Make all the changes in the Wallet, Inventory, User balance and Service balance
Make all the changes in the Wallet Inventory User balance and Service balance
// The worker pays for the materials // The Workshop gets money for the materials // Make the stock (if you are selling it there is already a stock created)