
[dbo].[UpdateCustomerCreditInfo]
create procedure [dbo].[UpdateCustomerCreditInfo]
@inCustomerNumber varchar(15),
@inCreditLimit money,
@inAccountingCustomerCreditLimitTypeId int
as
begin
set nocount on
declare @theAccountingSystemType varchar(2) = dbo.GetAccountingSystemType()
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 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