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,< /p>

APTODCDT,

ApplyToGLPostDate,

CURNCYID,

CURRNIDX,

APPTOAMT,

ORAPT OAM,

APFRDCNM,

APFRDCTY,

APFRDCDT,

ApplyFromGLPostDate,

FROMCURR,

< p>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; http://www.albaspectrum.com

Culver prom limo ..
In The News:

An artificial intelligence-powered home security system can fire paintballs and tear gas at trespassers. The camera identifies human faces and animals.
Technology expert Kim Komando gives her tips and tricks on enhancing your user experience a smartphone and other devices you use everyday.
A new camera called NUCA uses artificial intelligence to create deepfake photos of subjects by stripping away clothing in close to real time.
The Kimberley Kube trail-ready camper has a compact but spacious design and combines luxury, functionality and ruggedness for a weekend getaway.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
Emails instructing you to reset your password for an account may be legitimate, or they may be scams. Kurt "CyberGuy" Knutsson explains.
Northrop Grumman's Manta Ray uncrewed underwater vehicle aims to revolutionize undersea missions — it glides through the ocean without human assistance.
Learn how to work Google's calendar application to streamline and organize your daily tasks from technology expert Kim Komando.
If you do not want Facebook to have automatic access to your private photos, follow our tips to protect yourself. Kurt “CyberGuy" Knutsson shows you how.
Kurt “CyberGuy" Knutsson goes into detail about Apple’s recent iOS update that allows iPhone users to instantly translate spoken language simply by using the Action Button.
Safeguarding your digital life with a reliable physical backup isn't just a precaution, it's a necessity. Kurt “CyberGuy" Knutsson provides the essential backup checklist.
Kurt “CyberGuy" Knutsson reveals how a Redditor exposed false recycling claims at their apartment, highlighting a report that only 21% of U.S. recyclables are processed.
Kurt "CyberGuy" Knutsson offers a travel toolkit featuring five technology tools to help you with booking flights and hotels for your summer vacation.
The bubble behind the clock on your iPhone can appear in different colors. Kurt "CyberGuy" Knutsson explains what each of those colors mean.
Scammers are using the power of artificial intelligence to mimic voices of people and are using the fake voices to commit crimes, like kidnappings.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
Tech guru Kurt "CyberGuy" Knutsson explains the science behind the Invisibility Shield, a 6-foot shield that makes people become invisible.
The International Olympic Committee on Friday announced plans to use AI in various Olympic aspects, including athlete identification, training and judging.
Tech guru Kurt "CyberGuy" Knutsson explains an easy trick to avoid squinting while working or surfing the web by zooming in on your personal computer.
Streaming giant Roku has recently been targeted by a pair of cyberattacks, and the company confirmed over a half million Roku accounts were compromised.
The Land Aircraft Carrier combines an all-terrain, six-wheeled vehicle with a two-seat aircraft, which features electric vertical takeoff and landing.
The European Union has sent TikTok a "request for information" on the video sharing platform's newest app, TikTok Lite, under the Digital Services Act, with the aim to clean up social media.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
The FBI is warning the public about a recent phishing scam via text that claims its targets owe money in Pennsylvania for unpaid road toll charges.
Your Apple Music settings may be revealing to your contacts what you're listening to. Kurt "CyberGuy" Knutsson explains the process to change those settings.

.NET :Solving the Multiple Inheritance Issue Under .NET Platform

.NET platform does not support multiple inheritance. Do not confuse... Read More

Microsoft CRM ? Consulting in the Post-Recession Time

New post-recession era has new features, which didn't exist in... Read More

Why Java RDBMS?

It is a well known fact that Java as a... Read More

How to Upgrade Dexterity Customization ? Tips for IT Manager

If you have Microsoft Great Plains and support it... Read More

Groove Network. Are you in it?

If you are in a business that passes documents around... Read More

Microsoft and Webmasters

Does Microsoft care for WebmastersIt's always been a problem with... Read More

Device Driver Basics

Most people understand that the "hardware" part of their computer... Read More

Microsoft CRM for Corporate Business ? Working Offline

If your company has regional and worldwide operations, you might... Read More

Ukraine IT Myths Dispersed

While Ukraine is becoming a new popular IT outsourcing destination,... Read More

Microsoft Great Plains Chemicals & Paint Industry Implementation & Customization Notes

Microsoft Great Plains fits to majority of industries, in the... Read More

Know-how in Microsoft Publisher

For those who still don't know, Microsoft Publisher helps computer... Read More

New SQL Delta Version 3.1

COMMAND LINE FUNCTIONA powerful command line script processor has been... Read More

Reporting for Microsoft Great Plains/Dynamics/eEnterprise: RW ? ReportWriter ? Tips for Developer

Microsoft Business Solutions Great Plains is written in Great Plains... Read More

Assertion in Java

Assertion facility is added in J2SE 1.4. In order to... Read More

Separate Anti-Keylogging Protection: Who Needs it Most?

If there still are few unprotected computers left, I haven't... Read More

Adware and Spyware Blockers

The most important things you can do for your computer... Read More

SQL: Querying Microsoft Great Plains ? Overview for Database Administrator/Developer

Looks like Microsoft Great Plains becomes more... Read More

Run Your Own Search Engine

Our hosted solution allow you to run your own search... Read More

Change Your Word Docs in Record Time!

Anyone who has ever used Microsoft Word knows that it... Read More

Why do Manufacturers Invest in Business Management Software?

With many manufacturing shops heading over seas in favor of... Read More

Data Quality Best Practices for Salesforce.com

Executive SummaryAn effective plan for entering, cleaning and updating the... Read More

How To Develop Software For Your Business

Software development is a risky business.Many software developers are barely... Read More

eStore Advantage ? Extending Microsoft eConnect for MBS Great Plains

eStore Advantage allows front-office applications to communicate with back-office business... Read More

Spyware Protection: A Must for Any Home Computer

Now that spyware is the single most dangerous threat to... Read More

Programming Environments And The Software Production Process

Introduction: The creating of a computer program involves a number... Read More

Wood Dale limo ..