SQL Scripts for Microsoft Dynamics GP: Sales by Customer By Year

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posting the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script returns a list of sales in the last five years summarised by customer:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
SELECT ['RM Customer MSTR'].CUSTNMBR AS CustomerNumber ,['RM Customer MSTR'].CUSTNAME AS CustomerName ,['RM Customer MSTR'].CUSTCLAS AS CustomerClass ,['RM_Class_MSTR'].CLASDSCR AS CustomerClassDescription ,ISNULL(['RM Salesperson Master'].SLPRSNID, '* No Salesperson *') AS CustomerSalesperson ,RTRIM(LTRIM(RTRIM(ISNULL(['RM Salesperson Master'].SLPRSNFN, '')) + ' ' + ISNULL(['RM Salesperson Master'].SPRSNSLN, ''))) AS CustomerSalesPersonName ,SUM(CASE WHEN YEAR(['Sales Data'].DOCDATE) = YEAR(GETDATE()) THEN SLSAMNT ELSE 0 END) AS SalesYear0 ,SUM(CASE WHEN YEAR(['Sales Data'].DOCDATE) = YEAR(GETDATE()) -1 THEN SLSAMNT ELSE 0 END) AS [SalesYear-1] ,SUM(CASE WHEN YEAR(['Sales Data'].DOCDATE) = YEAR(GETDATE()) -2 THEN SLSAMNT ELSE 0 END) AS [SalesYear-2] ,SUM(CASE WHEN YEAR(['Sales Data'].DOCDATE) = YEAR(GETDATE()) -3 THEN SLSAMNT ELSE 0 END) AS [SalesYear-3] ,SUM(CASE WHEN YEAR(['Sales Data'].DOCDATE) = YEAR(GETDATE()) -4 THEN SLSAMNT ELSE 0 END) AS [SalesYear-4] FROM ( SELECT CUSTNMBR ,DOCNUMBR ,RMDTYPAL ,DOCDATE ,GLPOSTDT ,CASE WHEN RMDTYPAL < 7 THEN SLSAMNT ELSE SLSAMNT * -1 END AS SLSAMNT FROM RM20101 [sqlgreen]--[gptl=RM20101][/sqlgreen] WHERE RMDTYPAL <> 9 AND VOIDSTTS = 0 UNION ALL SELECT CUSTNMBR , DOCNUMBR , RMDTYPAL , DOCDATE , GLPOSTDT ,CASE WHEN RMDTYPAL < 7 THEN SLSAMNT ELSE SLSAMNT * -1 END AS SLSAMNT FROM RM30101 [sqlgreen]--[gptl=RM30101][/sqlgreen] WHERE RMDTYPAL <> 9 AND VOIDSTTS = 0 ) AS ['Sales Data'] INNER JOIN RM00101 ['RM Customer MSTR'] --RM Customer MSTR (RM00101) ON ['Sales Data'].CUSTNMBR = ['RM Customer MSTR'].CUSTNMBR LEFT OUTER JOIN RM00301 AS ['RM Salesperson Master'] --RM Salesperson Master (RM00301) ON ['RM Customer MSTR'].SLPRSNID = ['RM Salesperson Master'].SLPRSNID LEFT OUTER JOIN RM00201 AS ['RM_Class_MSTR'] --RM_Class_MSTR (RM00201) ON ['RM Customer MSTR'].CUSTCLAS = ['RM_Class_MSTR'].CLASSID GROUP BY ['RM Customer MSTR'].CUSTNMBR ,['RM Customer MSTR'].CUSTNAME ,['RM Customer MSTR'].CUSTCLAS ,['RM Salesperson Master'].SLPRSNID ,['RM Salesperson Master'].SLPRSNFN ,['RM Salesperson Master'].SPRSNSLN ,['RM_Class_MSTR'].CLASDSCR GO

Click to show/hide the SQL Scripts for Microsoft Dynamics GP Series Index

In Microsoft Dynamics 365 Business Central (Inventory and Warehouse Management), how do I… Setup Inventory for Locations

Microsoft Dynamics 365 Business CentralThis post is part of the In Microsoft Dynamics 365 Business Central (Inventory and Warehouse Management), how do I… series and of the wider In Microsoft Dynamics 365 Business Central, how do I… series which I am posting as I familiarise myself with Microsoft Dynamics 365 Business Central.

There is only one setting required for the use of locations in Business Central. That is to make the locations mandatory; this is a very important step to do if you have even a single location defined in Business Central. If locations are not mandatory, then users can process stock related transactions without selecting a location for the goods, which can result in unexpected behaviour. Goods processed in this way will show as being at an unspecified location

If you have been processing in Business central without locations mandatory, you will need to do some transfers of goods from the unspecified location to an actual location before you make locations mandatory.

To make locations mandatory, do a search in the Tell me what you want to do for Inventory Setup; toggle the Location Mandatory option on:

Inventory Setup

With this option enabled, all stock processing will now require a site to be selected.

In Microsoft Dynamics 365 Business Central, how do I…

In Microsoft Dynamics 365 Business Central (Inventory and Warehouse Management), how do I…

SQL Scripts for Microsoft Dynamics GP: Extract GL Period Balances

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posting the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script was put together a while ago for a client who was migrating from Dynamics GP to another ERP system.

There are three sections to the script.

Firstly, a table is created in the DYNAMICS database into which data from all company databases will be populated:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
CREATE TABLE GLPeriodBalances ( INTERID VARCHAR(100), ACTINDX VARCHAR(100), ACTNUMST VARCHAR(100), YEAR1 VARCHAR(100), PERIODID VARCHAR(100), LEDGERID VARCHAR(100), PERDBLNC VARCHAR(100), ACTNUMBR_1 VARCHAR(100), ACTNUMBR_2 VARCHAR(100), ACTNUMBR_3 VARCHAR(100), ACCATNUM VARCHAR(100), DEBITAMT VARCHAR(100), CRDTAMNT VARCHAR(100) ) GO

Secondly, a script which can be run in each company database to populate the extract table in the DYNAMICS database:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
INSERT INTO DYNAMICS..GLPeriodBalances ( INTERID ,ACTINDX ,ACTNUMST ,YEAR1 ,PERIODID ,LEDGERID ,PERDBLNC ,ACTNUMBR_1 ,ACTNUMBR_2 ,ACTNUMBR_3 ,ACCATNUM ,DEBITAMT ,CRDTAMNT ) SELECT DB_NAME(), ['GL Period Balance'].ACTINDX ,['Account Index Master'].ACTNUMST ,['GL Period Balance'].YEAR1 ,['GL Period Balance'].PERIODID ,['GL Period Balance'].LEDGER_ID ,['GL Period Balance'].PERDBLNC ,['Account Index Master'].ACTNUMBR_1 ,['Account Index Master'].ACTNUMBR_2 ,['Account Index Master'].ACTNUMBR_3 ,['GL Period Balance'].ACCATNUM ,['GL Period Balance'].DEBITAMT ,['GL Period Balance'].CRDTAMNT FROM GL00105 AS ['Account Index Master'] --Account Index Master (GL00105) INNER JOIN GL10110 AS ['GL Period Balance'] --Account Current Summary Master (GL10110) ON ['Account Index Master'].ACTINDX = ['GL Period Balance'].ACTINDX GO

Thirdly, the script which is used to select data from the extract table in the DYNAMICS database:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
SELECT * FROM DYNAMICS..GLPeriodBalances GO

Click to show/hide the SQL Scripts for Microsoft Dynamics GP Series Index

Use uBlock Filters to Hide Sections of A Website (such as Twitter)

Vivaldi BrowserThere are a few websites which display content, I don’t want to see and I’ve been looking for a way to block it. I am a user of the Vivaldi browser, which is Chromium based. The browser supports all of the extensions in the Google Play Store, which includes the uBlock Origin ad-blocker.

As well as doing traditional ad-blocking, the extension also allows you to block arbitrary elements of the site. In the caes of Twitter, I want to hide the Bookmarks and Verified tabs on the navigation pane:

Twitter sidebar

Continue reading “Use uBlock Filters to Hide Sections of A Website (such as Twitter)”

