<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Victoria Yudin &#187; GP SQL view</title>
	<atom:link href="http://victoriayudin.com/tag/gp-sql-view/feed/" rel="self" type="application/rss+xml" />
	<link>http://victoriayudin.com</link>
	<description>Ramblings and musings of a Dynamics GP MVP</description>
	<lastBuildDate>Sat, 19 May 2012 09:34:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='victoriayudin.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/3cb782884f1419245af3e8375b2a1bff?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Victoria Yudin &#187; GP SQL view</title>
		<link>http://victoriayudin.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://victoriayudin.com/osd.xml" title="Victoria Yudin" />
	<atom:link rel='hub' href='http://victoriayudin.com/?pushpress=hub'/>
		<item>
		<title>SQL view for sales quantities by customer by item by year</title>
		<link>http://victoriayudin.com/2012/03/09/sql-view-for-sales-quantities-by-customer-by-item-by-year/</link>
		<comments>http://victoriayudin.com/2012/03/09/sql-view-for-sales-quantities-by-customer-by-item-by-year/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 14:02:12 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[SOP SQL code]]></category>
		<category><![CDATA[Inventory SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[SQL code]]></category>
		<category><![CDATA[Sales Order Processing]]></category>
		<category><![CDATA[Inventory]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=4096</guid>
		<description><![CDATA[Seems like no many how many variations of sales reports there are, people will always want more. I recently had a request for something similar to my view for sales quantities by item by year, but also adding in the customer.  Below is code for a view to accomplish this. This view makes a number of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=4096&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Seems like no many how many variations of sales reports there are, people will always want more. I recently had a request for something similar to my <a title="SQL view for sales quantities by item by year" href="http://victoriayudin.com/2012/01/23/sql-view-for-sales-quantities-by-item-by-year-2/">view for sales quantities by item by year</a>, but also adding in the customer.  Below is code for a view to accomplish this. This view makes a number of assumptions (listed in the view comments in green), and I am hard coding years from 2003 through 2012 as well as adding an overall total column at the end. You can easily change the years or add new ones by following the example in my code.</p>
<p style="text-align:justify;">You can find more code like this on my <a title="SOP SQL Views" href="http://victoriayudin.com/gp-reports/sop-sql-views/">SOP SQL Views</a> and <a title="Inventory SQL Views" href="http://victoriayudin.com/gp-reports/inventory-sql-views/">Inventory SQL Views</a> pages. For additional GP reporting information and links, check out my <a title="GP Reports" href="http://victoriayudin.com/gp-reports/">GP Reports</a> page.</p>
<p><pre class="brush: sql;">

CREATE VIEW view_Sales_Qty_by_Customer_Item_Year
AS

--***********************************************************************************
--view_Sales_Qty_by_Customer_Item_Year
--Created Mar 9, 2012 by Victoria Yudin - Flexible Solutions, Inc.
--For updates see http://victoriayudin.com/gp-reports/
--Returns total sales quantities fulfilled (invoices - returns) for each item
--     by customer by year
--Only posted invoices and returns are included
--Quantity is calculated by multiplying by QTYBSUOM column in case other UofM's are
--     used on transations
--Voided transations are excluded
--Invoice/Return dates are used, not GL posting dates 
--Item Description is taken from Inventory Item Maintenance for all inventory items
--     and from SOP line items for non-inventory items
--***********************************************************************************

SELECT
C.CUSTNMBR Customer_ID, C.CUSTNAME Customer_Name,
D.ITEMNMBR Item_Number, D.Item_Description,
sum(case when year(D.DOCDATE) = 2003 then D.Qty else 0 end) as [Qty_in_2003],
sum(case when year(D.DOCDATE) = 2004 then D.Qty else 0 end) as [Qty_in_2004],
sum(case when year(D.DOCDATE) = 2005 then D.Qty else 0 end) as [Qty_in_2005],
sum(case when year(D.DOCDATE) = 2006 then D.Qty else 0 end) as [Qty_in_2006],
sum(case when year(D.DOCDATE) = 2007 then D.Qty else 0 end) as [Qty_in_2007],
sum(case when year(D.DOCDATE) = 2008 then D.Qty else 0 end) as [Qty_in_2008],
sum(case when year(D.DOCDATE) = 2009 then D.Qty else 0 end) as [Qty_in_2009],
sum(case when year(D.DOCDATE) = 2010 then D.Qty else 0 end) as [Qty_in_2010],
sum(case when year(D.DOCDATE) = 2011 then D.Qty else 0 end) as [Qty_in_2011],
sum(case when year(D.DOCDATE) = 2012 then D.Qty else 0 end) as [Qty_in_2012],
sum(D.Qty) Total_Qty

FROM
(SELECT SH.DOCDATE, SH.CUSTNMBR, SD.ITEMNMBR,
 coalesce(I.ITEMDESC, SD.ITEMDESC) Item_Description,
 CASE SD.SOPTYPE
     WHEN 3 THEN SD.QTYFULFI*QTYBSUOM
     WHEN 4 THEN SD.QUANTITY*QTYBSUOM*-1
     END Qty
 FROM SOP30200 SH
 INNER JOIN
     SOP30300 SD
     ON SD.SOPNUMBE = SH.SOPNUMBE
     AND SD.SOPTYPE = SH.SOPTYPE
 LEFT OUTER JOIN
     IV00101 I
     ON I.ITEMNMBR = SD.ITEMNMBR
 WHERE SH.VOIDSTTS = 0
     AND SH.SOPTYPE IN (3,4)
     AND SD.ITEMNMBR not like 'XXXXXXXXXXXXXXX%') D

LEFT OUTER JOIN RM00101 C
  ON C.CUSTNMBR = D.CUSTNMBR

GROUP BY D.ITEMNMBR, D.Item_Description, C.CUSTNMBR, C.CUSTNAME

GO
GRANT SELECT ON view_Sales_Qty_by_Customer_Item_Year TO DYNGRP
</pre></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/inventory-sql-code/'>Inventory SQL code</a>, <a href='http://victoriayudin.com/category/gp-reports-code/sop-sql-code/'>SOP SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/inventory/'>Inventory</a>, <a href='http://victoriayudin.com/tag/sales-order-processing/'>Sales Order Processing</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/4096/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/4096/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/4096/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/4096/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/4096/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/4096/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/4096/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/4096/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/4096/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/4096/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/4096/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/4096/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/4096/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/4096/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=4096&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2012/03/09/sql-view-for-sales-quantities-by-customer-by-item-by-year/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2012/03/hand-truck.jpg?w=78" />
		<media:content url="http://victoriayudin.files.wordpress.com/2012/03/hand-truck.jpg?w=78" medium="image">
			<media:title type="html">hand truck</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for current Receivables aging in Dynamics GP</title>
		<link>http://victoriayudin.com/2012/01/25/sql-view-for-current-receivables-aging-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2012/01/25/sql-view-for-current-receivables-aging-in-dynamics-gp/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 09:33:00 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Receivables SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Receivables]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3979</guid>
		<description><![CDATA[I have created a variation on my view that shows all unapplied Receivables transactions to show customer aging in buckets. This is only looking at functional currency and will return data in summary, meaning one row per customer with a balance. I am hard-coding the aging using the default aging setup installed with GP, which is aging by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3979&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">I have created a variation on <a title="SQL view for all unapplied Receivables transactions in Dynamics GP" href="http://victoriayudin.com/2009/09/05/sql-view-for-all-unapplied-receivables-transactions-in-dynamics-gp/">my view that shows all unapplied Receivables transactions</a> to show customer aging in buckets. This is only looking at functional currency and will return data in summary, meaning one row per customer with a balance. I am hard-coding the aging using the default aging setup installed with GP, which is aging by due date and using the following buckets:</p>
<ul>
<li>
<div style="text-align:justify;">Current</div>
</li>
<li>
<div style="text-align:justify;">31 to 60 Days</div>
</li>
<li>
<div style="text-align:justify;">61 to 90 Days</div>
</li>
<li>
<div style="text-align:justify;">91 and Over</div>
</li>
</ul>
<p style="text-align:justify;">If you would like to use different aging buckets, just follow the examples in my code.</p>
<p style="text-align:justify;">You can find more Receivables code <a title="Receivables SQL Views" href="http://victoriayudin.com/gp-reports/receivables-sql-views/">here</a>, or links to additional reporting resources <a title="GP Reports" href="http://victoriayudin.com/gp-reports/">on my GP Reports page</a>.</p>
<p><pre class="brush: sql;">
create view view_Current_Receivables_Aging_Summary
as

-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-- view_Current_Receivables_Aging_Summary
-- Created Jan 25, 2012 by Victoria Yudin - Flexible Solutions, Inc.
-- For updates see http://victoriayudin.com/gp-reports/
-- Shows current AR aging with hard-coded aging buckets
-- Tables used:
--     CM - RM00101 - Customer Master
--     CS - RM00103 – Customer Master Summary
--     RM - RM20101 - Open Transactions
-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

SELECT
CM.CUSTNMBR Customer_ID, CM.CUSTNAME Customer_Name,
CM.PYMTRMID Customer_Terms, CM.CUSTCLAS Customer_Class,
CM.PRCLEVEL Price_Level,

sum(CASE
WHEN RM.RMDTYPAL &lt; 7 THEN RM.CURTRXAM
ELSE RM.CURTRXAM * -1
END) Total_Due,

sum(CASE
WHEN DATEDIFF(d, RM.DUEDATE, getdate()) &lt; 31 and RM.RMDTYPAL &lt; 7 THEN RM.CURTRXAM
WHEN DATEDIFF(d, RM.DUEDATE, getdate()) &lt; 31 and RM.RMDTYPAL &gt; 6 THEN RM.CURTRXAM *-1
ELSE 0
END) [Current],

sum(CASE
WHEN DATEDIFF(d, RM.DUEDATE, getdate()) between 31 and 60 and RM.RMDTYPAL &lt; 7 THEN RM.CURTRXAM
WHEN DATEDIFF(d, RM.DUEDATE, getdate()) between 31 and 60 and RM.RMDTYPAL &gt; 6 THEN RM.CURTRXAM * -1
ELSE 0
END) [31_to_60_Days],

sum(CASE
WHEN DATEDIFF(d, RM.DUEDATE, getdate()) between 61 and 90 and RM.RMDTYPAL &lt; 7 THEN RM.CURTRXAM
WHEN DATEDIFF(d, RM.DUEDATE, getdate()) between 61 and 90 and RM.RMDTYPAL &gt; 6 THEN RM.CURTRXAM * -1
ELSE 0
END) [61_to_90_Days],

sum(CASE
WHEN DATEDIFF(d, RM.DUEDATE, getdate()) &gt; 90 and RM.RMDTYPAL &lt; 7 THEN RM.CURTRXAM
WHEN DATEDIFF(d, RM.DUEDATE, getdate()) &gt; 90 and RM.RMDTYPAL &gt; 6 THEN RM.CURTRXAM *-1
ELSE 0
END) [91_and_Over],

CS.LASTPYDT Last_Payment_Date,
CS.LPYMTAMT Last_Payment_Amount

FROM RM20101 RM

INNER JOIN RM00101 CM
     ON RM.CUSTNMBR = CM.CUSTNMBR
INNER JOIN RM00103 CS
     ON RM.CUSTNMBR = CS.CUSTNMBR

WHERE RM.VOIDSTTS = 0 and RM.CURTRXAM &lt;&gt; 0

GROUP BY CM.CUSTNMBR, CM.CUSTNAME, CM.PYMTRMID, CM.CUSTCLAS, CM.PRCLEVEL, CS.LASTPYDT,
CS.LPYMTAMT

-- add permissions for DYNGRP
GO
GRANT SELECT ON view_Current_Receivables_Aging_Summary TO DYNGRP
</pre></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/receivables-sql-code/'>Receivables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/receivables/'>Receivables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3979/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3979/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3979/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3979&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2012/01/25/sql-view-for-current-receivables-aging-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2012/01/abacus.jpg?w=69" />
		<media:content url="http://victoriayudin.files.wordpress.com/2012/01/abacus.jpg?w=69" medium="image">
			<media:title type="html">abacus</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for customer yearly totals in Dynamics GP</title>
		<link>http://victoriayudin.com/2012/01/09/sql-view-for-customer-yearly-totals-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2012/01/09/sql-view-for-customer-yearly-totals-in-dynamics-gp/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 18:31:31 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Receivables SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[SQL code]]></category>
		<category><![CDATA[year end close]]></category>
		<category><![CDATA[Receivables]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3947</guid>
		<description><![CDATA[As a follow up to my SQL view for vendor yearly totals, here is something similar for customers. I have combined sales less credits/returns in one column, please take a look at the notes above the code (on lines 5 through 16 below) to see more details about the logic I am using. The code [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3947&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">As a follow up to my <a title="SQL view for vendor yearly totals in Dynamics GP" href="http://victoriayudin.com/2012/01/04/sql-view-for-vendor-yearly-totals-in-dynamics-gp/">SQL view for vendor yearly totals</a>, here is something similar for customers.</p>
<p style="text-align:justify;">I have combined sales less credits/returns in one column, please take a look at the notes above the code (on lines 5 through 16 below) to see more details about the logic I am using. The code below will give you 2007 through 2012 calendar years as well as &#8216;life-to-date&#8217; total sales. You can add or remove years as needed following my example.</p>
<p style="text-align:justify;">For more Dynamics GP Receivables code, take a look at my <a title="Receivables SQL Views" href="http://victoriayudin.com/gp-reports/receivables-sql-views/">Receivables SQL Views page</a>. Or check out my <a title="GP Reports" href="http://victoriayudin.com/gp-reports/">GP Reports page</a> for views in other modules and additional report writing and coding tips.</p>
<p><pre class="brush: sql;">
CREATE VIEW view_Customer_Totals_by_Year
AS

-- *********************************************************************
-- Created Jan 9, 2012 by Victoria Yudin - Flexible Solutions, Inc.
-- For updates please check http://victoriayudin.com/gp-reports/
-- Includes all posted receivables transactions in GP
-- Document dates and calendar years are used for groupings
-- Voided transactions are excluded
-- Sales amount adds Invoices, Debit Memos and Finance Charges
--      and subtracts Credit Memos and Returns
-- Amount includes subtotal plus misc amount less trade discount
-- Only fucntional currency is shown
-- Note that Returns are assumed as 'on account', if this is not
--      typically the case, Returns should be excluded
-- Total columns shows all years, not just what is shown in the columns
-- *********************************************************************

SELECT
T.CUSTNMBR [Customer ID], C.CUSTNAME [Customer Name], C.CUSTCLAS [Class ID],
sum(case when YEAR(T.DOCDATE) = 2012 then T.Amount else 0 end) [2012 Sales],
sum(case when YEAR(T.DOCDATE) = 2011 then T.Amount else 0 end) [2011 Sales],
sum(case when YEAR(T.DOCDATE) = 2010 then T.Amount else 0 end) [2010 Sales],
sum(case when YEAR(T.DOCDATE) = 2009 then T.Amount else 0 end) [2009 Sales],
sum(case when YEAR(T.DOCDATE) = 2008 then T.Amount else 0 end) [2008 Sales],
sum(case when YEAR(T.DOCDATE) = 2007 then T.Amount else 0 end) [2007 Sales],
sum(T.Amount) [Total Sales]

FROM -- all posted RM transactions, exclude voids
(SELECT  CUSTNMBR, DOCDATE, GLPOSTDT, DOCNUMBR,
 case when RMDTYPAL in (1,3,4) then (SLSAMNT + MISCAMNT - TRDISAMT)
	  when RMDTYPAL in (7,8) then -1*(SLSAMNT + MISCAMNT - TRDISAMT)
	  else 0 end Amount
 FROM RM20101
 WHERE VOIDSTTS = 0
UNION ALL
 SELECT  CUSTNMBR, DOCDATE, GLPOSTDT, DOCNUMBR,
 case when RMDTYPAL in (1,3,4) then (SLSAMNT + MISCAMNT - TRDISAMT)
	  when RMDTYPAL in (7,8) then -1*(SLSAMNT + MISCAMNT - TRDISAMT)
	  else 0 end Amount
 FROM RM30101
 WHERE VOIDSTTS = 0) T

LEFT OUTER JOIN RM00101 C  -- customer master
     ON T.CUSTNMBR = C.CUSTNMBR

GROUP BY T.CUSTNMBR, C.CUSTNAME, C.CUSTCLAS

GO
GRANT SELECT ON view_Customer_Totals_by_Year TO DYNGRP
</pre></p>
<p><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/receivables-sql-code/'>Receivables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/receivables/'>Receivables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a>, <a href='http://victoriayudin.com/tag/year-end-close/'>year end close</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3947/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3947/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3947/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3947/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3947/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3947/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3947/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3947/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3947/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3947/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3947/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3947/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3947/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3947/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3947&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2012/01/09/sql-view-for-customer-yearly-totals-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2012/01/calculator.jpg?w=96" />
		<media:content url="http://victoriayudin.files.wordpress.com/2012/01/calculator.jpg?w=96" medium="image">
			<media:title type="html">calculator</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for vendor yearly totals in Dynamics GP</title>
		<link>http://victoriayudin.com/2012/01/04/sql-view-for-vendor-yearly-totals-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2012/01/04/sql-view-for-vendor-yearly-totals-in-dynamics-gp/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 11:10:40 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Payables SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[SQL code]]></category>
		<category><![CDATA[year end close]]></category>
		<category><![CDATA[Payables]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3931</guid>
		<description><![CDATA[There has been a lot of talk lately about the year end close Payables and Receivables. I feel like I have spent the last week or two justifying my reasoning for not needing to perform the year end close for Payables and Receivables to many of my customers and blog readers. (For more on this, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3931&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">There has been a lot of talk lately about the year end close Payables and Receivables. I feel like I have spent the last week or two justifying my reasoning for not needing to perform the year end close for Payables and Receivables to many of my customers and blog readers. (For more on this, please see my <a title="Year end close in Dynamics GP" href="http://victoriayudin.com/2008/11/14/year-end-close-in-dynamics-gp/" target="_blank">Year end close in Dynamics GP blog post</a>.)</p>
<p style="text-align:justify;">My main reasoning has always been that the only thing accomplished by the year end close is updating the &#8216;amounts since last close&#8217; year-to-date and last-year totals and since that can be easily (and maybe even better?) accomplished by a custom report, why waste time on the year end close for these modules in GP? However, where is this custom report?</p>
<p style="text-align:justify;">For Payables &#8211; you now have 2 choices.  I previously published <a title="SQL view to show yearly totals for Dynamics GP Vendors" href="http://victoriayudin.com/2010/07/15/sql-view-to-show-yearly-totals-for-dynamics-gp-vendors/" target="_blank">this view</a> that results in one row per vendor per year with the columns being the different possible totals GP tracks for vendors. This is often useful for comparing year to year information for one vendor at a time.</p>
<p style="text-align:justify;">However, many people have asked to see this in columns representing years, so they can see all the vendor totals at the same time for all the years. That&#8217;s what you have below. I included separate columns for amounts billed and paid &#8211; please take a look at the notes (in green) for more details on the logic. The code below will give you 2007 through 2012 calendar years as well as &#8216;life-to-date&#8217; totals. You can add or remove years as needed following my example.</p>
<p style="text-align:justify;">I will be posting a similar view for Receivables in the next few days, so keep an eye out. For more Dynamics GP Payables code, take a look at my <a title="Payables SQL Views" href="http://victoriayudin.com/gp-reports/payables-sql-views/">Payables SQL Views page</a>. Or check out my <a title="GP Reports" href="http://victoriayudin.com/gp-reports/">GP Reports page</a> for views in other modules and additional report writing and coding tips.</p>
<p><pre class="brush: sql;">
CREATE VIEW view_Vendor_Totals_by_Year
AS

-- ****************************************************************
-- Created Jan 4, 2012 by Victoria Yudin - Flexible Solutions, Inc.
-- For updates please check http://victoriayudin.com/gp-reports/
-- Includes all posted payables transactions in GP
-- Document dates and calendar years are used for groupings
-- Voided transactions are excluded
-- Billed amount adds Invoices, Finance Charges and Misc Charges
--      and subtracts Credit Memos and Returns
-- Only fucntional currency is shown
-- Note that Returns are assumed as 'on account', if this is not
--      typically the case, Returns should be excluded
-- ****************************************************************

SELECT
P.VENDORID [Vendor ID],
V.VENDNAME [Vendor Name],
sum(case when year(P.DOCDATE) = 2012 and P.DOCTYPE &lt; 6
   then P.DOCAMNT else 0 end) [2012 Billed],
sum(case when year(P.DOCDATE) = 2012 and P.DOCTYPE = 6
   then P.DOCAMNT else 0 end) [2012 Paid],
sum(case when year(P.DOCDATE) = 2011 and P.DOCTYPE &lt; 6
   then P.DOCAMNT else 0 end) [2011 Billed],
sum(case when year(P.DOCDATE) = 2011 and P.DOCTYPE = 6
   then P.DOCAMNT else 0 end) [2011 Paid],
sum(case when year(P.DOCDATE) = 2010 and P.DOCTYPE &lt; 6
   then P.DOCAMNT else 0 end) [2010 Billed],
sum(case when year(P.DOCDATE) = 2010 and P.DOCTYPE = 6
   then P.DOCAMNT else 0 end) [2010 Paid],
sum(case when year(P.DOCDATE) = 2009 and P.DOCTYPE &lt; 6
   then P.DOCAMNT else 0 end) [2009 Billed],
sum(case when year(P.DOCDATE) = 2009 and P.DOCTYPE = 6
   then P.DOCAMNT else 0 end) [2009 Paid],
sum(case when year(P.DOCDATE) = 2008 and P.DOCTYPE &lt; 6
   then P.DOCAMNT else 0 end) [2008 Billed],
sum(case when year(P.DOCDATE) = 2008 and P.DOCTYPE = 6
   then P.DOCAMNT else 0 end) [2008 Paid],
sum(case when year(P.DOCDATE) = 2007 and P.DOCTYPE &lt; 6
   then P.DOCAMNT else 0 end) [2007 Billed],
sum(case when year(P.DOCDATE) = 2007 and P.DOCTYPE = 6
   then P.DOCAMNT else 0 end) [2007 Paid],
sum(case when P.DOCTYPE &lt; 6 then P.DOCAMNT else 0 end) [Life Billed],
sum(case when P.DOCTYPE = 6 then P.DOCAMNT else 0 end) [Life Paid]

FROM --all posted payables transactions, exclude voids
 (SELECT VENDORID, DOCTYPE, DOCDATE, PSTGDATE,
 case when DOCTYPE in (4,5) then DOCAMNT *-1 else DOCAMNT end DOCAMNT
 FROM PM20000
 WHERE VOIDED = 0
 UNION ALL
 SELECT VENDORID, DOCTYPE, DOCDATE, PSTGDATE,
 case when DOCTYPE in (4,5) then DOCAMNT *-1 else DOCAMNT end DOCAMNT
 FROM PM30200
 WHERE VOIDED = 0) P

INNER JOIN -- vendor master
 PM00200 V
 ON V.VENDORID = P.VENDORID

GROUP BY P.VENDORID, V.VENDNAME

GO
GRANT SELECT ON view_Vendor_Totals_by_Year TO DYNGRP
</pre></p>
<p><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/payables-sql-code/'>Payables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/payables/'>Payables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a>, <a href='http://victoriayudin.com/tag/year-end-close/'>year end close</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3931/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3931&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2012/01/04/sql-view-for-vendor-yearly-totals-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2011/02/briefcaseinvoice.jpg?w=85" />
		<media:content url="http://victoriayudin.files.wordpress.com/2011/02/briefcaseinvoice.jpg?w=85" medium="image">
			<media:title type="html">briefcase invoice</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view to show monthly totals for Dynamics GP Vendors</title>
		<link>http://victoriayudin.com/2011/12/09/sql-view-to-show-monthly-totals-for-dynamics-gp-vendors/</link>
		<comments>http://victoriayudin.com/2011/12/09/sql-view-to-show-monthly-totals-for-dynamics-gp-vendors/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 11:35:17 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Payables SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Payables]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3902</guid>
		<description><![CDATA[In response to a reader request, I have created this new view based on my Vendor Yearly Totals view that will show monthly totals for your Dynamics GP Vendors for all years. This view will show both the numbers and names of the months and assumes that you have 12 periods corresponding to the calendar [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3902&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">In response to a reader request, I have created this new view based on my <a title="SQL view to show yearly totals for Dynamics GP Vendors" href="http://victoriayudin.com/2010/07/15/sql-view-to-show-yearly-totals-for-dynamics-gp-vendors/">Vendor Yearly Totals view</a> that will show monthly totals for your Dynamics GP Vendors for all years.</p>
<p style="text-align:justify;">This view will show both the numbers and names of the months and assumes that you have 12 periods corresponding to the calendar months. To get results for a particular year you can run the following query against this view after creating it:</p>
<p><code> select * from view_Vendor_Monthly_Totals<br />
where [Year] = 2011 <span style="color:#008000;">--change the year as desired</span><br />
</code></p>
<p>For more Dynamics GP Payables code, take a look at my <a title="Payables SQL Views" href="http://victoriayudin.com/gp-reports/payables-sql-views/">Payables SQL Views page</a>. Or check out my <a title="GP Reports" href="http://victoriayudin.com/gp-reports/">GP Reports page</a> for views in other modules and additional report writing and coding tips.</p>
<p><pre class="brush: sql;">

CREATE VIEW view_Vendor_Monthly_Totals
AS

-- ***************************************************************
-- view_Vendor_Monthly_Totals
-- Created Dec 9, 2011 by Victoria Yudin - Flexible Solutions, Inc.
-- For updates please see http://victoriayudin.com/gp-reports/
-- Shows totals for all AP vendors per month and year
-- Assumes periods are calendar months
-- Results shown for calendar months and functionaly currency
-- ***************************************************************

SELECT VT.VENDORID Vendor_ID,
       VM.VENDNAME Vendor_Name,
       VM.VNDCLSID Class_ID,
       case VM.VENDSTTS
          when 1 then 'Active'
          when 2 then 'Inactive'
          when 3 then 'Temporary'
          end Vendor_Status,
       case VM.TEN99TYPE
          when 1 then 'Not a 1099 Vendor'
          when 2 then 'Dividend'
          when 3 then 'Interest'
          when 4 then 'Miscellaneous'
          end [1099_Type],
       VM.PYMTRMID Payment_Terms_ID,
       VT.PERIODID Period,
       datename(month, DATEADD(month, VT.PERIODID, -1 )) [Month],
       VT.YEAR1 [Year],
       sum(VT.AMBLDLIF) Amount_Billed,
       sum(VT.AMTPDLIF) Amount_Paid,
       sum(VT.TEN99ALIF) [1099_Amount],
       sum(VT.FINCHLIF) Finance_Charges,
       sum(VT.WROFSLIF) Writeoffs,
       sum(VT.RTRNSLIF) [Returns],
       sum(VT.TRDTKLIF) Trade_Discounts,
       sum(VT.DISAVLIF) Term_Discounts_Avail,
       sum(VT.DISTKNLF) Term_Discounts_Taken,
       sum(VT.DISLSTLF) Term_Discounts_Lost,
       sum(VT.Withholding_LIFE) Withholding,
       sum(VT.NOINVLIF) Num_Of_Invoices,
       sum(VT.NFNCHLIF) Num_Of_Finance_Charges,
       VM.ADDRESS1 Address_1,
       VM.ADDRESS2 Address_2,
       VM.ADDRESS3 Address_3,
       VM.CITY City,
       VM.[STATE] [State],
       VM.ZIPCODE Zip_Code,
       VM.COUNTRY Country,
       VM.TXIDNMBR Tax_ID

FROM PM00202 VT

INNER JOIN PM00200 VM
       ON VT.VENDORID = VM.VENDORID

WHERE VT.HISTTYPE = 0

GROUP BY VT.VENDORID, VM.VENDNAME, VM.VNDCLSID, VM.VENDSTTS, VM.TEN99TYPE,
		 VM.PYMTRMID, VT.PERIODID, VT.YEAR1, VM.ADDRESS1, VM.ADDRESS2,
         VM.ADDRESS3, VM.CITY, VM.[STATE], VM.ZIPCODE, VM.COUNTRY, VM.TXIDNMBR

GO
GRANT SELECT ON view_Vendor_Monthly_Totals TO DYNGRP
</pre></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/payables-sql-code/'>Payables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/payables/'>Payables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3902/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3902/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3902/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3902/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3902/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3902/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3902/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3902/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3902/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3902/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3902/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3902/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3902/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3902/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3902&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2011/12/09/sql-view-to-show-monthly-totals-for-dynamics-gp-vendors/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2011/12/shaking-hands.jpg?w=110" />
		<media:content url="http://victoriayudin.files.wordpress.com/2011/12/shaking-hands.jpg?w=110" medium="image">
			<media:title type="html">shaking hands</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for bank deposits and receipts in Dynamics GP</title>
		<link>http://victoriayudin.com/2011/10/06/sql-view-for-bank-deposits-and-receipts-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2011/10/06/sql-view-for-bank-deposits-and-receipts-in-dynamics-gp/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 20:03:30 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Bank Rec SQL code]]></category>
		<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Bank Reconciliation]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3813</guid>
		<description><![CDATA[About a year ago I published a view for a Checkbook Register and have received some follow up requests asking for a way to show the receipt details. Primarily this request seems to come from the need to see the difference in dates between the receipts and the deposits for tracking down possible bank reconciliation issues. I didn&#8217;t want to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3813&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">About a year ago I published a view for a <a title="SQL view for Dynamics GP Checkbook Register" href="http://victoriayudin.com/2010/10/14/sql-view-for-dynamics-gp-checkbook-register/" target="_blank">Checkbook Register</a> and have received some follow up requests asking for a way to show the receipt details. Primarily this request seems to come from the need to see the difference in dates between the receipts and the deposits for tracking down possible bank reconciliation issues. I didn&#8217;t want to clutter up the original view with this, so I thought it would be better to create a separate view showing the receipt details.</p>
<p style="text-align:justify;">The view below shows all the posted deposits and the associated receipts.  Each receipt is on a separate line and the deposit information will be repeated as many times as there are receipts in that deposit.</p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre>CREATE VIEW view_Bank_Deposits_and_Receipts
as</pre>
<p><span style="color:#888888;"><code>/*******************************************************************</code></span><br />
<span style="color:#888888;"><code>view_Bank_Deposits_and_Receipts</code></span><br />
<span style="color:#888888;"><code>Created on Oct 6, 2011 by Victoria Yudin</code></span><br />
<span style="color:#888888;"><code>For updates please see http://victoriayudin.com/gp-reports/</code></span><br />
<span style="color:#888888;"><code>All bank rec deposits with their receipts - one line per receipt</code></span><br />
<span style="color:#888888;"><code>Includes voided transactions </code></span><br />
<span style="color:#888888;"><code>Tables: </code></span><br />
<span style="color:#888888;"><code>CM20200 - bank transactions </code></span><br />
<span style="color:#888888;"><code>CM20300 - bank receipts </code></span><br />
<span style="color:#888888;"><code>CM40101 - transaction type setup</code></span><br />
<span style="color:#888888;"><code>*******************************************************************/</code></span></p>
<pre>SELECT
     T.CHEKBKID Checkbook_ID,
     T.CMTrxNum Deposit_Number,
     T.TRXDATE Deposit_Date,
     T.GLPOSTDT Deposit_GL_Posting_Date,
     T.Checkbook_Amount Deposit_Amount,
     T.CURNCYID Currency_ID,
     T.DSCRIPTN 'Description',
     T.ClrdAmt Cleared_Amount,
     CASE T.Recond
     WHEN 1 THEN 'Yes'
       ELSE 'No'
       END Reconciled,
     T.AUDITTRAIL Audit_Trail,
     CASE T.VOIDED
       WHEN 1 THEN 'Yes'
       ELSE 'No'
       END Deposit_Voided,
     R.RCPTNMBR Receipt_Number,
     R.receiptdate Receipt_Date,
     R.GLPOSTDT Receipt_GL_Posting_Date,
     CASE R.RcpType
       WHEN 1 THEN 'Check'
       WHEN 2 THEN 'Cash'
       WHEN 3 THEN 'Credit Card'
       END Receipt_Type,
     R.RcvdFrom Received_From,
     R.ORIGAMT Originating_Amount,
     R.Checkbook_Amount Receipt_Amount,
     R.CURNCYID Receipt_Currency,
     CASE R.VOIDED
       WHEN 1 THEN 'Yes'
       ELSE 'No'
       END Receipt_Voided

FROM CM20200 T

LEFT OUTER JOIN CM40101 D
ON D.CMTrxType = T.CMTrxType

LEFT OUTER JOIN CM20300 R
ON R.depositnumber = T.CMTrxNum

WHERE D.DOCABREV = 'DEP'</pre>
<p><code></code><br />
<span style="color:#339966;"><code>/** the following will grant permissions to this view to DYNGRP,</code></span><br />
<code><span style="color:#339966;">leave this section off if you do not want to grant permissions **/</span></code><code><br />
</code><code>GO</code><br />
<code>GRANT SELECT ON view_Bank_Deposits_and_Receipts TO DYNGRP</code></p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/gp-reports-code/bank-rec-sql-code/'>Bank Rec SQL code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a> Tagged: <a href='http://victoriayudin.com/tag/bank-reconciliation/'>Bank Reconciliation</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3813/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3813/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3813/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3813&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2011/10/06/sql-view-for-bank-deposits-and-receipts-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2008/10/piggybank.jpg?w=96" />
		<media:content url="http://victoriayudin.files.wordpress.com/2008/10/piggybank.jpg?w=96" medium="image">
			<media:title type="html">piggy bank</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for current Payables aging in Dynamics GP</title>
		<link>http://victoriayudin.com/2011/09/30/sql-view-for-current-payables-aging-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2011/09/30/sql-view-for-current-payables-aging-in-dynamics-gp/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 12:51:22 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Payables SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Payables]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3790</guid>
		<description><![CDATA[Over the past few years I have had several requests for a summary current Payables aging report that can be easily exported into Excel. Yes, you can play with the Report Writer aging report to take out the headers and make it export to Excel, but sometimes there are other reasons for wanting a report outside [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3790&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Over the past few years I have had several requests for a summary current Payables aging report that can be easily exported into Excel. Yes, you can play with the Report Writer aging report to take out the headers and make it export to Excel, but sometimes there are other reasons for wanting a report outside of Report Writer.</p>
<p style="text-align:justify;">Below is a script to create a view for this. It is only looking at functional currency and will return one row per vendor with a balance. I am hard-coding the aging using the default aging setup installed with GP, which is aging by due date and using the following buckets:</p>
<ul>
<li>
<div style="text-align:justify;">Current</div>
</li>
<li>
<div style="text-align:justify;">31 to 60 Days</div>
</li>
<li>
<div style="text-align:justify;">61 to 90 Days</div>
</li>
<li>
<div style="text-align:justify;">91 and Over</div>
</li>
</ul>
<p style="text-align:justify;">If you would like to use different aging buckets, just follow the examples in my code.</p>
<p><pre class="brush: sql;">
create view view_Current_Payables_Aging_Summary
as

-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-- view_Current_Payables_Aging_Summary
-- Created Sep 30, 2011 by Victoria Yudin - Flexible Solutions, Inc.
-- For updates please see http://victoriayudin.com/gp-reports/
-- Shows current AP aging
-- Functional currency only
-- Updated on Jan 25, 2012 to fix all aging buckets to use due dates
-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

SELECT
VM.VENDORID Vendor_ID, VM.VENDNAME Vendor_Name, 
VM.VNDCLSID Vendor_Class, VM.PYMTRMID Vendor_Terms,

sum(CASE
   WHEN P.DOCTYPE &lt; 4 THEN P.CURTRXAM
   ELSE P.CURTRXAM * -1
   END) Unapplied_Amount,

sum(CASE
   WHEN DATEDIFF(d, P.DUEDATE, getdate()) &lt; 31 and P.DOCTYPE &lt; 4 THEN P.CURTRXAM
   WHEN DATEDIFF(d, P.DUEDATE, getdate()) &lt; 31 and P.DOCTYPE &gt; 3 THEN P.CURTRXAM * -1
   ELSE 0
   END) [Current],

sum(CASE
   WHEN DATEDIFF(d, P.DUEDATE, getdate()) between 31 and 60 
      and P.DOCTYPE &lt; 4 THEN P.CURTRXAM
   WHEN DATEDIFF(d, P.DUEDATE, getdate()) between 31 and 60 
      and P.DOCTYPE &gt; 3 THEN P.CURTRXAM * -1
   ELSE 0
   END) [31_to_60_Days],

sum(CASE
   WHEN DATEDIFF(d, P.DUEDATE, getdate()) between 61 and 90
      and P.DOCTYPE &lt; 4 THEN P.CURTRXAM
   WHEN DATEDIFF(d, P.DUEDATE, getdate()) between 61 and 90
      and P.DOCTYPE &gt; 3 THEN P.CURTRXAM * -1
   ELSE 0
   END) [61_to_90_Days],

sum(CASE
   WHEN DATEDIFF(d, P.DUEDATE, getdate()) &gt; 90 and P.DOCTYPE &lt; 4 THEN P.CURTRXAM
   WHEN DATEDIFF(d, P.DUEDATE, getdate()) &gt; 90 and P.DOCTYPE &gt; 3 THEN P.CURTRXAM * -1
   ELSE 0
   END) [91_and_Over]

FROM PM00200 VM  --vendor master
INNER JOIN PM20000 P  --open payables
   ON P.VENDORID = VM.VENDORID

WHERE P.CURTRXAM &lt;&gt; 0 AND VOIDED = 0

GROUP BY VM.VENDORID, VM.VENDNAME, VM.PYMTRMID, VM.VNDCLSID

-- add permissions for DYNGRP
GO
GRANT SELECT ON view_Current_Payables_Aging_Summary TO DYNGRP
</pre></p>
<p>style=&#8221;text-align: justify;&#8221;&gt;<em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/payables-sql-code/'>Payables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/payables/'>Payables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3790/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3790/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3790/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3790&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2011/09/30/sql-view-for-current-payables-aging-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2011/02/briefcaseinvoice.jpg?w=85" />
		<media:content url="http://victoriayudin.files.wordpress.com/2011/02/briefcaseinvoice.jpg?w=85" medium="image">
			<media:title type="html">briefcase invoice</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for last sale date of item</title>
		<link>http://victoriayudin.com/2011/03/31/sql-view-for-last-sale-date-of-item/</link>
		<comments>http://victoriayudin.com/2011/03/31/sql-view-for-last-sale-date-of-item/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 13:14:20 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[SOP SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Sales Order Processing]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3572</guid>
		<description><![CDATA[An interesting question came up in response to my last SQL view showing the last sale by customer and item. How do you show the latest sale of an item and who the customer was for that particular sale? This is a bit more difficult, as you have to make two passes through the data, first [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3572&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">An interesting question came up in response to my last <a title="SQL view for last sale by customer and item" href="http://victoriayudin.com/2011/03/29/sql-view-for-last-sale-by-customer-and-item/">SQL view showing the last sale by customer and item</a>. How do you show the latest sale of an item and who the customer was for that particular sale?</p>
<p style="text-align:justify;">This is a bit more difficult, as you have to make two passes through the data, first to find the latest date and then to pull out the information for that date only. There are also many things to consider when writing a report like this &#8211; for example how do you handle multiple sales of the same item on the same date? Do you show all the customers or just one?  If just one, which one? Also, what happens if you have a different item description? Is that considered a different item?  </p>
<p style="text-align:justify;">The view below shows the last sale date of an item (using Invoice Date) and will return multiple lines if the same item was sold to more than one customer on that date. (So item ABC was last sold on 3/31/2011, and 3 different customers bought it on that date, you will see 3 individual lines in the results, one for each customer.) It will also show different item descriptions as different items, but only for the last sale date of the item. (So if item XYZ was last sold on 3/31/2011, but there are two different item descriptions in SOP10200 for the items sold on that date, they will show up as different lines in the results.)</p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre><span style="color:#888888;"><span style="color:#000000;">CREATE VIEW view_Last_Sale_by_Item
AS

</span><span style="color:#339966;">/*******************************************************************
view_Last_Sale_By_Item
Created on Mar 31, 2011 by Victoria Yudin - Flexible Solutions, Inc.
For updates see http://victoriayudin.com/gp-reports/
Only looks at posted SOP invoices that are not voided.
Multiple customer sales on the same date are shown as separate lines.
Different item descriptions for items sold on the same date are shown
	as separate lines. 

Tables used:
HH - History Header - SOP30200
HL - History Line - SOP30300
*******************************************************************/

</span><span style="color:#000000;">SELECT DISTINCT
	MD.Last_Sale,
	HH.CUSTNMBR Customer_ID,
	HL.ITEMNMBR Item_Number,
	HL.ITEMDESC Item_Description,
	HH.SOPNUMBE Invoice_Number

FROM
	SOP30200 HH

INNER JOIN
	SOP30300 HL
	ON HH.SOPTYPE = HL.SOPTYPE
	AND HH.SOPNUMBE = HL.SOPNUMBE

INNER JOIN
	(SELECT max(H.DOCDATE) Last_Sale, D.ITEMNMBR
	 FROM SOP30200 H
	 INNER JOIN SOP30300 D
		ON H.SOPTYPE = D.SOPTYPE
		AND H.SOPNUMBE = D.SOPNUMBE
	 WHERE H.SOPTYPE = 3 AND H.VOIDSTTS = 0
	 GROUP BY D.ITEMNMBR) MD <span style="color:#339966;">-- max date
</span>	ON HL.ITEMNMBR = MD.ITEMNMBR
	AND HH.DOCDATE = MD.Last_Sale

WHERE
	HH.SOPTYPE = 3
	AND HH.VOIDSTTS = 0

<span style="color:#339966;">/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
</span>GO
GRANT SELECT ON view_Last_Sale_By_Item TO DYNGRP</span></span></pre>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/sop-sql-code/'>SOP SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/sales-order-processing/'>Sales Order Processing</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3572/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3572/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3572/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3572&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2011/03/31/sql-view-for-last-sale-date-of-item/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2011/03/inside-cart.jpg?w=96" />
		<media:content url="http://victoriayudin.files.wordpress.com/2011/03/inside-cart.jpg?w=96" medium="image">
			<media:title type="html">3d trolley</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for last sale by customer and item</title>
		<link>http://victoriayudin.com/2011/03/29/sql-view-for-last-sale-by-customer-and-item/</link>
		<comments>http://victoriayudin.com/2011/03/29/sql-view-for-last-sale-by-customer-and-item/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 13:23:09 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[SOP SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Sales Order Processing]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3556</guid>
		<description><![CDATA[When was the last time a particular customer bought a particular item? Here is a little view that will tell you. For other Dynamics GP views and reporting tips, take a look at my GP Reports page. Or check out the SOP Tables page for more details about reporting on SOP data. ~~~~~ CREATE VIEW view_Last_Sale_By_Customer_Item AS /******************************************************************* [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3556&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When was the last time a particular customer bought a particular item? Here is a little view that will tell you.</p>
<p>For other Dynamics GP views and reporting tips, take a look at my <a title="GP Reports" href="http://victoriayudin.com/gp-reports/">GP Reports page</a>. Or check out the <a title="SOP Tables" href="http://victoriayudin.com/gp-tables/sop-tables/">SOP Tables page</a> for more details about reporting on SOP data.</p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre>CREATE VIEW view_Last_Sale_By_Customer_Item
AS
<span style="color:#339966;">
/*******************************************************************
view_Last_Sale_By_Customer_Item
Created on Mar 29, 2011 by Victoria Yudin - Flexible Solutions, Inc.
For updates see http://victoriayudin.com/gp-reports/
Only looks at posted SOP invoices that are not voided

Tables used:
HH - History Header - SOP30200
HL - History Line - SOP30300
*******************************************************************/

</span>SELECT
	max(HH.DOCDATE) Last_Sale,
	HH.CUSTNMBR Customer_ID,
	HL.ITEMNMBR Item_Number,
	HL.ITEMDESC Item_Description

FROM
	SOP30200 HH

INNER JOIN
	SOP30300 HL
	ON HH.SOPTYPE = HL.SOPTYPE
	AND HH.SOPNUMBE = HL.SOPNUMBE

WHERE
	HH.SOPTYPE = 3
	AND HH.VOIDSTTS = 0

GROUP BY
	HH.CUSTNMBR,
	HL.ITEMNMBR,
	HL.ITEMDESC

<span style="color:#3366ff;"><span style="color:#339966;">/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
</span><span style="color:#000000;">GO
GRANT SELECT ON view_Last_Sale_By_Customer_Item TO DYNGRP</span></span></pre>
<p style="text-align:center;"><span style="color:#808080;"> </span></p>
<p style="text-align:center;"><span style="color:#808080;">~~~~~</span></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/sop-sql-code/'>SOP SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/sales-order-processing/'>Sales Order Processing</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3556/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3556/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3556/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3556&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2011/03/29/sql-view-for-last-sale-by-customer-and-item/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2010/09/shoppingcart-e1283329105252.jpg?w=111" />
		<media:content url="http://victoriayudin.files.wordpress.com/2010/09/shoppingcart-e1283329105252.jpg?w=111" medium="image">
			<media:title type="html">empty cart</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>Customer shipping addresses in Dynamics GP</title>
		<link>http://victoriayudin.com/2011/02/18/customer-shipping-addresses-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2011/02/18/customer-shipping-addresses-in-dynamics-gp/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 13:26:36 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Receivables SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Receivables]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3513</guid>
		<description><![CDATA[Need to see a list of all the shipping addresses for your Dynamics GP customers? You can use the view below which pulls out the ship to address and the associated tax schedule, shipping method , salesperson, etc. To see other SQL views for Dynamics GP receivables data, take a look at the Receivables SQL Views page. For [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3513&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Need to see a list of all the shipping addresses for your Dynamics GP customers? You can use the view below which pulls out the ship to address and the associated tax schedule, shipping method , salesperson, etc.</p>
<p style="text-align:justify;">To see other SQL views for Dynamics GP receivables data, take a look at the <a title="Receivables SQL Views" href="http://victoriayudin.com/gp-reports/receivables-sql-views/">Receivables SQL Views page</a>. For other Dynamics GP views and reporting reporting information, check out the <a title="GP Reports" href="http://victoriayudin.com/gp-reports/">GP Reports page</a>.</p>
<p style="text-align:center;"><span style="color:#888888;">﻿~~~~~</span></p>
<pre>CREATE VIEW view_Customer_Ship_To_Addresses
AS

<span style="color:#888888;">/********************************************************************
view_Customer_Ship_To_Addresses
Created on Feb. 18, 2011 by Victoria Yudin - Flexible Solutions, Inc.
For updates visit http://victoriayudin.com/gp-reports/
********************************************************************/

</span>SELECT 	M.CUSTNMBR Customer_ID,
	M.CUSTNAME Customer_Name,
	M.CUSTCLAS Class_ID,
	M.CPRCSTNM Parent_ID,
	M.PRSTADCD Ship_To_Address_ID,
	A.CNTCPRSN Contact,
	A.ADDRESS1 Address_1,
	A.ADDRESS2 Address_2,
	A.ADDRESS3 Address_3,
	A.CITY City,
	A.[STATE] [State],
	A.ZIP Zip,
	A.COUNTRY Country,
	A.PHONE1 Phone_1,
	A.PHONE2 Phone_2,
	A.PHONE3 Phone_3,
	A.FAX Fax,
	A.UPSZONE UPS_Zone,
	A.SHIPMTHD Shipping_Method,
	A.TAXSCHID Tax_Schedule_ID,
	A.LOCNCODE Site_ID,
	A.SLPRSNID Salesperson_ID,
	A.SALSTERR Territory_ID,
	A.USERDEF1 [User-Defined_1],
	A.USERDEF2 [User-Defined_2],
	A.MODIFDT Modified_Date,
	A.CREATDDT Created_Date

FROM RM00101 M  <span style="color:#339966;">--customer master

</span>INNER JOIN RM00102 A  <span style="color:#339966;">--addresses
</span>	ON M.CUSTNMBR = A.CUSTNMBR
	AND M.PRSTADCD = A.ADRSCODE

<span style="color:#339966;">/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
</span>
GO
GRANT SELECT ON view_Customer_Ship_To_Addresses to DYNGRP</pre>
<p style="text-align:center;"><span style="color:#888888;"> </span></p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/receivables-sql-code/'>Receivables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/receivables/'>Receivables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3513/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3513&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2011/02/18/customer-shipping-addresses-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2011/01/boxes.jpg?w=96" />
		<media:content url="http://victoriayudin.files.wordpress.com/2011/01/boxes.jpg?w=96" medium="image">
			<media:title type="html">boxes</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>Yearly Fixed Assets depreciation totals in Dynamics GP</title>
		<link>http://victoriayudin.com/2011/02/15/yearly-fixed-assets-depreciation-totals-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2011/02/15/yearly-fixed-assets-depreciation-totals-in-dynamics-gp/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 13:32:24 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[Fixed Assets SQL code]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Fixed Assets]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3481</guid>
		<description><![CDATA[Around this time of year we get a lot of questions about closing the year for the Dynamics GP Fixed Assets module, since you cannot run January depreciation until you close the prior year. And right after we start getting requests for reports of prior year depreciation. Here is a view that shows year to date, last year [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3481&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Around this time of year we get a lot of questions about closing the year for the Dynamics GP Fixed Assets module, since you cannot run January depreciation until you close the prior year. And right after we start getting requests for reports of prior year depreciation. Here is a view that shows year to date, last year and life to date depreciation by asset. It also has a pretty cool example of how to group your data into columns by year.</p>
<p style="text-align:justify;">For more detail on the Fixed Assets module, please visit my <a title="Fixed Assets tables" href="http://victoriayudin.com/gp-reports/fixed-assets-tables/" target="_blank">Fixed Assets Tables page</a>. If you’re looking for more SQL code, you can find it on my <a title="GP Reports" href="http://victoriayudin.com/gp-reports/" target="_blank">GP Reports page</a>.</p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre>CREATE VIEW view_FA_Depreciation_Yearly
AS</pre>
<p><span style="color:#888888;"><code>/********************************************************************</code></span><br />
<span style="color:#888888;"><code>view_FA_Depreciation_Yearly</code></span><br />
<span style="color:#888888;"><code>Created on Feb 15, 2011 by Victoria Yudin - Flexible Solutions, Inc. </code></span><br />
<span style="color:#888888;"><code>For updates visit http://victoriayudin.com/gp-reports/ </code></span><br />
<span style="color:#888888;"><code>Tables used: </code></span><br />
<span style="color:#888888;"><code>FA00100 – fm - Asset General Information Master </code></span><br />
<span style="color:#888888;"><code>FA00902 – d - Financial Detail Master </code></span><br />
<span style="color:#888888;"><code>FA40200 - b - Book Setup</code></span><br />
<span style="color:#888888;"><code>FA40400 - a - Asset Account Master</code></span><br />
<span style="color:#888888;"><code>GL00105 - am - Account Index Master</code></span><br />
<span style="color:#888888;"><code>Updated Nov 30, 2011 to add accumulated depreciation account</code></span><br />
<span style="color:#888888;"><code>********************************************************************/</code></span></p>
<pre>SELECT
     fm.ASSETID Asset_ID,
     fm.ASSETIDSUF Asset_Suffix,
     fm.ASSETDESC Asset_Description,
     fm.ACQDATE Acquisition_Date,
     fm.Acquisition_Cost,
     b.BOOKID Book_ID,
     sum(d.AMOUNT) Life_to_Date_Depreciation,
     sum(case
	when year(getdate()) = d.FAYEAR
	then d.AMOUNT
	else 0 end) Year_to_Date_Depreciation,
     sum(case
	when year(dateadd(yy,-1,getdate()))=d.FAYEAR
	then d.AMOUNT
	else 0 end) Last_Year_Depreciation,
     fm.ASSETCLASSID Asset_Class,
     am.ACTNUMST Accum_Depr_Account

FROM FA00902 d  <span style="color:#339966;">-- financial detail </span>

LEFT OUTER JOIN
     FA00100 fm  <span style="color:#339966;">-- fa master </span>
     ON fm.assetindex = d.assetindex

INNER JOIN
     FA40200 b   <span style="color:#339966;">-- book setup </span>
     ON b.BOOKINDX = d.BOOKINDX	

INNER JOIN
     FA00400 a  <span style="color:#339966;">-- account numbers</span>
     ON a.ASSETINDEX = fm.ASSETINDEX

INNER JOIN
     GL00105 am  <span style="color:#339966;">-- GL account for accumulated depr.</span>
     ON am.ACTINDX = a.DEPRRESVACCTINDX  

WHERE d.TRANSACCTTYPE = 2  <span style="color:#339966;">-- depreciation only </span>

GROUP BY fm.ASSETID, fm.ASSETIDSUF, fm.ASSETDESC, b.BOOKID,
fm.ASSETCLASSID, fm.ACQDATE, fm.Acquisition_Cost, am.ACTNUMST</pre>
<p><code></code><br />
<span style="color:#339966;"><code>/** the following will grant permissions to this view to DYNGRP, </code></span><br />
<span style="color:#339966;"><code>leave this section off if you do not want to grant permissions **/ </code></span><br />
<code>GO</code><br />
<code>GRANT SELECT ON view_FA_Depreciation_Yearly to DYNGRP</code><span style="color:#888888;"> </span></p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/fixed-assets-sql-code/'>Fixed Assets SQL code</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a> Tagged: <a href='http://victoriayudin.com/tag/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/tag/fixed-assets/'>Fixed Assets</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3481/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3481/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3481/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3481&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2011/02/15/yearly-fixed-assets-depreciation-totals-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2011/02/briefcaseinvoice.jpg?w=85" />
		<media:content url="http://victoriayudin.files.wordpress.com/2011/02/briefcaseinvoice.jpg?w=85" medium="image">
			<media:title type="html">briefcase invoice</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for Dynamics GP Checkbook Register</title>
		<link>http://victoriayudin.com/2010/10/14/sql-view-for-dynamics-gp-checkbook-register/</link>
		<comments>http://victoriayudin.com/2010/10/14/sql-view-for-dynamics-gp-checkbook-register/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 10:08:39 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Bank Rec SQL code]]></category>
		<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Bank Reconciliation]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3107</guid>
		<description><![CDATA[The view below will return all Checkbook transactions for Dynamics GP. It does not show details for the deposits because I wanted to keep this to one line per transaction, as it appears on the Checkbook Register in GP. To add deposit detail to you report, you can join table CM20300 on CM20200.CMTrxNum = CM20300.depositnumber. You [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3107&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">The view below will return all Checkbook transactions for Dynamics GP. It does not show details for the deposits because I wanted to keep this to one line per transaction, as it appears on the Checkbook Register in GP. To add deposit detail to you report, you can join table CM20300 on CM20200.CMTrxNum = CM20300.depositnumber.</p>
<p>You can find other Dynamics GP views on my <a title="GP Reports" href="http://victoriayudin.com/gp-reports/" target="_blank">GP Reports page</a>.</p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre>CREATE VIEW view_Checkbook_Register
as

<span style="color:#888888;">/******************************************************************* 
view_Checkbook_Register
Created on Oct 14, 2010 by Victoria Yudin 
For updates see http://victoriayudin.com/gp-reports/ 
All bank rec transactions - one line per transaction 
Includes voided transactions 
Tables: CM20200 - bank transactions 
CM20600 - bank transfers 
CM40101 - transaction type setup 

Updated Nov 10, 2010 to link to CM40101 table instead of hard coding 
transaction types (thanks to Siva Venkataraman for this suggestion) 

Updated Feb 18, 2011 to include code for bank transfers from and to 
the same checkbook (thanks to Max Toledo for this suggestion)
*******************************************************************/

</span>SELECT	T.CHEKBKID Checkbook_ID,
	T.CMTrxNum Trx_Number,
	D.DOCABREV Trx_Type,
	T.TRXDATE Trx_Date,
	T.GLPOSTDT GL_Posting_Date,
	T.paidtorcvdfrom Paid_To_Received_From,
	CASE
	  WHEN T.CMTrxType in (1,2,5,101,102)
	    THEN T.Checkbook_Amount
	  WHEN T.CMTrxType = 7 AND X.CMCHKBKID = X.CMFRMCHKBKID
	    THEN T.Checkbook_Amount*0 
	  WHEN T.CMTrxType = 7 AND T.CHEKBKID = X.CMCHKBKID
	    THEN T.Checkbook_Amount
	  WHEN T.CMTrxType = 7 AND T.CHEKBKID = X.CMFRMCHKBKID
	    THEN T.Checkbook_Amount*-1
	  ELSE T.Checkbook_Amount*-1
	  END Checkbook_Amount,
	T.CURNCYID Currency_ID,
	T.DSCRIPTN 'Description',
	T.ClrdAmt Cleared_Amount,
	CASE T.Recond
	  WHEN 1 THEN 'Yes'
	  ELSE 'No'
	  END Reconciled,
	T.AUDITTRAIL Audit_Trail,
	CASE T.VOIDED
	  WHEN 1 THEN 'Yes'
	  ELSE 'No'
	  END Voided 

 FROM CM20200 T 

 LEFT OUTER JOIN
 CM20600 X
 ON T.Xfr_Record_Number = X.Xfr_Record_Number

 INNER JOIN CM40101 D
 ON D.CMTrxType = T.CMTrxType

<span style="color:#008000;">/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
</span>GO
GRANT SELECT ON view_Checkbook_Register TO DYNGRP</pre>
<p style="text-align:center;"><span style="color:#888888;"> </span></p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/gp-reports-code/bank-rec-sql-code/'>Bank Rec SQL code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a> Tagged: <a href='http://victoriayudin.com/tag/bank-reconciliation/'>Bank Reconciliation</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3107/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3107/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3107/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3107&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/10/14/sql-view-for-dynamics-gp-checkbook-register/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2008/10/piggybank.jpg?w=96" />
		<media:content url="http://victoriayudin.files.wordpress.com/2008/10/piggybank.jpg?w=96" medium="image">
			<media:title type="html">piggy bank</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for Payables apply detail and GL distributions in Dynamics GP</title>
		<link>http://victoriayudin.com/2010/09/23/sql-view-for-payables-apply-detail-and-gl-distributions-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2010/09/23/sql-view-for-payables-apply-detail-and-gl-distributions-in-dynamics-gp/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 20:45:13 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Payables SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Payables]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=3070</guid>
		<description><![CDATA[Who doesn&#8217;t need yet another view for Payables transactions in Dynamics GP?   The view below is a combination of my Payment Apply Detail and GL Distributions for AP Transactions views. It lists all Payments, then shows the transactions they were applied to and the GL distributions of those applied to transactions. You can find other Dynamics GP Payables [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3070&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Who doesn&#8217;t need yet another view for Payables transactions in Dynamics GP?  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  The view below is a combination of my <a title="SQL view - Payment Apply Detail" href="http://victoriayudin.com/2009/10/22/sql-view-for-payables-payment-apply-detail-in-dynamics-gp/" target="_blank">Payment Apply Detail</a> and <a title="view - AP GL Distributions" href="http://victoriayudin.com/2008/11/28/sql-view-to-show-all-gl-distributions-for-ap-transactions/" target="_self">GL Distributions for AP Transactions</a> views. It lists all Payments, then shows the transactions they were applied to and the GL distributions of those applied to transactions.</p>
<p style="text-align:justify;">You can find other Dynamics GP Payables views <a title="Dynamics GP Payables SQL views" href="http://victoriayudin.com/gp-reports/payables-sql-views//" target="_blank">here</a> or check out my <a title="GP Reports" href="http://victoriayudin.com/gp-reports/" target="_blank">GP Reports page</a> for other views and reporting links.</p>
<p style="text-align:left;"><span style="color:#888888;"><br />
</span></p>
<p><pre class="brush: sql;">
CREATE VIEW view_Payables_Apply_and_GL_Dist
AS

-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
-- view_Payables_Apply_and_GL_Dist 
-- Created on Sep 23 2010 by Victoria Yudin 
-- For updates see http://victoriayudin.com/gp-reports/ 
-- Does not take Multicurrency into account 
-- Will return multiple lines for payments that were applied to more than  
--     one transaction and for invoices with multiple GL distributions 
-- GL Distributions are shown for the Applied To documents
-- Voided payments are excluded
-- Payments for $0 are excluded
-- Tables Used: 
--     GL00100 – Account Master
--     GL00105 – Account Index Master
--     PM00200 – Vendor Master
--     PM10100 - GL Distributions for Work and Open Transactions 
--     PM10200 – Apply To Work/Open PM20000 – Open/Posted Transactions 
--     PM30200 – Historical/Paid Transactions
--     PM30300 – Apply To History
--     PM30600 - GL Distributions for Historical Transactions 
-- Updated on Feb 22, 2012 to allow for multiple identical GL distributions
--     on same transaction - thanks to Geraldine for helping me track this down!
-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

SELECT	
P.VENDORID Vendor_ID,
V.VENDNAME Vendor_Name,
V.VNDCHKNM Vendor_Check_Name,
CASE P.PYENTTYP
	WHEN 0 THEN 'Check'
	WHEN 1 THEN 'Cash'
	WHEN 2 THEN 'Credit Card'
	WHEN 3 THEN 'EFT'
	ELSE 'Other'
	END Payment_Type,
CASE
	WHEN P.PYENTTYP in (0,1,3) THEN P.CHEKBKID
	ELSE ''
	END Checkbook_ID,
CASE P.PYENTTYP
	WHEN 2 THEN P.CARDNAME
	ELSE ''
	END Credit_Card_ID,
P.DOCDATE Payment_Date,
P.PSTGDATE Payment_GL_Date,
P.VCHRNMBR Payment_Voucher_Number,
P.DOCNUMBR Payment_Document_Number,
P.DOCAMNT Payment_Functional_Amount,
coalesce(PA.APTVCHNM,'') Apply_To_Voucher_Number,
CASE PA.APTODCTY
	WHEN 1 THEN 'Invoice'
	WHEN 2 THEN 'Finance Charge'
	WHEN 3 THEN 'Misc Charge'
	ELSE ''
	END Apply_To_Doc_Type,
coalesce(PA.APTODCNM,'') Apply_To_Doc_Number,
coalesce(PA.APTODCDT,'1/1/1900') Apply_To_Doc_Date,
coalesce(PA.ApplyToGLPostDate,'1/1/1900') Apply_To_GL_Date,
coalesce(PA.APPLDAMT,0) Applied_Amount,
coalesce(G.ACTNUMST,'') GL_Account_Number,
coalesce(G2.ACTDESCR,'') GL_Account_Name,
CASE D.DISTTYPE
	WHEN 1 THEN 'Cash'
	WHEN 2 THEN 'Payable'
	WHEN 3 THEN 'Discount Available'
	WHEN 4 THEN 'Discount Taken'
	WHEN 5 THEN 'Finance Charge'
	WHEN 6 THEN 'Purchase'
	WHEN 7 THEN 'Trade Disc.'
	WHEN 8 THEN 'Misc. Charge'
	WHEN 9 THEN 'Freight'
	WHEN 10 THEN 'Taxes'
	WHEN 11 THEN 'Writeoffs'
	WHEN 12 THEN 'Other'
	WHEN 13 THEN 'GST Disc'
	WHEN 14 THEN 'PPS Amount'
	ELSE ''
	END Distribution_Type,
coalesce(D.DEBITAMT,0) Debit,
coalesce(D.CRDTAMNT,0) Credit

FROM
     (SELECT VENDORID, DOCTYPE, DOCDATE, VCHRNMBR, DOCNUMBR, DOCAMNT,
          VOIDED, TRXSORCE, CHEKBKID, PSTGDATE, PYENTTYP, CARDNAME
      FROM PM30200
      UNION
      SELECT VENDORID, DOCTYPE, DOCDATE, VCHRNMBR, DOCNUMBR, DOCAMNT,
          VOIDED, TRXSORCE, CHEKBKID, PSTGDATE, PYENTTYP, CARDNAME
      FROM PM20000) P

INNER JOIN PM00200 V
     ON P.VENDORID = V.VENDORID

LEFT OUTER JOIN
     (SELECT VENDORID, VCHRNMBR, DOCTYPE, APTVCHNM, APTODCTY,
          APTODCNM, APTODCDT, ApplyToGLPostDate, APPLDAMT
      FROM PM10200
      UNION
      SELECT VENDORID, VCHRNMBR, DOCTYPE, APTVCHNM, APTODCTY,
          APTODCNM, APTODCDT, ApplyToGLPostDate, APPLDAMT
      FROM PM30300) PA
     ON P.VCHRNMBR = PA.VCHRNMBR AND P.VENDORID = PA.VENDORID AND P.DOCTYPE = PA.DOCTYPE

LEFT OUTER JOIN
     (SELECT VENDORID, VCHRNMBR, CNTRLTYP, DEBITAMT, CRDTAMNT,
          DSTINDX, DISTTYPE, DistRef, PSTGDATE
      FROM PM10100
      WHERE PSTGSTUS = 1 AND CNTRLTYP = 0
      UNION ALL
      SELECT VENDORID, VCHRNMBR, CNTRLTYP, DEBITAMT, CRDTAMNT,
          DSTINDX, DISTTYPE, DistRef, PSTGDATE
      FROM PM30600 WHERE CNTRLTYP = 0) D
     ON PA.VENDORID = D.VENDORID AND PA.APTVCHNM = D.VCHRNMBR

LEFT OUTER JOIN  GL00105 G
     ON D.DSTINDX = G.ACTINDX 	

LEFT OUTER JOIN GL00100 G2
     ON D.DSTINDX = G2.ACTINDX 	

WHERE P.DOCTYPE = 6 AND P.DOCAMNT &lt;&gt; 0 AND P.VOIDED = 0

-- add permissions for DYNGRP
GO
GRANT SELECT on view_Payables_Apply_and_GL_Dist to DYNGRP
</pre></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/payables-sql-code/'>Payables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/payables/'>Payables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/3070/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/3070/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/3070/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/3070/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/3070/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/3070/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/3070/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/3070/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/3070/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/3070/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/3070/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/3070/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/3070/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/3070/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=3070&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/09/23/sql-view-for-payables-apply-detail-and-gl-distributions-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2010/09/yelloworangejigsaw.jpg?w=121" />
		<media:content url="http://victoriayudin.files.wordpress.com/2010/09/yelloworangejigsaw.jpg?w=121" medium="image">
			<media:title type="html">YellowOrangeJigsaw</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for Payables invoices originating from POP in Dynamics GP</title>
		<link>http://victoriayudin.com/2010/09/01/sql-view-for-payables-invoices-originating-from-pop-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2010/09/01/sql-view-for-payables-invoices-originating-from-pop-in-dynamics-gp/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 08:22:13 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GL SQL code]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Payables SQL code]]></category>
		<category><![CDATA[POP SQL code]]></category>
		<category><![CDATA[General Ledger]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Payables]]></category>
		<category><![CDATA[Purchase Order Processing]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=2931</guid>
		<description><![CDATA[This Dynamics GP SQL view originated from a request on the Dynamics GP customer forum, but is also something that I can see being useful in a variety of situations. It returns all posted Payables invoices that came from the Purchase Order Processing module with details of the items that were received on each invoice as well [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2931&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">This Dynamics GP SQL view originated from a request on the <a title="Dynamics GP Customer Forum" href="https://community.dynamics.com/forums/32.aspx" target="_blank">Dynamics GP customer forum</a>, but is also something that I can see being useful in a variety of situations. It returns all posted Payables invoices that came from the Purchase Order Processing module with details of the items that were received on each invoice as well as the GL journal entry number for each POP reciept and invoice. </p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre>CREATE VIEW view_Payables_POP_Invoices
AS
<span style="color:#888888;">/*******************************************************************
view_Payables_POP_Invoices
Created on Sep 1, 2010 by Victoria Yudin - Flexible Solutions, Inc.
For updates visit http://victoriayudin.com/gp-reports/
Returns Payables Invoices only</span><span style="color:#888888;">
Updated on Feb 10, 2011 to include GL journal entry number
*******************************************************************/</span>

SELECT	PM.VCHRNMBR Voucher_Number,
	PM.VENDORID Vendor_ID,
	POP.VENDNAME Vendor_Name,
	PM.DOCDATE Invoice_Date,
	PM.DUEDATE Due_Date,
	PM.DOCNUMBR Invoice_Number,
	PM.DOCAMNT Invoice_Amount,
	PM.CURTRXAM Unpaid_Amount,
	CASE PM.VOIDED
		WHEN 0 THEN 'No'
		WHEN 1 THEN 'Yes'
		END Voided,
	POP.POPRCTNM POP_Receipt_Number,
	CASE POP.POPTYPE
		WHEN 2 THEN 'Invoice'
		WHEN 3 THEN 'Shipment/Invoice'
		END Receipt_Type,
	POP.receiptdate Receipt_Date,
	I.RCPTLNNM Receipt_Line_Num,
	I.PONUMBER PO_Number,
	I.ITEMNMBR Item_Number,
	I.ITEMDESC Item_Description,
	R.QTYINVCD Quantity_Invoiced,
	R.UOFM U_of_M,
	I.UNITCOST Unit_Cost,
	I.EXTDCOST Extended_Cost,
	I.LOCNCODE Site_ID,
	CASE I.NONINVEN
		WHEN 0 THEN 'Inventory Item'
		WHEN 1 THEN 'Non-Inventory Item'
		END Item_Type,
	G.JRNENTRY Journal_Entry_Number

FROM
	(SELECT VCHRNMBR,VENDORID, DOCDATE,
		DUEDATE, DOCNUMBR, DOCAMNT,
		CURTRXAM, DOCTYPE, VOIDED
	 FROM PM20000
	 UNION ALL
	 SELECT VCHRNMBR,VENDORID, DOCDATE,
		DUEDATE, DOCNUMBR, DOCAMNT,
		CURTRXAM, DOCTYPE, VOIDED
	 FROM PM30200) PM  <span style="color:#339966;">-- PM trx</span>

INNER JOIN POP30300 POP  <span style="color:#339966;">-- POP header</span>
	ON PM.VENDORID = POP.VENDORID
	AND PM.DOCNUMBR = POP.VNDDOCNM

INNER JOIN POP30310 I  <span style="color:#339966;">-- POP detail</span>
	ON I.POPRCTNM = POP.POPRCTNM

INNER JOIN POP10500 R  <span style="color:#339966;">-- recceipt details</span>
	ON R.POPRCTNM = I.POPRCTNM
	AND R.RCPTLNNM = I.RCPTLNNM

LEFT OUTER JOIN
	(SELECT DISTINCT SOURCDOC, JRNENTRY, ORDOCNUM, ORMSTRID
	 FROM GL20000
	   UNION
	 SELECT DISTINCT SOURCDOC, JRNENTRY, ORDOCNUM, ORMSTRID
 	 FROM GL30000
	   UNION
	 SELECT DISTINCT SOURCDOC, a.JRNENTRY, ORDOCNUM, ORMSTRID
	 FROM GL10001 a
	   INNER JOIN GL10000 b
	   ON a.JRNENTRY = b.JRNENTRY) G  <span style="color:#339966;">--GL entries</span>
	ON G.ORDOCNUM = R.POPRCTNM
	AND G.ORMSTRID = R.VENDORID
	AND G.SOURCDOC in ('POIVC','RECVG')

WHERE PM.DOCTYPE = 1  <span style="color:#339966;">-- invoices only</span>
AND POP.POPTYPE in (2,3)  <span style="color:#339966;">-- invoices only</span>

<span style="color:#3366ff;">/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
GO
GRANT SELECT ON view_Payables_POP_Invoices TO DYNGRP
</span></pre>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p>For more Dynamics GP SQL scripts take a look at the <a title="Victoria Yudin's GP Reports" href="http://victoriayudin.com/gp-reports/" target="_blank">GP Reports page</a> on this blog.</p>
<p><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/gl-sql-code/'>GL SQL code</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/payables-sql-code/'>Payables SQL code</a>, <a href='http://victoriayudin.com/category/gp-reports-code/pop-sql-code/'>POP SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/general-ledger/'>General Ledger</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/payables/'>Payables</a>, <a href='http://victoriayudin.com/tag/purchase-order-processing/'>Purchase Order Processing</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/2931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/2931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/2931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/2931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/2931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/2931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/2931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/2931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/2931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/2931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/2931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/2931/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/2931/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/2931/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2931&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/09/01/sql-view-for-payables-invoices-originating-from-pop-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
	
		<media:thumbnail url="http://victoriayudin.files.wordpress.com/2010/09/shoppingcart-e1283329105252.jpg?w=111" />
		<media:content url="http://victoriayudin.files.wordpress.com/2010/09/shoppingcart-e1283329105252.jpg?w=111" medium="image">
			<media:title type="html">empty cart</media:title>
		</media:content>

		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for asset account numbers in Dynamics GP</title>
		<link>http://victoriayudin.com/2010/08/10/sql-view-for-asset-account-numbers-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2010/08/10/sql-view-for-asset-account-numbers-in-dynamics-gp/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 10:38:30 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[Fixed Assets SQL code]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Fixed Assets]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=2888</guid>
		<description><![CDATA[Want to see all the account numbers set up for all your Fixed Assets? You can do this in SmartList, but SmartList is sometimes limiting when you want to do complex searches. Here is a view that will return all the account numbers assigned for each asset in Dynamics GP. ~~~~~ CREATE VIEW view_Asset_Accounts AS /******************************************************************* view_Asset_Accounts [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2888&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Want to see all the account numbers set up for all your Fixed Assets? You can do this in SmartList, but SmartList is sometimes limiting when you want to do complex searches. Here is a view that will return all the account numbers assigned for each asset in Dynamics GP.</p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre>CREATE VIEW view_Asset_Accounts
AS

/*******************************************************************
view_Asset_Accounts
Created on Aug 10, 2010 by Victoria Yudin - Flexible Solutions, Inc.
For updates visit http://victoriayudin.com/gp-reports/
*******************************************************************/

select	F.ASSETID Asset_ID,
		F.ASSETIDSUF Suffix,
		F.ASSETDESC Desciption,
		F.ASSETCLASSID Asset_Class,
		F.Physical_Location_ID,
		G1.ACTNUMST Depreciation_Expense,
		G2.ACTNUMST Depreciation_Reserve,
		G3.ACTNUMST Prior_Yr_Depreciation,
		G4.ACTNUMST Asset_Cost,
		G5.ACTNUMST Proceeds,
		G6.ACTNUMST Recognized_Gain_Loss,
		G7.ACTNUMST Non_Recognized_Gain_Loss,
		G8.ACTNUMST Clearing_Account

from FA00100 F
left outer join FA00400 A
	on F.ASSETINDEX = A.ASSETINDEX
left outer join GL00105 G1
	on A.DEPREXPACCTINDX = G1.ACTINDX
left outer join GL00105 G2
	on A.DEPRRESVACCTINDX = G2.ACTINDX
left outer join GL00105 G3
	on A.PRIORYRDEPRACCTINDX = G3.ACTINDX
left outer join GL00105 G4
	on A.ASSETCOSTACCTINDX = G4.ACTINDX
left outer join GL00105 G5
	on A.PROCEEDSACCTINDX = G5.ACTINDX
left outer join GL00105 G6
	on A.RECGAINLOSSACCTINDX = G6.ACTINDX
left outer join GL00105 G7
	on A.NONRECGAINLOSSACCTINDX = G7.ACTINDX
left outer join GL00105 G8
	on A.CLEARINGACCTINDX = G8.ACTINDX		

<span style="color:#3366ff;">/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
GO
GRANT SELECT ON view_Asset_Accounts TO DYNGRP
</span></pre>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p>For more Dynamics GP SQL code take a look at the <a title="Victoria Yudin's GP Reports" href="http://victoriayudin.com/gp-reports/" target="_blank">GP Reports page </a>on this blog.</p>
<p><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/fixed-assets-sql-code/'>Fixed Assets SQL code</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a> Tagged: <a href='http://victoriayudin.com/tag/fixed-assets/'>Fixed Assets</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/2888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/2888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/2888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/2888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/2888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/2888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/2888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/2888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/2888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/2888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/2888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/2888/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/2888/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/2888/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2888&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/08/10/sql-view-for-asset-account-numbers-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view for Inventory Price Levels in Dynamics GP</title>
		<link>http://victoriayudin.com/2010/08/09/sql-view-for-inventory-price-levels-in-dynamics-gp/</link>
		<comments>http://victoriayudin.com/2010/08/09/sql-view-for-inventory-price-levels-in-dynamics-gp/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 11:56:20 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Inventory SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Inventory]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=2870</guid>
		<description><![CDATA[When you are creating prices for different price levels in Dynamics GP, there is no easy way to see these, or to see all the prices for a particular price level. Below is a view that can help with this. ~~~~~ CREATE VIEW view_Inventory_Price_Levels AS /******************************************************************* view_Inventory_Price_Levels Created on Aug 9, 2010 by Victoria Yudin - [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2870&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When you are creating prices for different price levels in Dynamics GP, there is no easy way to see these, or to see all the prices for a particular price level. Below is a view that can help with this.</p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre>CREATE VIEW view_Inventory_Price_Levels
AS

/*******************************************************************
view_Inventory_Price_Levels
Created on Aug 9, 2010 by Victoria Yudin - Flexible Solutions, Inc.
For updates visit http://victoriayudin.com/gp-reports/
*******************************************************************/

SELECT IV.ITEMNMBR Item_Number,
       IM.ITEMDESC Item_Description,
       IM.ITMCLSCD Item_Class,
       IV.PRCLEVEL Price_Level,
       CASE IM.PRICMTHD
       	  WHEN 1 THEN 'Currency Amount'
       	  WHEN 2 THEN '% of List Price'
	  WHEN 3 THEN '% Markup – Current Cost'
	  WHEN 4 THEN '% Markup – Standard Cost'
	  WHEN 5 THEN '% Margin – Current Cost'
	  WHEN 6 THEN '% Margin – Standard Cost'
	  END Price_Method,
       IV.CURNCYID Currency_ID,
       IV.UOFM U_of_M,
       CASE IM.PRICMTHD
	  WHEN 1 THEN IV.UOMPRICE
	  WHEN 2 THEN IV.UOMPRICE * IC.LISTPRCE / 100
	  ELSE 0
	  END Price,
       CASE IM.PRICMTHD
	  WHEN 1 THEN 0
	  ELSE IV.UOMPRICE
	  END Percent_of_List,
       IV.FROMQTY From_Qty,
       IV.TOQTY To_Qty,
       IV.QTYBSUOM Qty_In_Base_UofM

FROM   IV00108 IV

LEFT OUTER JOIN
       IV00101 IM
       ON IM.ITEMNMBR = IV.ITEMNMBR

LEFT OUTER JOIN
       IV00105 IC
       ON IC.ITEMNMBR = IV.ITEMNMBR
       AND IV.CURNCYID = IC.CURNCYID

<span style="color:#3366ff;">/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
GO
GRANT SELECT ON view_Inventory_Price_Levels TO DYNGRP
</span></pre>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p>If you are looking to see customer specific pricing, take a look at my <a title="SQL view to show customer pricing" href="http://victoriayudin.com/2009/01/07/sql-view-to-show-customer-pricing/" target="_self">Customer Pricing</a> post.  You can also see a full list of my Dynamics GP SQL code on the <a title="Victoria Yudin's GP Reports" href="http://victoriayudin.com/gp-reports/" target="_blank">GP Reports page</a> of this blog.</p>
<p><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/inventory-sql-code/'>Inventory SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/inventory/'>Inventory</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/2870/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/2870/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/2870/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/2870/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/2870/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/2870/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/2870/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/2870/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/2870/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/2870/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/2870/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/2870/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/2870/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/2870/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2870&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/08/09/sql-view-for-inventory-price-levels-in-dynamics-gp/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view to show yearly totals for Dynamics GP Vendors</title>
		<link>http://victoriayudin.com/2010/07/15/sql-view-to-show-yearly-totals-for-dynamics-gp-vendors/</link>
		<comments>http://victoriayudin.com/2010/07/15/sql-view-to-show-yearly-totals-for-dynamics-gp-vendors/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 15:31:21 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Payables SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Payables]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=2777</guid>
		<description><![CDATA[Below is a view that will show yearly totals for your Dynamics GP Vendors. It&#8217;s something we have used internally for a while, but I have recently gotten a few requests for it, so I cleaned it up and am sharing it. This will show yearly totals for calendar years. If you want to use fiscal years [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2777&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Below is a view that will show yearly totals for your Dynamics GP Vendors. It&#8217;s something we have used internally for a while, but I have recently gotten a few requests for it, so I cleaned it up and am sharing it.</p>
<p style="text-align:justify;">This will show yearly totals for calendar years. If you want to use fiscal years instead, change the WHERE clause on line 55 below to the following:</p>
<p><pre class="brush: plain; light: true;">
WHERE VT.HISTTYPE = 1</pre><br />
<pre class="brush: sql;">

CREATE VIEW view_Vendor_Yearly_Totals
AS

/***************************************************************
view_Vendor_Yearly_Totals
Shows totals for all AP vendors
Created Jul 15, 2010 by Victoria Yudin - Flexible Solutions, Inc.
For updates see http://victoriayudin.com/gp-reports/
Results shown for calendar months and functionaly currency.
***************************************************************/

SELECT VT.VENDORID Vendor_ID,
       VM.VENDNAME Vendor_Name,
       VM.VNDCLSID Class_ID,
       case VM.VENDSTTS
          when 1 then 'Active'
          when 2 then 'Inactive'
          when 3 then 'Temporary'
          end Vendor_Status,
       case VM.TEN99TYPE
          when 1 then 'Not a 1099 Vendor'
          when 2 then 'Dividend'
          when 3 then 'Interest'
          when 4 then 'Miscellaneous'
          end [1099_Type],
       VM.PYMTRMID Payment_Terms_ID,
       VT.YEAR1 [Year],
       sum(VT.AMBLDLIF) Amount_Billed,
       sum(VT.AMTPDLIF) Amount_Paid,
       sum(VT.TEN99ALIF) [1099_Amount],
       sum(VT.FINCHLIF) Finance_Charges,
       sum(VT.WROFSLIF) Writeoffs,
       sum(VT.RTRNSLIF) [Returns],
       sum(VT.TRDTKLIF) Trade_Discounts,
       sum(VT.DISAVLIF) Term_Discounts_Avail,
       sum(VT.DISTKNLF) Term_Discounts_Taken,
       sum(VT.DISLSTLF) Term_Discounts_Lost,
       sum(VT.Withholding_LIFE) Withholding,
       sum(VT.NOINVLIF) Num_Of_Invoices,
       sum(VT.NFNCHLIF) Num_Of_Finance_Charges,
       VM.ADDRESS1 Address_1,
       VM.ADDRESS2 Address_2,
       VM.ADDRESS3 Address_3,
       VM.CITY City,
       VM.[STATE] [State],
       VM.ZIPCODE Zip_Code,
       VM.COUNTRY Country,
       VM.TXIDNMBR Tax_ID

FROM PM00202 VT

INNER JOIN PM00200 VM
       ON VT.VENDORID = VM.VENDORID

WHERE VT.HISTTYPE = 0

GROUP BY VT.VENDORID, VM.VENDNAME, VM.VNDCLSID,
         VM.VENDSTTS, VM.TEN99TYPE, VM.PYMTRMID,
         VT.YEAR1, VM.ADDRESS1, VM.ADDRESS2,
         VM.ADDRESS3, VM.CITY, VM.[STATE],
         VM.ZIPCODE, VM.COUNTRY, VM.TXIDNMBR

/** the following will grant permissions to this view to DYNGRP, 
leave this section off if you do not want to grant permissions **/
GO
GRANT SELECT ON view_Vendor_Yearly_Totals TO DYNGRP
</pre></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/payables-sql-code/'>Payables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/payables/'>Payables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/2777/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/2777/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/2777/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/2777/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/2777/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/2777/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/2777/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/2777/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/2777/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/2777/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/2777/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/2777/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/2777/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/2777/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2777&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/07/15/sql-view-to-show-yearly-totals-for-dynamics-gp-vendors/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>Updates to SQL view to show all GL distributions for AP transactions</title>
		<link>http://victoriayudin.com/2010/06/25/updates-to-sql-view-to-show-all-gl-distributions-for-ap-transactions/</link>
		<comments>http://victoriayudin.com/2010/06/25/updates-to-sql-view-to-show-all-gl-distributions-for-ap-transactions/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 14:57:16 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GL SQL code]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[Payables SQL code]]></category>
		<category><![CDATA[General Ledger]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[Payables]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=2745</guid>
		<description><![CDATA[I have made a number of updates to my SQL view to show all GL distributions for AP transactions since I first published it. Some of these were in response to comments asking for additional fields, others were added when I came across new data to test with. Rather than publish another post with the latest revisions, I have updated the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2745&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">I have made a number of updates to my <a title="SQL view to show all GL distributions for AP transactions" href="http://victoriayudin.com/2008/11/28/sql-view-to-show-all-gl-distributions-for-ap-transactions/" target="_blank">SQL view to show all GL distributions for AP transactions</a> since I first published it. Some of these were in response to comments asking for additional fields, others were added when I came across new data to test with. Rather than publish another post with the latest revisions, I have updated the code in <a title="SQL view to show all GL distributions for AP transactions" href="http://victoriayudin.com/2008/11/28/sql-view-to-show-all-gl-distributions-for-ap-transactions/" target="_blank">my original blog post</a>, but I wanted to let everyone know it&#8217;s there. Some of the updates are:</p>
<ul type="square">
<li style="text-align:justify;padding-bottom:5px;">Added Due To and Due From distribution types for anyone using Intercompany transactions.</li>
<li style="text-align:justify;padding-bottom:5px;">Added Realized Gain and Realized Loss distribution types for Multicurrency transactions.</li>
<li style="text-align:justify;padding-bottom:5px;">Added Currency ID, Exchange Rate and Originating Debit/Credit fields.</li>
<li style="text-align:justify;padding-bottom:5px;">Added Distribution Reference, Batch ID and Transaction Description fields.</li>
<li style="text-align:justify;padding-bottom:5px;">Added Voucher Number.</li>
</ul>
<p>As always, if you find any issues or would like any additional updates, please let me know.</p>
<p style="text-align:justify;">There are also enough Payables SQL scripts that I have moved them to <a title="Dynamics GP Payables SQL views" href="http://victoriayudin.com/gp-reports/payables-sql-views/" target="_blank">their own page</a>. The page can also be accessed from the main navigation menu on this blog under GP Reports and on my <a title="Dynamics GP Reports" href="http://victoriayudin.com/gp-reports/" target="_blank">GP Reports page</a>.</p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/gl-sql-code/'>GL SQL code</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a>, <a href='http://victoriayudin.com/category/gp-reports-code/payables-sql-code/'>Payables SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/general-ledger/'>General Ledger</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/payables/'>Payables</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/2745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/2745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/2745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/2745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/2745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/2745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/2745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/2745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/2745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/2745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/2745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/2745/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/2745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/2745/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2745&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/06/25/updates-to-sql-view-to-show-all-gl-distributions-for-ap-transactions/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
		<item>
		<title>Awesome resources available from Mark Polino</title>
		<link>http://victoriayudin.com/2010/06/17/awesome-resources-available-from-mark-polino/</link>
		<comments>http://victoriayudin.com/2010/06/17/awesome-resources-available-from-mark-polino/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 10:16:05 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[GP SQL scripts]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[GP table information]]></category>
		<category><![CDATA[SQL code]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=2728</guid>
		<description><![CDATA[Mark Polino, one of the very first Dynamics GP bloggers and someone who has personally inspired me often with his writing, has done some spring cleaning on his blog. There is a ton of great content, but I would like to point out these two great resources: SQL Scripts - one location with descriptions and links for many [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2728&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;"><a href="http://victoriayudin.files.wordpress.com/2010/06/thumbsupguy.jpg"><img class="size-full wp-image-2732 alignright" title="yes!" src="http://victoriayudin.files.wordpress.com/2010/06/thumbsupguy.jpg?w=450" alt=""   /></a><a title="Mark Polino's blog" href="http://msdynamicsgp.blogspot.com/" target="_blank">Mark Polino</a>, one of the very first Dynamics GP bloggers and someone who has personally inspired me often with his writing, has done some spring cleaning on his blog. There is a ton of great content, but I would like to point out these two great resources:</p>
<ul type="square">
<li style="text-align:justify;padding-bottom:5px;"><a title="Mark Polino's SQL script list" href="http://cid-bc679914609aa946.office.live.com/view.aspx/Downloads/Dynamic%20GP%20SQL%20Scripts.xlsx?wa=wsignin1.0&amp;sa=510964649" target="_blank">SQL Scripts</a> - one location with descriptions and links for many of the SQL scripts Mark has collected.  I am very proud to say some of these are mine.  <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li style="text-align:justify;padding-bottom:5px;"><a title="GP 2010 table reference" href="http://cid-bc679914609aa946.office.live.com/view.aspx/Downloads/GP%5E_2010%5E_Table%5E_Reference.xlsx" target="_blank">The GP 2010 table reference</a> - a really handy Excel listing of all the tables in GP 2010.</li>
</ul>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-sql-scripts/'>GP SQL scripts</a> Tagged: <a href='http://victoriayudin.com/tag/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/gp-table-information/'>GP table information</a>, <a href='http://victoriayudin.com/tag/sql-code/'>SQL code</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/2728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/2728/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/2728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/2728/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/2728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/2728/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/2728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/2728/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/2728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/2728/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/2728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/2728/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/2728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/2728/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2728&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/06/17/awesome-resources-available-from-mark-polino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>

		<media:content url="http://victoriayudin.files.wordpress.com/2010/06/thumbsupguy.jpg" medium="image">
			<media:title type="html">yes!</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL view with security and SmartList details in GP</title>
		<link>http://victoriayudin.com/2010/05/13/sql-view-with-security-and-smartlist-details-in-gp/</link>
		<comments>http://victoriayudin.com/2010/05/13/sql-view-with-security-and-smartlist-details-in-gp/#comments</comments>
		<pubDate>Thu, 13 May 2010 08:27:58 +0000</pubDate>
		<dc:creator>Victoria Yudin</dc:creator>
				<category><![CDATA[Dynamics GP]]></category>
		<category><![CDATA[GP 10.0]]></category>
		<category><![CDATA[GP 2010]]></category>
		<category><![CDATA[GP Reports code]]></category>
		<category><![CDATA[System/Setup SQL code]]></category>
		<category><![CDATA[GP SQL view]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://victoriayudin.com/?p=2391</guid>
		<description><![CDATA[Robert Cavill from Emeco in Australia has sent me an amazing update to my Security Roles and Tasks in GP 10 SQL script that includes SmartList objects. I have tested this script with both GP 10.0 and GP 2010 and for both versions to get the most out of this you will want to populate the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2391&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Robert Cavill from Emeco in Australia has sent me an amazing update to my <a title="Security Roles and Tasks in GP 10" href="http://victoriayudin.com/2009/03/12/sql-view-to-show-security-roles-and-tasks-in-dynamics-gp-10/" target="_blank">Security Roles and Tasks in GP 10</a> SQL script that includes SmartList objects. I have tested this script with both GP 10.0 and GP 2010 and for both versions to get the most out of this you will want to populate the GP system resource table by following the steps below:</p>
<ol>
<li>Go to <em>Microsoft Dynamics GP &gt; Maintenance &gt; Clear Data</em></li>
<li>Click <em>Display</em> on the toolbar and choose <em>Physical</em></li>
<li>Select <em>System</em> under <em>Series</em></li>
<li>Click<em> Security Resource Descriptions</em> under <em>Tables</em> to highlight it and click <em>Insert</em> to add it to the <em>Selected Tables</em> list</li>
<li>Click <em>OK</em>, then <em>Yes</em> to the pop up message asking you if you’re sure that you want to clear data from the table</li>
<li>Send the report to the screen, it should report back with &#8220;No errors found&#8221;</li>
</ol>
<p style="text-align:justify;">The view will still work without going through the steps above, but all the resource details will be blank. Please note that the script below should be run against your DYNAMICS database.</p>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<pre>CREATE VIEW view_Security_and_SL_Details
AS
<span style="color:#888888;">/*******************************************************************
view_Security_and_SL_Details
Create this in the DYNAMICS database
Created May 13 2010 by Victoria Yudin - Flexible Solutions, Inc.
     and Robert Cavill - Emeco
For updates see http://victoriayudin.com/gp-reports/
Shows all security roles, tasks and detailed resource descriptions
     including SmartList by user by company for GP 10.0 and GP 2010
*******************************************************************/</span>

SELECT DISTINCT
   S.USERID [User_ID],
   S.CMPANYID Company_ID,
   C.CMPNYNAM Company_Name,
   S.SECURITYROLEID Security_Role_ID,
   coalesce(T.SECURITYTASKID,'') Security_Task_ID,
   coalesce(TM.SECURITYTASKNAME,'') Security_Task_Name,
   coalesce(TM.SECURITYTASKDESC,'') Security_Task_Description,
   coalesce(R.DICTID,SO.ASI_DICTID,'') Dictionary_ID,
   coalesce(R.PRODNAME,'') Product_Name,
   coalesce(R.TYPESTR,SO.ResType,'') Resource_Type,
   coalesce(R.DSPLNAME,SO.SmartlistObject,'') Resource_Display_Name,
   coalesce(R.RESTECHNAME,'') Resource_Technical_Name,
   coalesce(R.Series_Name,'') Resource_Series

FROM SY10500 S   <span style="color:#008000;">-- security assignment user role</span>

LEFT OUTER JOIN
   SY01500 C   <span style="color:#008000;">-- company master</span>
   ON S.CMPANYID = C.CMPANYID

LEFT OUTER JOIN
   SY10600 T  <span style="color:#008000;">-- tasks in roles</span>
   ON S.SECURITYROLEID = T.SECURITYROLEID 

LEFT OUTER JOIN
   SY09000 TM  <span style="color:#008000;">-- tasks master</span>
   ON T.SECURITYTASKID = TM.SECURITYTASKID 

LEFT OUTER JOIN
   SY10700 O  <span style="color:#008000;">-- operations in tasks</span>
   ON T.SECURITYTASKID = O.SECURITYTASKID 

LEFT OUTER JOIN
   SY09400 R  <span style="color:#008000;">-- resource descriptions</span>
   ON R.DICTID = O.DICTID AND O.SECRESTYPE = R.SECRESTYPE
   AND O.SECURITYID = R.SECURITYID 

LEFT OUTER JOIN  <span style="color:#008000;">-- smartlist objects</span>
   (SELECT SECURITYTASKID, SECURITYID, DICTID, SECRESTYPE,
 	ASI_DICTID, SL_OBJID, SmartlistObject,
	'Smartlist' ResType
   FROM
      (SELECT SECURITYTASKID, SECURITYID, DICTID, SECRESTYPE,
              SECURITYID / 65536 ASI_DICTID, SECURITYID % 65536 SL_OBJID
      FROM SY10700
      WHERE SECRESTYPE = 1000 AND DICTID = 1493) ST
   JOIN
      (SELECT coalesce(TRANSVAL, ASI_Favorite_Name) SmartlistObject,
              ASI_Favorite_Dict_ID, ASI_Favorite_Type
      FROM ASIEXP81  F
      LEFT JOIN
         ASITAB30 A
         ON F.ASI_Favorite_Name = A.UNTRSVAL
         AND A.Language_ID = 0
         WHERE ASI_Favorite_Save_Level = 0) SM
      ON ASI_DICTID = ASI_Favorite_Dict_ID
      AND SL_OBJID = ASI_Favorite_Type) SO
   ON SO.DICTID = O.DICTID AND O.SECRESTYPE = SO.SECRESTYPE
   AND O.SECURITYID = SO.SECURITYID

<span style="color:#3366ff;">/** the following will grant permissions to this view to DYNGRP,
leave this section off if you do not want to grant permissions **/
GO
GRANT SELECT ON view_Security_and_SL_Details TO DYNGRP</span></pre>
<p style="text-align:center;"><span style="color:#888888;">~~~~~</span></p>
<p style="text-align:justify;"><em>Disclaimer: I tested this on limited data, if you find an issue or have a suggestion for improvement, please let me know and I will post the update here for everyone.</em></p>
<p style="text-align:justify;">Thanks again to Robert for his work on this! For more SQL code and help with reporting on Dynamics GP data, please take a look at my <a title="Victoria Yudin - GP Reports" href="http://victoriayudin.com/gp-reports/" target="_blank">GP Reports</a> page.</p>
<br />Filed under: <a href='http://victoriayudin.com/category/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-100/'>GP 10.0</a>, <a href='http://victoriayudin.com/category/dynamics-gp/gp-2010/'>GP 2010</a>, <a href='http://victoriayudin.com/category/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/category/gp-reports-code/systemsetup-sql-code/'>System/Setup SQL code</a> Tagged: <a href='http://victoriayudin.com/tag/dynamics-gp/'>Dynamics GP</a>, <a href='http://victoriayudin.com/tag/gp-100/'>GP 10.0</a>, <a href='http://victoriayudin.com/tag/gp-2010/'>GP 2010</a>, <a href='http://victoriayudin.com/tag/gp-reports-code/'>GP Reports code</a>, <a href='http://victoriayudin.com/tag/gp-sql-view/'>GP SQL view</a>, <a href='http://victoriayudin.com/tag/security/'>security</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/victoriayudin.wordpress.com/2391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/victoriayudin.wordpress.com/2391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/victoriayudin.wordpress.com/2391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/victoriayudin.wordpress.com/2391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/victoriayudin.wordpress.com/2391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/victoriayudin.wordpress.com/2391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/victoriayudin.wordpress.com/2391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/victoriayudin.wordpress.com/2391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/victoriayudin.wordpress.com/2391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/victoriayudin.wordpress.com/2391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/victoriayudin.wordpress.com/2391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/victoriayudin.wordpress.com/2391/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/victoriayudin.wordpress.com/2391/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/victoriayudin.wordpress.com/2391/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=victoriayudin.com&#038;blog=4884873&#038;post=2391&#038;subd=victoriayudin&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://victoriayudin.com/2010/05/13/sql-view-with-security-and-smartlist-details-in-gp/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/17a8ce996aec3d35caf943487b6956a5?s=96&#38;d=wavatar" medium="image">
			<media:title type="html">Victoria</media:title>
		</media:content>
	</item>
	</channel>
</rss>
