Files
productManager/include/logic.h
T
2026-10-10 20:40:24 +02:00

52 lines
1.9 KiB
C

#ifndef LOGIC_H
#define LOGIC_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ncurses.h>
#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 deleteSold(const char *productsFile, const char *soldFile, const char *name);
int updateSold(const char *productsFile, const char *soldFile, const char *name, int qty);
int recordSale(const char *productsFile, const char *soldFile, const char *name, int qty);
/* Entrate */
double getTotalRevenue(const char *productsFile, const char *soldFile);
/* Export */
int exportSalesToCsv(const char *productsFile, const char *soldFile, const char *outFile);
/* Config */
int ensureAppConfig(const char *fname);
int loadAppConfig(const char *fname);
int saveAppConfig(const char *fname);
#endif