SQL Scripts for Microsoft Dynamics GP: View to Return List of Payments and Linked Invoices

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posting the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script creates a SQL view which returns a list of payments and the invoices linked to them.

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
CREATE VIEW uv_AZRCRV_InvoicesLinkedToPayments AS SELECT ['Payment Batch'].BACHNUMB AS 'Batch ID' ,['Payment Batch'].DOCDATE AS 'Payment Date' ,['Payment Batch'].DOCNUMBR As 'Cheque Number' ,['PM Transactions'].VCHRNMBR ,['PM Transactions'].VENDORID ,['PM Creditor Master'].VENDNAME ,CASE WHEN ['PM Transactions'].DOCTYPE = 1 THEN 'Invoice' WHEN ['PM Transactions'].DOCTYPE = 5 THEN 'Credit Note' WHEN ['PM Transactions'].DOCTYPE = 6 THEN 'Payment' END AS DOCTYPE ,['PM Transactions'].DOCDATE ,['PM Transactions'].VALUE ,['PM Transactions'].MODIFDT ,['PM Transactions'].PSTGDATE ,['PM Transactions'].POSTEDDT ,['Account Index Master'].ACTNUMST ,['Account Master'].ACTDESCR FROM PM30200 AS ['Payment Batch'] WITH (NOLOCK) --PM Paid Transaction History File (PM30200) INNER JOIN PM10201 AS ['Remittance'] WITH (NOLOCK) --PM Payment Apply To Work File (PM10201) ON ['Payment Batch'].VCHRNMBR = ['Remittance'].PMNTNMBR INNER JOIN (SELECT ['PM Transaction Open'].VCHRNMBR ,['PM Transaction Open'].VENDORID ,['PM Distribution Work Open'].DSTINDX ,['PM Transaction Open'].DOCTYPE ,['PM Transaction Open'].DOCDATE ,CASE WHEN ['PM Distribution Work Open'].CRDTAMNT > 0 THEN ['PM Distribution Work Open'].CRDTAMNT * -1 ELSE ['PM Distribution Work Open'].DEBITAMT END AS 'Value' ,['PM Transaction Open'].MODIFDT ,['PM Transaction Open'].PSTGDATE ,['PM Transaction Open'].POSTEDDT FROM PM20000 AS ['PM Transaction Open'] WITH (NOLOCK) --PM Transaction OPEN File (PM20000) INNER JOIN PM10100 AS ['PM Distribution Work Open'] WITH (NOLOCK) --PM Distribution WORK OPEN (PM10100) ON ['PM Distribution Work Open'].VCHRNMBR = ['PM Transaction Open'].VCHRNMBR AND ['PM Distribution Work Open'].CNTRLTYP = ['PM Transaction Open'].CNTRLTYP UNION ALL SELECT ['PM Transaction History'].VCHRNMBR ,['PM Transaction History'].VENDORID ,['PM Distribution Hist'].DSTINDX ,['PM Transaction History'].DOCTYPE ,['PM Transaction History'].DOCDATE ,CASE WHEN ['PM Distribution Hist'].CRDTAMNT > 0 THEN ['PM Distribution Hist'].CRDTAMNT * -1 ELSE ['PM Distribution Hist'].DEBITAMT END AS 'Value' ,['PM Transaction History'].MODIFDT ,['PM Transaction History'].PSTGDATE ,['PM Transaction History'].POSTEDDT FROM PM30200 AS ['PM Transaction History'] WITH (NOLOCK) INNER JOIN PM30600 AS ['PM Distribution Hist'] WITH (NOLOCK) --PM Distribution History File (PM30600) ON ['PM Distribution Hist'].VCHRNMBR = ['PM Transaction History'].VCHRNMBR AND ['PM Distribution Hist'].DOCTYPE = ['PM Transaction History'].DOCTYPE ) AS ['PM Transactions'] ON ['PM Transactions'].VCHRNMBR = ['Remittance'].VCHRNMBR AND ['PM Transactions'].DOCTYPE = ['Remittance'].DOCTYPE INNER JOIN GL00105 AS ['Account Index Master'] WITH (NOLOCK) --Account Index Master (GL00105) ON ['Account Index Master'].ACTINDX = ['PM Transactions'].DSTINDX INNER JOIN GL00100 AS ['Account Master'] WITH (NOLOCK) --Breakdown Account Master (GL00100) ON ['Account Master'].ACTINDX = ['Account Index Master'].ACTINDX INNER JOIN PM00200 AS ['PM Creditor Master'] WITH (NOLOCK) --PM Vendor Master File (PM00200) ON ['PM Creditor Master'].VENDORID = ['PM Transactions'].VENDORID GO GRANT SELECT ON uv_AZRCRV_InvoicesLinkedToPayments TO DYNGRP GO

Click to show/hide the SQL Scripts for Microsoft Dynamics GP Series Index

Installing Microsoft Dynamics 365 Business Central 2023 Wave 1 On-premise Demo

Microsoft Dynamics 365 Business CentralBack in August of last year, I did a short series of articles on installing the Microsoft Dynamics 365 Business Central 2022 Wave 1 demo. In April, 2023 Wave 1 was released; I’ve decided to install a new on-premise demo environment using this version, which will allow me to use that demo/test environment when traveling if I don’t have an Internet connection.

The environment I am using is a similar one as I used for the 2022 Wave 1 demo series; there is a VM and client server, both running Windows Server 2022 Standard.

You can download Dynamics BC 2023 Wave 1 here.

Once you’ve downloaded the installation media and extracted the files, launch the setup.exe installation routine in the root directory and click Next on the welcome page:

Welcome to the Microsoft Dynamics Business Central Setup

Continue reading “Installing Microsoft Dynamics 365 Business Central 2023 Wave 1 On-premise Demo”

ClassicPress Plugins Available From azurecurve | Development in 2023: Shortcodes in Comments

ClassicPressIn this series of articles, I am going to introduce each of the plugins I have developed for ClassicPress, a hard-fork of WordPress, which was originally created to provide an alternative, yet compatible, CMS without the Gutenberg block editor.

