Software Information

Great Plains Customization - Programming Auto-apply in Accounts Receivable


Microsoft Great Plains is one of three Microsoft Business Solutions mid-market ERP products: Great Plains, Solomon, Navision. Considering that Great Plains is now very good candidate for integration with POS application, such as Microsoft Retail Management System or RMS and Client Relation Systems, such as Microsoft CRM - there is common need in Great Plains customizations and integrations, especially on the level of MS SQL Server transact SQL queries and stored procedures.

In this small article we'll show you how to create auto-apply utility, when you integrate huge number of sales transactions and payments. We will be working with RM20101 - Receivables Open File and RM20201 - Receivables Apply Open File.

Let's see SQL code:

declare @curpmtamt numeric(19,5)

declare @curinvamt numeric(19,5)

declare @curpmtnum varchar(20)

declare @curinvnum varchar(20)

declare @curinvtype int

declare @curpmttype int

declare @maxid int

declare @counter int

-- Create a temporary table

create table #temp

(

[ID] int identity(1,1) primary key,

CUSTNMBR varchar(15),

INVNUM varchar(20),

INVTYPE int,

PMTNUM varchar(20),

PMTTYPE int,

INVAMT numeric(19,5),

PMTAMT numeric(19,5),

AMTAPPLIED numeric(19,5)

)

create index IDX_INVNUM on #temp (INVNUM)

create index IDX_PMTNUM on #temp (PMTNUM)

-- Insert unapplied invoices and payments

insert into #temp

(

CUSTNMBR,

INVNUM,

INVTYPE,

PMTNUM,

PMTTYPE,

INVAMT,

PMTAMT,

AMTAPPLIED

)

select

CUSTNMBR = a.CUSTNMBR,

INVNUM = b.DOCNUMBR,

INVTYPE = b.RMDTYPAL,

PMTNUM = a.DOCNUMBR,

PMTTYPE = a.RMDTYPAL,

INVAMT = b.CURTRXAM,

PMTAMT = a.CURTRXAM,

AMTAPPLIED = 0

from RM20101 a

join RM20101 b on (a.CUSTNMBR = b.CUSTNMBR)

join RM00101 c on (a.CUSTNMBR = c.CUSTNMBR)

where

a.RMDTYPAL in (7, 8, 9) and

b.RMDTYPAL in (1, 3) and

a.CURTRXAM 0 and

b.CURTRXAM 0

order by

a.custnmbr,

b.DOCDATE,

a.DOCDATE,

a.DOCNUMBR,

b.DOCNUMBR

-- Iterate through each record

select @maxid = max([ID])

from #temp

select @counter = 1

while @counter = @curpmtamt) and (@curpmtamt>0) and (@curinvamt>0)-- if the invoice amount is greater or the same as the payment amount

begin

select @curinvamt = @curinvamt - @curpmtamt -- invoice amount remaining

-- update with the amount that is applied to the current invoice from

-- the current payment

update #temp

set

AMTAPPLIED = @curpmtamt

where

[ID] = @counter

-- update with amount of invoice remaining

update #temp

set

INVAMT = @curinvamt

where

INVNUM = @curinvnum and

INVTYPE = @curinvtype

-- update with amount of payment remaining

update #temp

set

PMTAMT = 0

where

PMTNUM = @curpmtnum and

PMTTYPE = @curpmttype

end

else if (@curinvamt 0) and (@curinvamt>0)-- if the invoice amount is lesser to the payment amount

begin

select @curpmtamt = @curpmtamt - @curinvamt -- payment amount remaining

-- update with the amount that is applied to the current invoice from

-- the current payment

update #temp

set

AMTAPPLIED = @curinvamt

where

[ID] = @counter

-- update with amount of invoice remaining

update #temp

set

INVAMT = 0

where

INVNUM = @curinvnum and

INVTYPE = @curinvtype

-- update with amount of payment remaining

update #temp

set

PMTAMT = @curpmtamt

where

PMTNUM = @curpmtnum and

PMTTYPE = @curpmttype

end

-- go to the next record

select @counter = @counter + 1

end

-- update the RM Open table with the correct amounts

update

RM20101

set

CURTRXAM = b.INVAMT

