OK, let’s talk business now. One of the main purposes of the app is to register the business transactions. This is what we use the Documents for. We are already registering the sales we make, but to sell something you need to buy it in the first place, right. So, let’s register our buying transactions with a new document called Purchases. As any other document it already has Reference, Number, Date and other standard attributes, so it’s all good here.
But we also need a list of products we bought, and this is where we use a Tabular Section - additional table sitting inside of a single document.
So, I’m gonna create a new tabular section and call it Products.
Now, what attributes do I need in here? That would be the Product (that refers to the Products catalog), the Quantity (number of products purchased) and the Price.
Now, consider this. I’m going to buy and sell the same products over and over again. And at any given moment I have to be able to answer the question: how many products I have left by now?
This information is not that easily obtainable from the documents. I need to scan all Purchases documents and sum up the quantities of all Products I find. Then I need to scan all the Sales documents and subtract the amount of the Products I sold. Imagine, that I work for years and have thousands of Sales and Purchases documents. How much time this calculation will take?
This is where the accumulation registers come to the rescue. The idea is that we register the transactions in documents, and, at the same time, post them to the register, that sums up the numbers as we go.
We already have the Inventory register that does the job for the Sales documents, and this is how it works. The register’s resources are the fields that will be summed up. We want to trace the Product’s quantities, so we created the Quantity resource here. We also need to tell the register how the sums should be sliced. This is done by defining the Dimensions. We want the single sum for each Product, so we created the single Dimension here. The process of writing the documents records to the register is called posting. To tell the Sales document to post data to the register, we ticked this checkbox and set up the posting procedure. First, we told the procedure, what we are doing here: adding some more products (buying them) or subtracting some products (selling them). Then we mapped the document fields onto the register fields.
Now, let’s do the same for the Purchases documents.
Let’s go to the Posting tab and say the document that it should post the data into the Inventory register.
Now, I’m running the wizard and telling it that we are adding some Products to the Inventory rather than selling them out, that we are posting the records from this tabular section, and that the Platform should try and map these fields onto the registers fields basing on the data types.
Let’s click OK here, and the Platform generates the procedure doing the posting for us. We don’t know much about the source code yet, so we’re gonna just trust the Platform on this for now.
OK, let’s run the app and see where we are Pringles-wise, shall we?
Looks like we are deep in the red zone here. Now, let’s post our Purchase document and check how the balance has changed. OK, this now looks correct, doesn’t it?