While looking at KWORK applications for software development, I found an interesting request, apparently from a self-employed or an entrepreneur who has his own small production: we need a simple program for analyzing the profitability of the production process, in fact – accounting for the materials used and comparing with the profit received from the sale of finished products . Of course, for a complete analysis, it is also necessary to take into account the costs of electricity, rent of premises, depreciation of equipment, taxes, etc., but in some cases it is enough to control only materials and finished products.

Despite the large number of accounting programs, including free ones, people are looking for what is right for them. And when tablets in MS Excell cease to suit them, and they are not ready to buy 1C or pay a monthly fee for online services, then the developers of the platform My Visual Database appears a chance to offer them the best solution.


When it comes to accounting for profit, the first thing that comes up is the method of calculating the cost. The task would be trivial in the case when the price of the materials used does not change, and the production has no defects. But in reality, everything is more complicated: purchase prices are constantly changing, and production technologies fail, as a result of which part of the raw materials, and sometimes finished products, have to be written off.

For the correct calculation of the cost in accounting, several calculation methods are used: FIFO, LIFO and batch accounting. The latter is best suited for accounting automation and gives a complete and clear picture, as it is based on the accounting of consignments.

A batch of goods is a product of a certain nomenclature with a certain purchase price.

Traditional accounting involves moving information about value and quantity between separate sub-accounts – analytical units of accounting. In addition, each accounting document generates many separate accounting entries. But in our case, a simplified system will work. It will include accounting for primary documentation (incoming and outgoing invoices), the details of which will act as postings. As a result, you will see the following economic indicators:

  • Stock balance
  • Production volumes
  • Purchase/sales volumes
  • Profit/loss

In fact, production accounting differs from sales accounting by the presence of a special counterparty who receives materials from the warehouse and returns finished products. In the future, this counterparty will be called “production site” or “workshop”. For the convenience of creating production documents, there is a special reference book that describes the consumption rates of materials needed to create a particular product.

Data Schema

Let’s denote the list of entities necessary for the implementation of the project.

  • Item type –itemType
  • Item – item
  • Parts – productItem
  • Material/goods batch – pItem
  • Account type – contrType
  • Account – contr
  • Document type – docType
  • Document – operDoc
  • Accounting operation (document detail) – oper

The references docType and contrType are auxiliary – in these tables the value of the ID field is used in the logic of the program. Therefore, they are filled in automatically when the application is launched for the first time and are not editable. The remaining tables are user-defined and for each of them there is a table view form and an editing form. Let’s consider them in more detail.


Item type added for two purposes:

  1. Separate materials (isProduct = 0) and finished products (isProduct = 1)
  2. Filter and group items for easy search and analysis


The item belongs to a specific type (id_itemType), has a mandatory name (name) and an optional article number (code)


Product composition is a list of nomenclature units (id_item1) that are included in this product (id_item) with an indication of the quantity (qty). This guide is not mandatory, but helps to create documents for writing off materials for production – it both contains regulatory requirements and facilitates production planning. It can be used to evaluate inventories for the quantity of products that can be produced from them. But production planning is a separate topic that will not be disclosed in this project.


Batch allows you to combine different actions into a single process. It sounds like a political slogan, but it’s actually a way to make it easier to generate a SQL query to perform certain actions: determining the purchase/production price, controlling stocks, calculating profit/loss.

So far, the party does not have its own visual identifier, only a link to the item (id_item), but most likely in the future, for convenience, a calculated field will be added to display the name of the party, which will consist of the name of the item and the ordinal numbers (in chronological order of income).


Document includes traditional required fields: document type (id_docType), date (docDate), number (docNum), from ( >id_contr) and where (id_contr1) materials or goods are moving. There is also an optional comment field (comment).


Document detail (accounting transaction) contains a link to the document (id_operDoc), a link to the lot (pItem), as well as information about the quantity (qty) and the amount (amount). If necessary, price information will be calculated using the formula: <Price> = <Amount> / <Quantity>


The counterparty can be suppliers, buyers, as well as warehouses and production shops of the enterprise. There can be many counterparties (if analytics for different counterparties is required), or there can be one of each type (id_contrType). Since the program only serves to record production, counterparties have only one field with details – the name.

Let use skill

Previously, several articles dealt with various techniques that I would like to use in other projects, in particular in this program. To do this, I will copy all the ClassExplorer project folders, except for the Extras folder, into the Production project folder. Then I will create a new project folder in Notepad++ and fill it with files from the copied folders. To do this, use the pop-up menu item “Add files from directory..”

Then perform the following steps in sequence

Remove from project:

  • script.dcu
  • script.pas

Remove from project and folders on disk:

  • All files in the Forms folder, except Forms.pas and Main.pas
  • Subfolders in the Tools folder, except DBG (debugger)

Correct the files by matching the uses section, lists of variables and constants, and removing unnecessary procedures and functions:

  • ConstVar.pas
  • UserApp.pas
  • Forms\Forms.pas
  • Forms\Main.pas
  • Tools\Tools.pas
In fact, cleaning up the code turned out to be a painstaking and long task, and all because the compiler in module mode in some cases cannot accurately show the place where the error is located. This is one of the main disadvantages of using modules, which can be maddening. Therefore, I will rewrite modules until a simple, clear and concise sequence of actions has been developed that allows you to transfer scripts from one project to another.

After updating the project name and version information, I replaced the logo files with more appropriate ones. As a result, the stub program is ready for increasing functionality.

Main form and “About” form with AquaLightSlate style

To be continued…

Leave a Reply

Your email address will not be published. Required fields are marked *