from

RM20101 a

join #temp b on (a.DOCNUMBR = b.INVNUM and a.RMDTYPAL = b.INVTYPE)

update

RM20101

set

CURTRXAM = b.PMTAMT

from

RM20101 a

join #temp b on (a.DOCNUMBR = b.PMTNUM and a.RMDTYPAL = b.PMTTYPE)

-- create the RM Apply record or update if records already exist

update

RM20201

set

DATE1 = convert(varchar(10), getdate(), 101),

GLPOSTDT = convert(varchar(10), getdate(), 101),

APPTOAMT = APPTOAMT + a.AMTAPPLIED,

ORAPTOAM = ORAPTOAM + a.AMTAPPLIED,

APFRMAPLYAMT = APFRMAPLYAMT + a.AMTAPPLIED,

ActualApplyToAmount = APFRMAPLYAMT + a.AMTAPPLIED

from

#temp a

join RM20101 b on (b.DOCNUMBR = a.INVNUM and b.RMDTYPAL = a.INVTYPE)

join RM20101 c on (c.DOCNUMBR = a.PMTNUM and c.RMDTYPAL = a.PMTTYPE)

join RM20201 d on (d.APFRDCTY = a.PMTTYPE and

d.APFRDCNM = a.PMTNUM and

d.APTODCTY = a.INVTYPE and

d.APTODCNM = a.INVNUM)

where

a.AMTAPPLIED 0

insert into RM20201

(CUSTNMBR,

DATE1,

GLPOSTDT,

POSTED,

APTODCNM,

APTODCTY,

APTODCDT,

ApplyToGLPostDate,

CURNCYID,

CURRNIDX,

APPTOAMT,

ORAPTOAM,

APFRDCNM,

APFRDCTY,

APFRDCDT,

ApplyFromGLPostDate,

FROMCURR,

APFRMAPLYAMT,

ActualApplyToAmount)

select

CUSTNMBR = a.CUSTNMBR,

DATE1 = convert(varchar(10), getdate(), 101),

GLPOSTDT = convert(varchar(10), getdate(), 101),

POSTED = 1,

APTODCNM = a.INVNUM,

APTODCTY = a.INVTYPE,

APTODCDT = b.DOCDATE,

ApplyToGLPostDate = b.GLPOSTDT,

CURNCYID = b.CURNCYID,

CURRNIDX = '',

APPTOAMT = a.AMTAPPLIED,

ORAPTOAM = a.AMTAPPLIED,

APFRDCNM = a.PMTNUM,

APFRDCTY = a.PMTTYPE,

APFRDCDT = c.DOCDATE,

ApplyFromGLPostDate = c.GLPOSTDT,

FROMCURR = c.CURNCYID,

APFRMAPLYAMT = a.AMTAPPLIED,

ActualApplyToAmount = a.AMTAPPLIED

from

#temp a

join RM20101 b on (b.DOCNUMBR = a.INVNUM and b.RMDTYPAL = a.INVTYPE)

join RM20101 c on (c.DOCNUMBR = a.PMTNUM and c.RMDTYPAL = a.PMTTYPE)

where

a.AMTAPPLIED 0 and

not exists (select 1

from RM20201 d

where d.APFRDCTY = a.PMTTYPE and

d.APFRDCNM = a.PMTNUM and

d.APTODCTY = a.INVTYPE and

d.APTODCNM = a.INVNUM)

drop table #temp

About The Author

