Stored Procedures [dbo].[UpdateCustomerCreditInfo]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@inCustomerNumbervarchar(15)15
@inCreditLimitmoney8
@inAccountingCustomerCreditLimitTypeIdint4
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
/**
*    Updates the customer credit limit info for a specific customer number.  This is used by the
*    AR Credit and Collections module.  This won't get called by XLedger systems as we don't push
*    acxcounting customer updates INTO XLedger.  Thus, we only update non-XLedger systems.
*/

create procedure [dbo].[UpdateCustomerCreditInfo]
    @inCustomerNumber varchar(15),
    @inCreditLimit money,
    @inAccountingCustomerCreditLimitTypeId int
as
begin
    set nocount on

    declare @theAccountingSystemType varchar(2) = dbo.GetAccountingSystemType()

    -- XLedger needs to be updated via XLedger system, which then passes the changes down to
    -- MoversSuite via web-hooks.  We don't push customer updates INTO XLedger.  This SP will
    -- not be invoked if XLedger is the accounting system.
    if( @theAccountingSystemType != 'XL' )
    begin
        update RM00101 set
            CRLMTAMT = isnull( @inCreditLimit, 0.0 ),
            CRLMTTYP = isnull( AccountingCustomerCreditLimitType.GPCreditLimitTypeCode,
                NoCreditCreditLimitType.GPCreditLimitTypeCode )
        from RM00101_Synonym as RM00101
        left outer join AccountingCustomerCreditLimitType on AccountingCustomerCreditLimitType.AccountingCustomerCreditLimitTypeId = @inAccountingCustomerCreditLimitTypeId
        left outer join AccountingCustomerCreditLimitType as NoCreditCreditLimitType on NoCreditCreditLimitType.TypeName = 'No Credit'
        where RM00101.CUSTNMBR = @inCustomerNumber

        -- Update GPWarehouse customer info as well.
        update GPCustomer set
            CreditLimit = isnull( @inCreditLimit, 0.0 ),
            CreditLimitType = isnull( AccountingCustomerCreditLimitType.GPCreditLimitTypeCode,
                NoCreditCreditLimitType.GPCreditLimitTypeCode ),
            AccountingCustomerCreditLimitTypeFid = isnull( AccountingCustomerCreditLimitType.AccountingCustomerCreditLimitTypeId,
                NoCreditCreditLimitType.AccountingCustomerCreditLimitTypeId )
        from GPCustomer
        left outer join AccountingCustomerCreditLimitType on AccountingCustomerCreditLimitType.AccountingCustomerCreditLimitTypeId = @inAccountingCustomerCreditLimitTypeId
        left outer join AccountingCustomerCreditLimitType as NoCreditCreditLimitType on NoCreditCreditLimitType.TypeName = 'No Credit'
        where GPCustomer.CustomerNumber = @inCustomerNumber
    end
end
GO
GRANT EXECUTE ON  [dbo].[UpdateCustomerCreditInfo] TO [MssExec]
GO
Uses