When the Flask server starts, it automatically reads two Excel files and populates the MySQL database with responsible persons, locations, and inventory items. This removes the need for manual data entry and makes the initial setup reproducible from source files.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/Goods-Inventory/llms.txt
Use this file to discover all available pages before exploring further.
How it works
app/controllers/excel_loader.py exports a single public function:
create_app(), inside the active Flask application context, immediately after db.create_all(). The function receives the paths to both Excel files and processes them in order — areas first, then articles — so that location records exist before items are linked to them.
areas.xls
This file defines the physical locations and their responsible persons. Expected format:- Column headers are on row 5 (
header=4in pandas, zero-indexed). - Required columns:
Responsable(s),Ubicación,Descripción. - Any row with a
NaNvalue in one of those columns is silently skipped. - For each valid row the loader searches for an existing
Responsiblerecord by name. If none is found, a new record is created. It then creates or updates the correspondingLocation.
excel_loader.py
articulos.xls
This file lists the individual inventory items. Expected format:- Column headers are on row 7 (
header=6in pandas, zero-indexed). - Required columns:
NO.CUENTA,UBICA,DESCRIPCION. - Any row with a
NaNvalue in one of those columns is silently skipped. - Items whose
UBICAvalue does not match a knownLocationrecord are silently skipped — the location data inareas.xlsmust be loaded first. NO.CUENTAis stored as a string containing only the integer portion of the value (the decimal part, if any, is discarded by splitting on.).
excel_loader.py
Idempotency
load_excel_data is safe to call on every server startup. Throughout both import loops, the loader uses find-or-create logic: it queries the database for an existing record before inserting a new one, and updates fields on existing records to match the current file contents. No duplicate rows are created across restarts.