#ifndef LOGIC_H #define LOGIC_H #include #include #include #include #include "jsonFile.h" #define PRODUCT_STOCK_UNLIMITED (-1) struct product { float cost; int numberSold; char name; }; /* Prodotti */ json_object *getProducts(const char *fname); void listProducts(const char *fname); int addProduct(const char *fname, const char *name, double price); int addProductWithInventory(const char *fname, const char *name, double price, int stock); int addBundleProduct(const char *fname, const char *name, double price, json_object *components); double getPrice(const char *fname, const char *name); int updateProduct(const char *productsFile, const char *soldFile, const char *oldName, const char *newName, double price); int updateProductWithInventory(const char *productsFile, const char *soldFile, const char *oldName, const char *newName, double price, int stock); int getProductInventory(const char *fname, const char *name, int *stock, int *tracked); int setProductInventory(const char *fname, const char *name, int stock, int tracked); int consumeProductInventory(const char *fname, const char *name, int qty); /* Copie vendute */ int getCount(const char *fname, const char *name); void listSold(const char *fname); int addSold(const char *fname, const char *name, int qty); int updateSold(const char *fname, const char *name, int qty); int deleteSold(const char *fname, const char *name); int recordSale(const char *productsFile, const char *soldFile, const char *name, int qty); /* Entrate */ double getTotalRevenue(const char *productsFile, const char *soldFile); /* Config */ int ensureAppConfig(const char *fname); int loadAppConfig(const char *fname); int saveAppConfig(const char *fname); #endif