Sage 200 - SQL Script if accrual posting amount differs
Description
Cause
Resolution

This total can differ from the actual posting made and the reason for this is due to the amount being a summary from the overall order and not an exact figure for each item line. This is to improve performance on systems where there are a lot of orders with a lot of item lines.

When the posting is actually made each item line is then checked for part deliveries and for lines where there have already been invoices entered which do not cover the entire amount delivered.

The resulting posting is always correct and for extra information a script has been prepared to show a breakdown of the items making up this amount.

NOTE: The below scripts do not make any changes to the data.

Copy and Paste the relevant script based on what you want to see.

Script 1

----Shows all lines which will be included in the Accrual posting----

select POPOrderReturnLineID,POPORDERRETURN.DocumentTypeID, POPOrderReturnLine.POPOrderReturnID,
[POPOrderReturn].[ExchangeRate],LineTotalValue, LineTaxValue,
UnitBuyingPrice, LineQuantity,ReceiptReturnQuantity, InvoiceCreditQuantity, StockUnitLineQuantity,
StockUnitOnOrderQuantity, StockUnitRcptRtnQuantity, StockUnitInvCredQuantity
from poporderreturnline INNER JOIN POPOrderReturn ON POPOrderReturn.POPOrderReturnID =
POPOrderReturnLine.POPOrderReturnID where POPOrderReturnLine.poporderreturnid in
(select poporderreturnid from POPOrderReturn where DocumentStatusID = 0) and StockItemTypeID = 0
AND LineTotalValue != '0.00' AND ReceiptReturnQuantity <> InvoiceCreditQuantity
Script 2

---- Shows calculation for Unit Price in base currency per line, the quantity to invoice and StockUnitOnOrderQuantity, the Line Accrual values----

select POPOrderReturnLine.POPOrderReturnLineID, POPOrderReturnLine.POPOrderReturnID,
POPOrderReturn.ExchangeRate, POPOrderReturnLine.UnitBuyingPrice,
ReceiptReturnQuantity, InvoiceCreditQuantity,
SUM ( ( POPOrderReturnLine.UnitBuyingPrice / POPOrderReturn.ExchangeRate ) )AS UnitPriceBase,
SUM ( ( POPOrderReturnLine.ReceiptReturnQuantity - POPOrderReturnLine.InvoiceCreditQuantity ) )
AS QtyToInvoice,
SUM (( ( POPOrderReturnLine.UnitBuyingPrice / POPOrderReturn.ExchangeRate ) ) *
( ( POPOrderReturnLine.ReceiptReturnQuantity - POPOrderReturnLine.InvoiceCreditQuantity ) ))
AS LineAccrual from poporderreturnline INNER JOIN POPOrderReturn
ON POPOrderReturn.POPOrderReturnID = POPOrderReturnLine.POPOrderReturnID
where POPOrderReturnLine.poporderreturnid in
(select poporderreturnid from POPOrderReturn where DocumentStatusID = 0) and StockItemTypeID = 0
AND LineTotalValue != '0.00' AND ReceiptReturnQuantity <> InvoiceCreditQuantity
GROUP BY POPOrderReturnLine.POPOrderReturnLineID,
POPOrderReturnLine.POPOrderReturnID,POPOrderReturn.ExchangeRate,
POPOrderReturnLine.UnitBuyingPrice,ReceiptReturnQuantity, InvoiceCreditQuantity
Script 3

---- Shows the total of the Line Accruals. This total is for all lines shown in the previous query above----

select SUM (( ( POPOrderReturnLine.UnitBuyingPrice / POPOrderReturn.ExchangeRate ) )
* ( ( POPOrderReturnLine.ReceiptReturnQuantity - POPOrderReturnLine.InvoiceCreditQuantity ) ))
AS LineAccrual from poporderreturnline INNER JOIN POPOrderReturn
ON POPOrderReturn.POPOrderReturnID = POPOrderReturnLine.POPOrderReturnID
where POPOrderReturnLine.poporderreturnid in (select poporderreturnid from POPOrderReturn
where DocumentStatusID = 0) and StockItemTypeID = 0 AND LineTotalValue != '0.00'
AND ReceiptReturnQuantity <> InvoiceCreditQuantity
Steps to duplicate
Related Solutions