Wrong line quantities calculating/posting retail statements

There could be wrong quantity/cost from retail store transactions when you calculate/post retail statements:
Retail / Periodic / POS posting / Calculate statement
Retail / Periodic / POS posting / Post statement

The reason for that is wrong relation between RetailTransactionSalesTrans and RetailTransactionTable tables.
Correct relation between RetailTransactionSalesTrans and RetailTransactionTable is using 3 fields: transactionId, store, terminalId
For some reason in standard only transactionId is used. If it is not unique, and most probably it will be not unique across all stores and terminals there will be quantity and cost multiplications.

\Classes\RetailTransactionSalesTransMark\markTransactions inbuild method reserveAggregatedInventoryPriv:
        while select sum(Qty), inventTransId from transactionSalesTrans
            group by #RetailSalesLineAggregationGroup
            where
                transactionSalesTrans.TransactionStatus == RetailEntryStatus::None      &&
                transactionSalesTrans.transactionCode == RetailItemTransactionCode::ItemOnFile &&
                // <GEERU>
                (!param.ProcessGiftCardsAsPrepayments_RU || !transactionSalesTrans.SkipSalesLine_RU) &&
                // </GEERU>
                (
                    // <GEERU>
                    (countryRegion_W && !aggregated) ||
                    // </GEERU>
                    (_forSales && transactionSalesTrans.Qty <= 0) || (!_forSales && transactionSalesTrans.Qty > 0))
            join
                transactionTable
            where
                transactionTable.transactionId == transactionSalesTrans.transactionId
                // FIX by VK
                && transactionTable.store == transactionSalesTrans.store
                && transactionTable.terminal == transactionSalesTrans.terminalId
                // FIX by VK
                && transactionTable.type != RetailTransactionType::CustomerOrder
                && transactionTable.type != RetailTransactionType::AsyncCustomerOrder
            exists join
                tmpSalesTrans
            where
                transactionSalesTrans.RecId == tmpSalesTrans.RefRecId
                && !tmpSalesTrans.SkipAggregation


\Classes\RetailTransactionSalesTransMark\markTransactions inbuild method and ReserveNonAggregatedInventory:
        while select forupdate salesTrans
            where !salesTrans.inventTransId
                && salesTrans.transactionStatus == RetailEntryStatus::None
                // <GEERU>
                && (!param.ProcessGiftCardsAsPrepayments_RU || !salesTrans.SkipSalesLine_RU)
                // </GEERU>
            join transactionTable
                where salesTrans.transactionId == transactionTable.transactionId
                   // FIX by VK
                   && salesTrans.store == transactionTable.store
                   && salesTrans.terminalId == transactionTable.terminal
                   // FIX by VK
                   && transactionTable.type != RetailTransactionType::CustomerOrder
                   && transactionTable.type != RetailTransactionType::AsyncCustomerOrder
            join tmpSalesTrans
                where salesTrans.RecId == tmpSalesTrans.RefRecId
                   && (!_handleSkipAggregationTrans || tmpSalesTrans.SkipAggregation == _handleSkipAggregationTrans)


 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags