USP_DATAFORMTEMPLATE_EDITLOAD_BANKACCOUNTTRANSACTIONGLDISTRIBUTION

The load procedure used by the edit dataform template "Bank Account Transaction GL Distribution Edit Data Form"

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter used to load the fields defined on the form.
@DATALOADED bit INOUT Output parameter indicating whether or not data was actually loaded.
@TSLONG bigint INOUT Output parameter indicating the TSLONG value of the record being edited. This is used to manage multi-user concurrency issues when multiple users access the same record.
@AMOUNT money INOUT Transaction amount
@GLDISTRIBUTION xml INOUT Bank account deposit correction GL distribution
@PDACCOUNTSYSTEMID uniqueidentifier INOUT Account System
@TRANSACTIONCURRENCYID uniqueidentifier INOUT Transaction currency ID

Definition

Copy

CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDITLOAD_BANKACCOUNTTRANSACTIONGLDISTRIBUTION(
  @ID uniqueidentifier,
  @DATALOADED bit = 0 output,
  @TSLONG bigint = 0 output,
  @AMOUNT money = null output,
  @GLDISTRIBUTION xml = null output,
  @PDACCOUNTSYSTEMID uniqueidentifier = null output
  ,@TRANSACTIONCURRENCYID uniqueidentifier = null output
)
as
begin
    set nocount on;

    -- be sure to set these, in case the select returns no rows
    set @DATALOADED = 0
    set @TSLONG = 0

    select @ID = CASE WHEN A.ID is null or A.ISORIGINALADJUSTMENT = 1 THEN BAT.ID ELSE A.TRANSFERADJUSTMENTID END
    from dbo.BANKACCOUNTTRANSACTION BAT
    left outer join dbo.BANKACCOUNTADJUSTMENT A on BAT.ID = A.ID
    where BAT.ID = @ID

  set @GLDISTRIBUTION = (
    select
      GLDISTRIBUTION.ID, 
      GLDISTRIBUTION.TRANSACTIONTYPECODE, 
      GLDISTRIBUTION.ACCOUNT,
      GLDISTRIBUTION.GLACCOUNTID,
      GLDISTRIBUTION.PROJECT,
      GLDISTRIBUTION.TRANSACTIONAMOUNT AMOUNT, 
      GLDISTRIBUTION.REFERENCE, 
      GLDISTRIBUTION.TRANSACTIONCURRENCYID,
      GLDISTRIBUTION.GLTRANSACTIONID
    from dbo.UFN_BANKACCOUNTTRANSACTION_GETGLDISTRIBUTION(@ID) GLDISTRIBUTION
        inner join dbo.GLTRANSACTION on GLDISTRIBUTION.GLTRANSACTIONID = GLTRANSACTION.ID
        where SYSTEMDISTRIBUTION = 0
    for xml raw('ITEM'),type,elements,root('GLDISTRIBUTION'),BINARY BASE64
  );

  select @DATALOADED = 1
    ,@AMOUNT = T.TRANSACTIONAMOUNT 
    ,@PDACCOUNTSYSTEMID = BA.PDACCOUNTSYSTEMID
    ,@TRANSACTIONCURRENCYID = BA.TRANSACTIONCURRENCYID
  from dbo.BANKACCOUNTTRANSACTION T
  inner join dbo.BANKACCOUNT BA on BA.ID = T.BANKACCOUNTID
  where T.ID = @ID

  if @DATALOADED = 1
    select @TSLONG = max(tslong) from dbo.BANKACCOUNTTRANSACTIONGLDISTRIBUTION where BANKACCOUNTTRANSACTIONID = @ID

    return 0;
end