Andrew Karasev is Chief Technology Officer in Alba Spectrum Technologies - USA nationwide Great Plains, Microsoft CRM customization company, with offices in Chicago, San Francisco, Los Angeles, San Diego, Phoenix, Houston, Miami, Atlanta, New York, Madrid, Brazil, Moscow ( http://www.albaspectrum.com), you can reach Andrew 1-866-528-0577, he is Dexterity, SQL, C#.Net, Crystal Reports and Microsoft CRM SDK developer; akarasev@albaspectrum.com


MORE RESOURCES:

Fortune

Oracle Broadens Reach in Web-Based Software
Wall Street Journal
By BEN WORTHEN Oracle Corp. agreed to acquire online-software maker Taleo Corp. for $1.9 billion, its second such acquisition in recent months and the latest sign that the software industry's old guard is embracing a newer model.
Oracle Will Purchase Taleo for $46 a Share in Deal Valued at $1.9 BillionBloomberg
Oracle Embraces the Cloud With $1.9 Billion Taleo DealNew York Times
Oracle paying $1.9 billion for Taleo's HR softwareSan Francisco Chronicle
Forbes -San Jose Mercury News
all 451 news articles »


Tableau Software Positioned as "Challenger" in Leading Analyst Firm Magic ...
San Francisco Chronicle (press release)
Tableau® Software, the global leader in rapid-fire business intelligence software, today announced that Gartner, Inc. has positioned Tableau as a "Challenger" in its 2012 Magic Quadrant for Business Intelligence Platforms* report.

and more »


Software maker Nuance shares plunge on 1Q miss
CBS News
Software maker Nuance Communications Inc. reported late Thursday that its first-quarter net income rose as revenue climbed for its health care, mobile and imaging applications, but its adjusted earnings and revenue fell short of analysts' expectations ...
Nuance Blunt In Earnings MissInvestor's Business Daily

all 31 news articles »


ND software <3794.OS>-2011/12 div forecast
Reuters
Feb 10 (Reuters) - ND SOFTWARE CO LTD PARENT-ONLY EARNINGS ESTIMATES (in billions of yen unless specified) Full year to Full year to March 31,2012 March 31,2012 LATEST PREVIOUS FORECAST FORECAST Annual div 45.00 yen 30.00 yen -Q2 div nil nil NOTE - ND ...

and more »


GrayHair Software releases a dynamic reporting engine to complement its cloud ...
MarketWatch (press release)
MOUNT LAUREL, NJ, Feb 09, 2012 (BUSINESS WIRE) -- GrayHair Software, Inc., a leader in solutions for business mailers, announces the release of a ground-breaking reporting engine that expands the versatility and depth of the services offered in its ...

and more »


Home Media Magazine

Video-Game Retail Sales in US Slid 34% in January, NPD Reports
BusinessWeek
9 (Bloomberg) -- US retail sales of video-game hardware, software and accessories tumbled 34 percent in January to $750.6 million from a year earlier, researcher NPD Group Inc. said today in an e-mailed statement. Sales a year ago were $1.14 billion, ...
Videogame Sales Plunge 34 Percent in JanuaryPC Magazine
US video game sales fall 34 percent in January due to lack of new titlesWashington Post

all 111 news articles »


Software Developers Get SaaS-y with Expanded Software-as-a-Service Platform
EON: Enhanced Online News (press release)
The software distribution platform allows software publishers to put their applications immediately in the cloud as a Software-as-a-Service (SaaS) offering with no development or rewrite effort. “Porting and conversion costs have been eliminated, ...

and more »


Callidus Software Increases Sales but Misses Estimates on Earnings
DailyFinance
By Seth Jayson, The Motley Fool Posted 11:19AM 02/09/12 Investing Callidus Software (NAS: CALD) reported earnings on Feb. 8. Here are the numbers you need to know. For the quarter ended Dec. 31 (Q4), Callidus Software beat slightly on revenues and ...
Callidus Software to Participate in Upcoming Investor ConferencesMarketWatch (press release)
Callidus Software Slips To Wider Q4 LossNASDAQ
Callidus Software Announces Fourth Quarter and Full Year 2011 ResultsMarketwire (press release)

all 27 news articles »


Raytheon Releases Software Upgrade for Airborne Communication System
MarketWatch (press release)
The enhancement is provided by an upgrade to Integrated Waveform (IW) software, following successful field tests hosted by the Defense Information Systems Agency (DISA). Prior to the software upgrade, this form of radio communications had limited ...

and more »


Quest Software Earnings Preview
DailyFinance
By Motley Fool Staff Posted 1:34PM 02/09/12 Investing Quest Software (NAS: QSFT) hasn't been able to establish an earnings trend, bouncing between beating and falling short of estimates during the past fiscal year. The company will unveil its latest ...

and more »

Google News

Home | Site Map

Powered By: Free Work At Home Business Opportunity!

© 2006