Table of Contents

Specific procedures of cost corrections

Apart from the standard method of cost correction - loading the store transaction for a specified period (plus the opening balances) and filling in the rows for the correction by the basic algorithm for cost correction calculation, there are two more ways to create a cost correction document. They use generation procedures available in the transaction document.

Cost correction generation procedure for the actual cost of the current transaction

This generation procedure updates the cost of the store transactions in the current transaction document.

For each row, the following actions are applied:

  1. Loading the actual cost by the current moment (i.e. this is the sum of the original cost from the transaction row and the addition cost in the row, generated by already created cost corrections). This is a sum [current cost];

  2. Then, the actual cost for the row is calculated - the sum [actual cost] as usual:

    a. if the transaction is issuing, the cost is calculated by the average accumulated cost;

    b. if the record is a receipt transaction and is part of a transfer or production process, its cost is recalculated according to the algorithm from articles Calculating cost for produced products, Calculating cost for returned products and Calculating cost for transferred products;

    c. if the record is a receipt transaction and is not part of a transfer or production process, the original cost is considered the actual cost.

To make valid calculations, the cost of all store transactions affecting the current transactions should be recalculated correctly.

At the end, the difference [actual cost] - [current cost] is calculated. Provided that it is different than zero, a new row is added in the cost correction sub-document for the current transaction row, which contains the difference.

Cost correction generation procedure for the current transaction results

This generation procedure updates the costs of all transactions that depend on the current transaction rows.

The following actions are executed:

  1. Loading all store transactions (with the opening balances if needed) which depend on the current document;

  2. Тhe basic algorithm for cost correction calculation is applied over the loaded set of records;

  3. For each store transaction from the set of records, the difference between the algorithm result and the actual cost valid before the creation of the current transaction, is calculated. If it is a non-zero result, a new row in the cost correction is added.

Loading the records is performed iteratively. Before the first iteration, the following is created:

[current set of records] = the transactions in the current Transaction document;

[current Movement Type] = Movement Type of the current transaction;

[result] = [current set of records] + the opening balances for the current store of the current products from the transactions of the [current set of records] (the opening balances are for the Transaction timestamp date)

Then, a cycle of iterations is performed, and for each iteration, the following is executed:

  • if the [current Movement Type] = receipt, a new set of records is loaded;

[new set of records] = all transactions for the stores and the products (and the lots, if the product keeps separated cost for each lot) from the [current set of records] whоse Transaction Timestamp is greater than or equal to the Transaction Timestamp in the [current set of records].

  • If the[current Movement Type ]= issue and the [current set of records] has records that are part of a transfer/production process, then the [new set of records] is as follows:

[new set of records] = all receipt transactions from the specified transfer/production processes, whose transaction timestamps are greater than or equal to the transaction timestamps in the [current set of records].

  • The result is updated and the current set of records becomes:

[result] = [result] U [new set of records] (the opening balances are added for every new store which is part ot [new set of records] but is not part of [current set of records]);

[current set of records] = [new set of records].

  • At the end, if [current Movement Type ] = receipt, then [current Movement Type] is set to issue and if it was [current Movement Type] = issue,[current Movement Type] is set to receipt.

These iterations are performed until an iteration has a [new set of records] that is empty.