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

Brookfield car service from Midway ..
In The News:

A ported phone number scam is leading to more people having their identities stolen by sophisticated scammers. Kurt “CyberGuy" Knutsson tells you what you need to know.
The Great Pacific Garbage Patch, a vast marine debris vortex, is being tackled by The Ocean Cleanup’s innovative technologies. Kurt “CyberGuy" Knutsson explains.
Discover easy solutions to tame autocorrect frustration on iOS and Android devices. Turn off, customize and add personal touches to your typing experience.
Kurt “CyberGuy" Knutsson reveals the six top things to do right now before it’s too late: Tech and life choices that can keep your safer on and offline.
Kurt “CyberGuy" Knutsson shows you some simple steps to discreetly hide apps or an entire app page on your iPhone for decluttering or confidentiality.
The ambient light sensors on smartphones may be turned into cameras, according to researches at MIT. This could pose a threat to people's privacy.
The Autonomous Road Repair System from tech firm Robotiz3d uses artificial intelligence technology to locate potholes and promptly seal them.
Scammers have stooped to using artificial intelligence to scan obituary websites to create fake obituary websites to target the grieving.
Stay up to date on the latest AI technology advancements and learn about the challenges and opportunities AI presents now and for the future.
A Mercedes-Benz Manufacturing factory in Hungary is using humanoid robots to help with human staffing shortages on the factory floor.
Some video games act like unregulated banks, according to CFPB, which has begun monitoring the situation. The agency says children may be most at risk.
Ascender the robot is capable of climbing stairs with heights up to 8.7 inches, and it can give every corner of your home a deep cleaning.
Tax-return scams are on the rise, and one tax expert from a cybersecurity firm says filing your taxes on time is one way to avoid tax scams.
The innovative XPENG Robot Unicorn is inspired by the mythical unicorn, and you may forget the robot is not actually a living creature.
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 Federal Trade Commission, the federal agency to report scams to, is being impersonated as part of a new sophisticated phone scam.
Eatrenalin is a restaurant in Germany with a Floating Chair innovation that makes the 17,000-square-foot venue feel like an amusement park.
U.S. Air Force Secretary Frank Kendall met with the Senate Appropriations Committee on Tuesday and said he plans to ride in an autonomously-operated aircraft this Spring.
Kurt “CyberGuy" Knutsson reveals advice from a reader who files debit card fraud claims all day. Here are eight do's and don'ts to prevent debit card fraud.
Kurt “CyberGuy" Knutsson shows you how to update your password, PIN or pattern on your Android to keep your device safe and secure from hackers.
Tech expert Kim Komando explains how to use Google Maps tricks like looking at your childhood home, planning trip times, and virtually visiting buildings and shipwrecks
Kurt “CyberGuy" Knutsson reveals how hackers have unleased a new, more powerful version of the Vultur banking Trojan that's capable of taking full control of your Android device.
Take your online tasks offline: Kurt “CyberGuy" Knutsson shows you how to print your Reminders app lists on your iPhone to take wherever you go.
Two types of malware are designed to trick Mac users and steal data. So, it's important to make sure your private data is locked down.
Eve is a new artificial intelligence-powered humanoid robot from 1X that can help with household chores, including folding the laundry.

Navision Attain Database access via C/ODBC in ASP.NET Application

Navision Software was purchased by Microsoft and now it is... Read More

Do You Know These Facts About Spyware ?

Imagine something that follows you home and sets itself up... Read More

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

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

Ukraine IT Myths Dispersed

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

Guide to Software Marketing

Intro This concise article will tell you in plain English... Read More

Five Reasons for Using an O/R Mapping Tool

So, why should you use any O/R mapping tool? I... Read More

Fundraising Software ? How Can That Help Me?

Fundraising software lets you connect with donors in a way... Read More

What to Do if All Screensavers Fun is Grayed Out?

Finally, you have some time to personalize your desktop with... Read More

SQL Administrator Skills Required to Support Microsoft Great Plains

Microsoft Great Plains is becoming more and more popular and... Read More

Corporate Accounting System: Microsoft Great Plains ? Overview

Corporate ERP/MRP selection might be tough one, especially considering very... Read More

Looking for an Alternative to Microsoft Office? You Should Be!

Now is the time to look at an alternative to... Read More

Microsoft Business Solutions VAR/Partner Selection ? Overview for IT Director/Manager/Controller

Microsoft Great Plains and Microsoft CRM become more and more... Read More

Microsoft CRM Data Import FAQ

Microsoft CRM has built-in conversion tool, however you should probably... Read More

Cisco Certification: Five Things To Do DURING Your CCNA Exam

There are plenty of articles out there about how to... Read More

QuarkXpress Tips: How to Move Content Between Print and Web Layouts

Since its release in 1987, QuarkXpress had made an immediate... Read More

MultiNational Corporation ERP Implementation ? Microsoft Business Solutions Great Plains

If you look back to the history, you will see... Read More

Microsoft CRM Lotus Notes Domino Connector FAQ

Microsoft Business Solutions CRM and IBM Lotus Notes Domino, being... Read More

Microsoft Great Plains Furniture & Fixtures ? Implementation & Customization Highlights

Microsoft Great Plains, former Great Plains Software Dynamics / eEnterprise... Read More

Oracle Development: JDeveloper 10G ? Java, J2EE, EJB, MVC, XML - Overview For Programmer

In 2004 Oracle, Inc. made its new step toward J2EE... Read More

Microsoft Great Plains: exchange & brokerage ? implementation notes

If you company is small or mid-size special products or... Read More

Microsoft Great Plains ? Licensing & Product Versions

Current Microsoft Business Solutions Great Plains has more that 10... Read More

Microsoft CRM Integration & Customization: SharePoint Document Gateway

MS CRM is very close to document workflow automation, including... Read More

Recovering Microsoft Great Plains Customization ? Tips for IT Director

Remember nice and prosperous Clinton era? When you implemented innovative... Read More

Getting Patched with Windows Service Pack

Are you one of those people that keeps track of... Read More

Protect Your Most Vital Business Asset with Security Software

Homeland security, airport security, Internet security ??" these days we???re... Read More

taxi from Midway Andalusia ..