The 38th plugin is Shortcodes in Comments.

Shortcodes in Comments v1.2.4 Released

Shortcodes
Allows shortcodes to be used in comments.

This plugin is multisite compatible; each site can independently define the shortcodes which can be used.

Continue reading “ClassicPress Plugins Available From azurecurve | Development in 2023: Shortcodes in Comments”

ClassicPress Plugins Available From azurecurve | Development in 2023: Series Index

ClassicPressIn this series of articles, I am going to introduce each of the plugins I have developed for ClassicPress, a hard-fork of WordPress, which was originally created to provide an alternative, yet compatible, CMS without the Gutenberg block editor.

The 37th plugin is Series Index.

Series Index
Displays Index of Series Posts using series-index shortcode. This plugin is multi-site compatible and integrates with the Toggle Show/Hide plugin from azurecurve. The shortcode can be used on posts and pages; the format of the index and other options are user configurable through an admin page.

Two custom fields (Series and Series Position) need to be added to each post in the series; these fields are used for selecting the posts and ordering them when the index is displayed; series index post should be Series Position of 0 (this is used for determining the link for the title).

Shortcode [series-index] is placed in the post where you want the index.

Shortcode [series-index-link] can be used in a post a link back to the series index (Series Position = 0) post using the series title as the link text; [series-index-link]alternative text[/series-index-link] to display text different to the series title. title attribute can be used to create link to other series index post; e.g. [series-index-link title='Implementing Jet Reports' /].

This plugin is multisite compatible; each site will need settings to be configured in the admin dashboard.

Continue reading “ClassicPress Plugins Available From azurecurve | Development in 2023: Series Index”

SQL Scripts for Microsoft Dynamics GP: Delete Orphaned Vendor EFT Details

Microsoft Dynamics GPThis script is part of the SQL Scripts for Microsoft Dynamics GP where I will be posting the scripts I wrote against Microsoft Dynamics GP over the 19 years before I stopped working with Dynamics GP.

This script will delete the orphaned vendor EFT details left over after a vendor record has been deleted, which was due to a but in Dynamics GP (which may be fixed by now).

I’ve previously posted about a SQL trigger to delete the EFT when the vendor card is deleted, but that wouldn’t remove existing orphaned records which this script will do.

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
DELETE ['Address Electronic Transfer Funds Master'] FROM SY06000 AS ['Address Electronic Transfer Funds Master'] --Address Electronic Funds Transfer Master (SY06000) LEFT JOIN PM00300 AS ['PM Creditor Address Master'] --PM Address MSTR (PM00300) ON ['PM Creditor Address Master'].VENDORID = ['Address Electronic Transfer Funds Master'].VENDORID AND ['PM Creditor Address Master'].ADRSCODE = ['Address Electronic Transfer Funds Master'].ADRSCODE WHERE ['PM Creditor Address Master'].VENDORID IS NULL

Click to show/hide the SQL Scripts for Microsoft Dynamics GP Series Index

In Microsoft Dynamics 365 Business Central (Inventory and Warehouse Management), how do I… Understand Locations

Microsoft Dynamics 365 Business CentralThis post is part of the In Microsoft Dynamics 365 Business Central (Inventory and Warehouse Management), how do I… series and of the wider In Microsoft Dynamics 365 Business Central, how do I… series which I am posting as I familiarise myself with Microsoft Dynamics 365 Business Central.

Locations in Business Central are physical or virtual places where inventory items are stored or tracked within your organization. Enabling the multiple locations feature allows you to manage and track inventory across different storage sites, such as warehouses, stores, or distribution centres.

Location cards represent each specific location in Business Central and contains information such as the location code, description, address, contact details, and any specific settings related to the location; multiple locations can be created for each physical or virtual storage site.

Enabling locations allows the tracking of inventory quantities and movements at a granular level, allowing monitoring of the availability and stock levels of each item in each location separately, helping you manage inventory more effectively.

Even taking into account the above, locations are not mandatory and you can use inventory in Business Central without them. The absence of locations simplifies the setup and configuration process and it can be suitable for businesses with relatively straightforward inventory management needs or those operating from a single location.

However, I still generally recommend to clients who only have one site or relatively simple inventory requirements, that they create at least one location and make locations mandatory. Across the last twenty years I have dealt with a few clients who originally said they don’t have any stock locations as such and don’t need to track by location, who, over time, had changing requirements and did then create more than one location.

If they’d started off with no locations, they’d have had to enable and create locations and then change their processes, including additional training for users; by having locations from the start, their processes already included the location and all they had to do was create an additional location and start transacting in it.

In Microsoft Dynamics 365 Business Central, how do I…

In Microsoft Dynamics 365 Business Central (Inventory and Warehouse Management), how do I…