Python code: six more programs for inventory, accounting and databases

Python code: six more programs for inventory, accounting and databases
This is the index of the code section. Every program is a Python file commented line by line, with sample data and with the output you should get when you run it: download it, unzip it, run it. There is nothing to install and no account to create, because all six use the Python standard library only.
They are written for people who run a small business and want to understand the numbers, not for people building a system: each file reads end to end in one sitting and can be changed without fear. All six were tested before publishing, and every article explains the code with the real fragments that ship inside the ZIP.
First batch: six programs to start with (stock ledger, accounting and a first neural network).
| Program | What it solves | Article |
|---|---|---|
| K4 | how much to order and when: the economic order quantity and the reorder point | Python code: reorder point and economic order quantity (EOQ) |
| K5 | ABC classification (a few products carry most of the value) and turnover | Python code: ABC classification and inventory turnover |
| K6 | the physical count against the system: differences, tolerance and adjustments | Python code: physical count vs system, differences and adjustments |
| C6 | the amount written in words for invoices and receipts, cents included | Python code: convert amounts to words (for invoices and receipts) |
| D1 | SQLite from scratch: create the database, save, query, update and delete | Python code: SQLite from scratch (create, insert, query, update, delete) |
| R5 | the demand forecast with a small network, measured against the moving average | Python code: demand forecast with a small network (compared with the moving average) |
The order that works best
The reorder point and the ABC classification are read together: one says when to buy and the other says which products to look at first. The physical count closes the month and produces the adjustments. Amounts in words and SQLite are tools of a different kind: the first for printed documents, the second to stop working with loose files. The network forecast goes last, once your sales data is in order.
- K4 — reorder point and economic order quantity.
- K5 — ABC classification and turnover.
- K6 — physical count against the system.
- C6 — amounts in words for your documents.
- D1 — SQLite from scratch.
- R5 — demand forecast with a small network.
What you need to run them
| You need | Detail |
|---|---|
| Python 3.11 or newer | Install it once from the official site and it is available for every program |
| A text editor | The one that ships with your system is enough; if you are going to change the data, one with code highlighting helps |
| Your own data | The CSV file inside the datos folder is enough: open it
in Excel, replace it with your movements and save it the same way |
| Five minutes | None of the six takes longer than that to show a result |
| Extra libraries | None: all six use only what ships with Python |
How to start today
Install Python from the official site, pick the program that solves this week's problem and run
it with your own data: in every case it is enough to replace the CSV file that ships in the
datos folder. If the result is useful, keep it; if not, the file stays where it is and
breaks nothing.
When this is not enough
A script answers one concrete question and answers it well. When the business has several warehouses, several users, invoicing and accounting at the same time, the natural next step is Kardex Tauro, which does that work with screens and with the data stored in a database. Until then, these programs help you understand what is being calculated and keep you away from a spreadsheet that only its author can read.
Questions that always come up
Do I need to know how to program? Not to run them: unzip and run one command. To change a formula or add a column you do need to read the program, and that is what the comment on every line is for.
Can I use them in a real business? Yes, and they work: they are tested before publishing. Keep in mind they are didactic internal-control material: check them against your own figures and the rules that apply to you before making decisions with them.
Why are there no screens like an inventory program? Because a screen costs much more than a file, and the point of this section is that you understand the numbers. When the business grows, the next step is a program with a database and several users, not a bigger script.
What happens to my data? Nothing leaves your computer: no servers, no accounts, no internet involved. The program reads and writes files in your own folder.
All six programs are didactic internal-control material: check them against your own figures before using them in a real business.
Third batch: six programs about prices, averages, RSI and sentiment, also free and with a disclaimer, in Python code for markets: stocks, bitcoin and buy-or-sell sentiment (with disclaimer).