Wednesday, December 18, 2019

NAV - How to use Purchase Prepayments


  • Purchases & Payables Setup - Define separate number series for posted prepayment invoices and credit notes
  • Define Prepayment Account on Gen. Posting Setup
    • Setup Gen Prod. Posting group on Prepayment GL account or you get an error when posting the purchase order
    • Setup Tax Business Posting Group on Prepayment GL account if you want the prepayment to calculate Tax 
  • Setup Prepayment % on Vendor
  • Do PO for Vendor
    • Confirm prepayment % on each line
  • Post Prepayment Invoice (Needs a vendor invoice number)
  • Pay prepayment invoice
  • Receive and Invoice PO
  • Invoice automatically deducts prepaid amount from balance
  • Pay balance of invoice

Warnings
  • When posting the Purchase Order to generate the second invoice, it will throw an error about the Vendor Invoice number. I recommend appending an R onto the end of the Vendor invoice number to indicate this invoice represents the received goods
    • Eg. Prepayment Vendor Invoice No was 2005
    • After receiving, change to 2005R, then post
Other Uses
  • This method can be used to track Goods in transit values before goods are received by setting the prepayment account to your purchases in transit account
  • Disable the "Compress Prepayment" option to get detailed lines on the prepayment invoice
  • Modify T38 Purchase Header to set default value for Compress Prepayment Initvalue = No
    • Prepayment invoice does not have correct qty or unit price, C444,T461 should be modified to include these fields in the buildbuffer

Wednesday, December 11, 2019

Devops - Tree view query does not filter correctly

Add the filters to the "Filters for linked work items" only

NAV / BC - FAQ


  • Can LS Central Do This?
    • Buy A and B. If over $100, trigger benefit
    • Q: Create a mix and match offer to trigger based on the value of the items identified in the items fast tab on the offer. Example Item A and B are identified in the Items fast tab When transaction is done if the value of item A and B purchased crosses $100 a discount or benefit is triggered. If Item A and B value does not cross $100 the offer does not trigger even if the total amount on the transaction crosses $100
    • A: No, it cannot do this out of the box. It will trigger on the total value of the transaction, regardless of if it consists of A,B or C. You cannot define "Buy $100 worth of Chocolates only to get 10% off"
  • What is the difference between a Limited User(Team User) and a Full User?
    • Limited user can enter data into most screens, but cannot post.
  •  Can Limited user do Purchase Quotes? 
    • Yes, but cannot post, only release or send for approval.
  • Does Business Central have Context Sensitive Help?
    • Pressing F1 brings up general help.
    • Your only help is in the form of hover tooltips. Hovering fetches the equivalent context sensitive help and displays it.
    • Use the arrow keys to expand the help box if it is too small.
  • Do extra windows use extra Business Central Licenses?
    • No. One named user license can open unlimited browser sessions on any number of devices at the same time.
  • Does NAV support a 13th month closing period?
    • If your financial year starts with 1st. of  July, you might use the posting date 300606C (the "C" at the end is important as it is stating a "Closing" Date. This is comparable to a "13th. month" in other accounting systems
  • Does Core NAV support barcodes?
    • Yes
    • Item>Item Identifiers
    •  Item>Cross References>Bar Code
    • These must be used 
  • What is ADCS? Can i receive at the warehouse using a mobile device?
    • Automated Data Capture
    • Telnet VT100 client that can communicate with NAV via a web service to handle basic receiving and ordering
    • Does not support bins
  • NAV Mobile App
    • What are the limitations of the NAV Mobile App?
  • Lookup
    • Affects what is displayed when using the drop-down
  • Drilldown
    • Affects what the three dots does next to a page field
  • When setting up a new POS terminal, how do i set the next transaction number?
    • Table Transaction Header 
    • Enter date/time, next transaction number, terminal, date, etc. (fill out entire record)
  • Can you connect NAV to CRM using Odata4?
    • Yes
    • https://docs.microsoft.com/en-us/dynamics-nav/walkthrough-creating-and-interacting-odata-v4-bound-action
  • LS NAV Foreign Currency Tender Rounding
    • pos transactions.payment calculates the wrong amount
    • 99001570   POSTransactionEvents.OnAfterInsertPaymentLine(REC,LineRec,CurrInput,TenderType.Code); //LS-7753
    •  uses pos func profile amount rounding to
    • PaymentAmount is getting wrong value
    • Set min change on retail currency setup to 2 cents 
  • Can NAV send out automated collection letters? (Dunning Letters?)
    • No.
    • However, you can set up Reminders which will create entries in the customer statement. The statement can be automatically emailed to customers periodically.
    • Third party module or customization required to produce mail merged letters with attached list of outstanding invoices.
  • Do i need to setup the Base LCY Currency in the Currencies table?
    • No.
    • Your Base currency should not exist in the currencies table.
    • The code used in the GL Setup will be displayed as your base currency.
  • Can you spend a specific amount of a gift card?
    • Q:
    • I have a Gift Card for $100,
    • My bill is $20
    • Can i only spend $5 from gift card, and pay the rest in cash?
    •  
    • A:
    • Yes. Gift Card will prompt for amount to use.
  • Does LS Central Support Storing Gift Cards in Multiple Currencies?
    • Yes.
    • But must convert to LCY at point of topup.
  • Does Ls Central Support Gift Card Usage across Companies?
    • No.
  • What are the limitations of Variants?
    • NAV Variants
    • Variants will work for Purchasing and Inventory
    • However, they will not work for Stock Counts, Retail Transfers, or Bin Movements.
    • You can enable the Variant columns in Transfers in the W1 under Inventory Management Setup
    • NA does not have this option.
  • LS NAV Variant Framework
    • LS Central supports Variants for transfers, but not bins
  • What causes Exchange rate Gains/Losses?
    • Unrealized Gains\Losses - Temporary Adjustments made for financial reporting, but not meant to reflect actual cash value
    • Realized  Gains\Losses - Permanent adjustments to cash value based on exchange rate
    • If an invoice is done on Day1, but is not paid until Day 10, the difference between the exchange rates from Day1 and Day10 is automatically generated as an Exchange Gain/Loss.
    • Stock Invoiced on Day1 is costed at the Day1 Rate.
    • If you need to adjust the cost of the inventory to be the actual exchange value paid on Day10, you must do a Value Entry Journal against the inventory cost layer, offsetting the Gains/Losses account
  • Does LS NAV 2018 Web POS support all functionality? On all Devices?
    • Web POS directly through web client supports all functionality on Windows Devices.
    • LS OMNI App and LS Central App have limited functionality.
  • Can LS NAV do email marketing campaigns?
    • Yes. Core NAV marketing can do mass mails based on an email template.
  • Can LS NAV Handle Layaway?
    • Business Central :- No Special Orders, Using customer Orders, Allowing multiple payments per customer order on POS.
    • NAV 2016-2018 - No Special order workaround, no layaway
    • Pre NAV 2016 - Special Orders are used as a workaround for layaway
  • Can NAV do straight line depreciation by month?
    • Yes. you must set your acquisition date to the beginning of the month.
    • You must run depreciation as at the end of the month.
    • the system will automatically use 30days
  • Can NAV e-mail Purchase Orders?
    • Yes.
    • From PO>Send Document To>Select doc Type (PDF)>Edit in Outlook, or Send from NAV E-mail screen
  • Can you reverse a Fixed Asset disposal?
    • Yes.
    • https://community.dynamics.com/nav/b/leapingfrogs/archive/2018/07/05/canceling-disposed-fixed-assets-entries-dynamics-nav
  • Does Core NAV support buy Y get X free?
    • No.
    • Dynamics Mobile does not support this either. But if using LS Retail, it will support LS retail pricing logic.
  • Can you define Lead times for transfers from a warehouse in LS Replenishment?
    • Q: When using LS Replenishment to recommend transfers from a warehouse to a store, is it possible to define lead times per item per source and destination location? 
    • A: Increase the Store Stock Cover Reqd and/or Wareh Stock Cover Reqd to include the lead time.
    • Store Stock Cover Reqd = Total days worth of stock to maintain at store (Only Affects Transfers)
    • Wareh Stock Cover Reqd = Total days worth of stock to maintain at Warehouse (Only affects Purchases)
    • Therefore, if i have 2 days lead time, i would increase my cover days by 2.
  •  Can NAV handle catchweights?
    • Q: How does NAV handle catchweights?
    • A: Lots can be used to represent boxes. Lot information fields can be added to track pieces or other box-specific data. Picks and Put aways are used to capture actual weights. Cannot over-receive, so original orders must either be slightly higher, or mod to auto-reopen and modify original sales or purchase orders.
  • How does LS Replenishment know if to purchase or transfer?
    • Q: How does replenishment know if to purchase or transfer stock from  WH to a Store?
    • A: Rules are defined per item, per destination location (Replen. Item Store List). A Purchase, or transfer journal is run from a source location,which calculates for all defined destination rules. You can only define one set of coverage days
    • A2: It does not decide on purchase or transfer. You must run the transfer journal first to transfer stock to all destinations based on the rules defined per item destination. Next, you run the purchase journal to purchase all stock for all locations based on the rules defined per item destination.
    • A3: Store coverage days can only be defined per destination, meaning you cannot have more than one supplying warehouse that may take longer to supply a store than another
  • Can LS Replenishment automatically generate PO's and Transfers?
    • Q: Can LS Replenishment automatically generate PO's and Transfers? How is this configured?
    • A: Yes. The Location, and Item must be active for automated replenishment. The Replenishment Template must be set to "Create Orders Automatically". When the nightly routine runs to calculate the replenishment quantities, PO's or TO's will be automatically generated.
  • Dynamics Mobile Route Sales
    • Sales Module Presentation: https://vimeo.com/172894961/f2b095c54a
    • Field Sales App Demo: https://vimeo.com/173479888/0b1e35f0e1
  • Can XMLPorts export joined tables to Text?
    • No. By default if an XMLport is set to export to text, it can only export a single table, or variables.
    • It is possible to use variables for all fields, and use CAL to populate each variable as required.
    • If you're going to do that, you might as well just use a codeunit to generate your file, and forget the XMLPort.
  • Where Can you use reason codes?
    • GL Journals
    • Item Journals
  • Where can you use return reason codes? (can set location, and whether it affects stock or not)
    • Sales Return Line Items
    • Purchase Return Line Items


Saturday, November 30, 2019

NAV - CAL Built-in email functions

T38.SendRecords
T60.SendToEmailVendor
T77.SendEmailtoVendorDirectly
P364.SelectSendingOptions

Wednesday, November 27, 2019

NAV CAL - Change Color


  • Create Global StyleText Text
  • Create Function UpdateStyle, Return Text
  • Update StyleText OnAfterGetRecord
OnAfterGetRecord()
StyleText := UpdateStyle;

UpdateStyle() : Text

IF "Matched Status" = 'Exact Match' THEN BEGIN
EXIT('Favorable');
END ELSE BEGIN
EXIT('Unfavorable');
END;

  • On Page Field Property StyleExpr
    • enter global StyleText



Modify(InventoryField)
        {
            StyleExpr = StyleText;
        }

    trigger OnAfterGetRecord()
    begin
        StyleText := UpdateStyle;
    end;

    procedure UpdateStyle()Text
    begin
        IF Inventory <= "Reorder Point" THEN
            EXIT('UnFavorable');
    End;

    var
        StyleText: Text[20];

LS NAV - Get Retail Item Price with discounts and promos

PROCEDURE GetItemPOSPrice@1000000004(Itm@1000000023 : Text[30]) : Decimal;
    VAR
      PT@1000000000 : Record 99008980;
      PosTerminal@1000000022 : Record 99001471;
      StoreSetup@1000000021 : Record 99001470;
      Item@1000000020 : Record 27;
      ItemVariant@1000000019 : Record 5401;
      TransLine@1000000018 : Record 99008981;
      Customer@1000000017 : Record 18;
      Staff@1000000016 : Record 99001461;
      PosFunc@1000000015 : Codeunit 99008900;
      PosPrice@1000000014 : Codeunit 99008906;
      Globals@1000000013 : Codeunit 99008919;
      gStoreNo@1000000012 : Code[10];
      gPosTerminalNo@1000000011 : Code[10];
      gReceiptNo@1000000010 : Code[20];
      gItemNo@1000000009 : Code[20];
      gQuantity@1000000008 : Decimal;
      gDescription@1000000007 : Text[100];
      gCustomerName@1000000006 : Text[50];
      gPriceInBarcode@1000000005 : Decimal;
      gCalcQty@1000000004 : Decimal;
      gStaffID@1000000003 : Code[20];
      SalesTypeBoxVisible@1000000002 : Boolean INDATASET;
      PriceGrBoxVisible@1000000001 : Boolean INDATASET;
      FinalPrice@1000000024 : Decimal;
    BEGIN
      TransLine.VALIDATE(TransLine.Number,TransLine.Number);
      gQuantity := 1;
      TransLine.VALIDATE(TransLine.Number,Itm);
      TransLine.InsertLine;

      TransLine.GET(TransLine."Receipt No.",TransLine."Line No.");

      Item.GET(TransLine.Number);
      IF Item."Qty. Becomes Negative" THEN BEGIN
        TransLine."Item/Dept. Negative" := TRUE;
        TransLine.VALIDATE(TransLine.Quantity,-gQuantity)
      END
      ELSE
        TransLine.VALIDATE(TransLine.Quantity,gQuantity);
      IF TransLine."Price in Barcode" AND (gQuantity = gCalcQty) THEN
        TransLine.VALIDATE(TransLine.Amount,gPriceInBarcode);


      PosFunc.ChangeVATBusOnLine(PT);
      PosFunc.RecalcSlip(PT);

      EXIT(FinalPrice);
    END;

Tuesday, November 26, 2019

Microsoft Surface - Charging light on charger is blinking or unlit


NAV/BC - Limit Item Master visibility by using user permissions


  • By default, user has no access to anything
    • Each permission rule will only add more permissions
    • No rule will explicitly deny, unless you are using a filter
    • If any rule explicitly gives permission, the user will have permission
  • Permissions
    • Filter On Item Table
      • Ideally, a single role should be created specifically for limiting each user group to a specific division
      • Existing item fields can be used, or a custom field added specifically to manage the Division that can view the item
    • Must create your own SUPER and Foundation and Basic permission sets that do not include the item table you are trying to filter on, otherwise the allow rule will take precedence
      • any item table rule without an item division filter will allow all records

Friday, November 8, 2019

NAV BC - Limited User vs Full User

Limited user can enter data into most screens, but cannot post.

Can Limited user do Purchase Quotes? Yes, but cannot post, only release or send for approval.
Can Limited user do Sales Quotes? Yes, but cannot post, only release or send for approval.


Can Limited user to journal entries? Yes, but cannot post, only release or send for approval.

Thursday, November 7, 2019

NAV - Custom On Lookup Dropdown

Simple lookup filter

field(Barcode; Barcode)

                {

                    ApplicationArea = All;

                    Lookup = true;

                    TableRelation = "LSC Barcodes"."Barcode No." WHERE("Item No."=field(Item));

}

OR
*Restart instance after making this modification.

On Page, Set Lookup = Yes

Name DataType Subtype Length
WRL Record Posted Whse. Receipt Lines
RecList Page Posted Whse. Receipt List
FromDate Date
ToDate Date
LPS Record Label Printing Setup


IF LPS.FINDFIRST THEN BEGIN
  FromDate := CALCDATE('-'+FORMAT(LPS."Show Receipts in Range"),TODAY);
  ToDate := CALCDATE(FORMAT(LPS."Show Receipts in Range"),TODAY);
END;
WRL.RESET;
WRL.CALCFIELDS("PO Type Code");
WRL.SETRANGE("PO Type Code",POTypeCode);
CLEAR(RecList);
RecList.SETRECORD(WRL);
RecList.SETTABLEVIEW(WRL);
RecList.LOOKUPMODE(TRUE);
  IF RecList.RUNMODAL = ACTION::LookupOK THEN BEGIN
    RecList.GETRECORD(WRL);
     VALIDATE(Receipt,WRL."No.");
  END;


field("Production Order"; "Production Order")
            {
                ApplicationArea = All;
                lookup = True;
                trigger OnLookup(var TextText)Boolean
                var
                    Prdord: record "Production Order";
                    RecList: page "Production Order List";
                    FromDate: date;
                    ToDate: Date;

                begin
                    FromDate := CALCDATE('-' + FORMAT('30D'), TODAY);
                    ToDate := CALCDATE(FORMAT('30D'), TODAY);
                    //Prdord.setrange("Starting Date",fromdate,ToDate);

                    CLEAR(RecList);
                    RecList.SETRECORD(Prdord);
                    RecList.SETTABLEVIEW(PrdOrd);
                    RecList.LOOKUPMODE(TRUE);
                    IF RecList.RUNMODAL = ACTION::LookupOK THEN BEGIN
                        RecList.GETRECORD(PrdOrd);
                        VALIDATE("Production Order", Prdord."No.");
                    END;
                end;

Tuesday, November 5, 2019

NAV CAL - How to calculate to and from range from a dateformula

  FromDate := CALCDATE('-'+FORMAT(LPS."Dateformula"),TODAY);
  ToDate := CALCDATE(FORMAT(LPS."Dateformula"),TODAY);

Friday, November 1, 2019

Dynamics NAV - Purchase Discounts


  1. Customize screen to allow manual amount for discount
  2. Manually split discount over each line
    1. Enter amount on each line item in line discount amount
  3. Enter GL line to inventory account or discounts account as a negative value

NAV Intercompany - Bank Transfers

You cannot do a direct intercompany transfer from one bank account to another.

However, you can do a direct intercompany to the bank g/l account, but doing so will not display the transfer on your bank rec.


  • One way to deal with this is to create a suspense account for the intercompany money transfer.
  • Company 1
    • GL Journal
      • Bank to transfer suspense
    • IC Journal
      • Line1 IC Partner
      • Line2 transfer suspense, IC Acc No = transfer suspense
      • Post and send
  • Company 2
    • Receive and process
    • GL Journal
      • transfer suspense to Bank

Thursday, October 31, 2019

Dynamics NAV - Recurring Methods


  • Fixed
    • Amount does not change after posting
    • The value is split based on the rules set in the Allocations page in the Allocations button
  • Variable
    • Amount is reset to 0 after posting
    • You need to manually re-enter a new value after every posting
    • The value is split based on the rules set in the Allocations page in the Allocations button
  • Balance
    • Journals the balance of the account
    • The value is split based on the rules set in the Allocations page in the Allocations button
  • Reversing Fixed
    • Same as Fixed, but reversal entry is also automatically posted to the next day after posting date
  • Reversing Variable
    • Same as Variable, but reversal entry is also automatically posted to the next day after posting date
  • Reversing Balance
    • Same as Balance, but reversal entry is also automatically posted to the next day after posting date

Document Description Formulas

  • %1 – The current day number
  • %2 – The current week number
  • %3 – The current month number
  • %4 – The current month name
  • %5 – The current accounting period name
  • Eg. RENT-%4

Date Formulas
  • CM+1D first of next month

Dynamics NAV - How to reconcile Inventory to GL

https://www.archerpoint.com/blog/Posts/inventory-general-ledger-reconciliation-microsoft-dynamics-nav

https://dynamics-consultants.co.uk/blog/posts/2017/june/reconciling-inventory-in-microsoft-dynamics-nav/



Wednesday, October 30, 2019

NAV-Configuration Package Import Error-Posting date must have a value in Gen. Journal line: Journal template = GENERAL, Journal batch = XXX, Line number = 10000. The field cannot be zero or empty.

It looks like the TESTFIELD command on the Posting Date field causes this error.

The true cause of this error is a bad configuration package.
Redo the configuration package in the current version of BC/NAV.

Dynamics NAV / Business Central - What happens to assigned charge items if the original received quantity is partially returned?


  • Scenario
    • 100 items are purchased for $1 each
      • Vendor Invoice is for $100
    • duty item charge of $1 is added
      • Customs Invoice is for $100
      • Cut a cheque and pay customs to clear container
    • Final Landed Cost
      • $200
    • Upon opening the container, we find 20 items damaged
    • We contact the vendor, and he gives us a credit for $20
  • Problem
    • We cannot request a credit from Customs for the $20 duty we have paid on the damaged items
    • The $20 value is still sitting in our inventory account
  • Solution
    • Pass a manual journal to move the value from Inventory to Damages/Writeoffs, (but not applied to any specific line item, as this will affect existing item costs)
      • Debit Inv $20
      • Credit Damages/Writeoffs $20
    • Add original po,receipt,credit numbers as reference on journal

Tuesday, October 29, 2019

Dynamics NAV / Business Central - How to post Duties for Landed Costs before receiving goods at warehouse

https://www.navug.com/communities/community-home/digestviewer/viewthread?MessageKey=a0bc75aa-84ab-40e2-8e2a-afcc6d4946ed&CommunityKey=95503735-5a0b-4af1-8326-9bd7bb3b4d3d&tab=digestviewer



  • Create a "DOCK" location to represent stock that has not arrived at your warehouse as yet
  • "DOCK" location is connected to your Goods in transit account
  • "WH" location should be set to require receive
  • All PO's are done to the DOCK location
  • Container Lands on dock
    • Post PO>Receive and Invoice
    • PO is received to the "DOCK" location
    • This immediately receives stock, and generates the invoice for the full amount
    • PO is closed and removed
    • If you are using lot or serial tracking, this will only work if you are aware of the lot and serial information in advance. Any differences would need to be handled as stock count adjustments after completing the full receiving process at the WH.
  • Landed Costs are entered and applied to the received PO lines
  • Transfer order is prepared
    • Tick Direct Transfer to default the Qty. to Ship and Qty. to Receive
    • Actions>Functions>Get Receipt Lines>Clear Location Filter
    • Add all lines from the receipt to a transfer order
    • Transfer order is updated with actual dates when container is picked up from the DOCK and delivered to the warehouse
    • Any additional charges can added on the transfer as well if required, but for simplicity all charges should have been applied after the initial receiving if possible
    • When goods arrive at warehouse 
      • Unstuff container and count goods received
      • On Transfer order, Adjust Qty. to Ship to actual count 
      • Post Transfer
      • Overs
        • Additional lines need to be added to the original PO, Received and transferred to WH
        • OR Adjusted into stock in a separate transaction as a stock count variance
      • Shortages
        • Any shortages will be left in the DOCK location
        • Reopen and delete the transfer order
        • Purchase Return>New>Enter Vendor>Process>Get Posted doc Lines to Reverse>Select PO Lines
        • By default, the remaining quantity in DOCK will be entered on the return line
        • Enter Return Reason code "Shortage"
        • Process>Apply entries (If this should be applied immediately)
        • Post>Ship and Invoice
Otherwise, if you are not keen on the idea of receiving stock to a dock location
  • You must receive the goods first, then apply landed costs
  • You can create the separate landed cost invoices beforehand, but you cannot apply or post them until after the goods are received.
Transfer process details

Friday, October 25, 2019

eOne Smartconnect - Calculate current Year for Batch Name

Create calculated field

IF _CREDITHOLD > "0" THEN
 return  "CREDITHOLD"
ELSE return "ORDER " + Convert.ToString(fn.YEAR(_RECEIVEDDATE))
END IF

Thursday, October 24, 2019

Tuesday, October 22, 2019

Business Central - Payables in a currency different from the Bank Currency

Leave the Bank Payment Type blank.
If you choose Manual or Computer check, it will force the transaction to be the same currency as the bank account

Wednesday, October 16, 2019

DEVOPS Excel Integration Add-In

Link to download Integration to Excel:
https://visualstudio.microsoft.com/downloads/

  1. At bottom of screen, Browse to Other Tools and frameworks
  2. Look for Azure Devops Office Integration 2019

Further instructions can be found here:
https://docs.microsoft.com/en-us/azure/devops/boards/backlogs/office/bulk-add-modify-work-items-excel?view=azure-devops

Dynamics GP - SOP Lot Qty and Attributes View

/****** Object:  View [dbo].[BI_SOP_LotAttr]    Script Date: 16/10/2019 09:40:44 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[BI_SOP_LotAttr]
AS
SELECT     dbo.SOP10201.SOPTYPE, dbo.SOP10201.SOPNUMBE, dbo.SOP10201.LNITMSEQ, dbo.SOP10201.CMPNTSEQ, dbo.SOP10201.QTYTYPE, dbo.SOP10201.SERLTNUM, dbo.SOP10201.SERLTQTY, dbo.SOP10201.SLTSQNUM, dbo.SOP10201.DATERECD,
                  dbo.SOP10201.DTSEQNUM, dbo.SOP10201.UNITCOST, dbo.SOP10201.ITEMNMBR, dbo.SOP10201.TRXSORCE, dbo.SOP10201.POSTED, dbo.SOP10201.OVRSERLT, dbo.SOP10201.BIN, dbo.SOP10201.MFGDATE, dbo.SOP10201.EXPNDATE,
                  dbo.SOP10201.DEX_ROW_ID, dbo.IV00301.ITEMNMBR AS Expr1, dbo.IV00301.LOTNUMBR, dbo.IV00301.LOTATRB1, dbo.IV00301.LOTATRB2, dbo.IV00301.LOTATRB3, dbo.IV00301.LOTATRB4 AS BestBefore, dbo.IV00301.LOTATRB5,
                  dbo.IV00300.MFGDATE AS Manufactured, dbo.IV00300.EXPNDATE AS Expiry, dbo.IV00300.DATERECD AS Received
FROM        dbo.SOP10201 INNER JOIN
                  dbo.SOP10200 ON dbo.SOP10201.SOPTYPE = dbo.SOP10200.SOPTYPE AND dbo.SOP10201.SOPNUMBE = dbo.SOP10200.SOPNUMBE AND dbo.SOP10201.LNITMSEQ = dbo.SOP10200.LNITMSEQ AND
                  dbo.SOP10201.CMPNTSEQ = dbo.SOP10200.CMPNTSEQ LEFT OUTER JOIN
                  dbo.IV00300 ON dbo.SOP10201.ITEMNMBR = dbo.IV00300.ITEMNMBR AND dbo.SOP10201.SERLTNUM = dbo.IV00300.LOTNUMBR AND dbo.SOP10200.LOCNCODE = dbo.IV00300.LOCNCODE LEFT OUTER JOIN

                  dbo.IV00301 ON dbo.SOP10201.SERLTNUM = dbo.IV00301.LOTNUMBR AND dbo.SOP10201.ITEMNMBR = dbo.IV00301.ITEMNMBR

GO

/****** Object:  View [dbo].[BI_SOP_BulkPick_Lots]    Script Date: 16/10/2019 09:41:13 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[BI_SOP_BulkPick_Lots]
AS
SELECT     PHolds.SOPNUMBE AS IsPHold, dbo.SOP10200.SOPTYPE, dbo.SOP10200.SOPNUMBE, dbo.SOP10100.ORIGTYPE, dbo.SOP10100.ORIGNUMB, dbo.SOP10100.DOCID, dbo.SOP10100.DOCDATE, dbo.SOP10100.GLPOSTDT, dbo.SOP10100.ReqShipDate,
                  dbo.SOP10100.CUSTNMBR, dbo.SOP10100.CUSTNAME, dbo.SOP10100.CSTPONBR, dbo.SOP10200.ITEMNMBR, dbo.SOP10200.ITEMDESC, dbo.SOP10200.UOFM, dbo.SOP10200.LOCNCODE, dbo.SOP10200.UNITCOST, dbo.SOP10200.UNITPRCE,
                  dbo.SOP10200.XTNDPRCE, ISNULL(dbo.BI_SOP_LotAttr.SERLTQTY, dbo.SOP10200.QUANTITY) AS QUANTITY, dbo.SOP10200.ATYALLOC, dbo.SOP10200.QTYBSUOM, dbo.SOP10200.SALSTERR, dbo.SOP10200.SLPRSNID, RTRIM(dbo.SOP10200.SOPNUMBE)
                  + ' | ' + CAST(dbo.SOP10100.DOCDATE AS varchar) + ' | ' + RTRIM(dbo.SOP10100.CUSTNMBR) + ' ' + RTRIM(dbo.SOP10100.ShipToName) + ' | ' + RTRIM(dbo.SOP10200.ADDRESS1) + RTRIM(dbo.SOP10200.ADDRESS2) + RTRIM(dbo.SOP10200.ADDRESS3)
                  + RTRIM(dbo.SOP10200.CITY) AS SOPLbl, dbo.SOP10100.PCKSLPNO, dbo.SOP10100.PICTICNU, dbo.SOP10100.ShipToName, dbo.SOP10100.ADDRESS1, dbo.SOP10100.ADDRESS2, dbo.SOP10100.ADDRESS3, dbo.SOP10100.CITY,
                  RTRIM(dbo.SOP10200.ADDRESS1) + RTRIM(dbo.SOP10200.ADDRESS2) + RTRIM(dbo.SOP10200.ADDRESS3) + RTRIM(dbo.SOP10200.CITY) AS FullAdd, ISNULL(dbo.BI_SOP_LotAttr.SERLTQTY, dbo.SOP10200.QTYTOINV) AS QTYTOINV, dbo.RM00101.HOLD,
                  dbo.IV00101.ITEMSHWT, dbo.BI_SOP_LotAttr.BestBefore, dbo.BI_SOP_LotAttr.SERLTQTY
FROM        dbo.IV00101 INNER JOIN
                  dbo.SOP10200 INNER JOIN
                  dbo.SOP10100 ON dbo.SOP10200.SOPTYPE = dbo.SOP10100.SOPTYPE AND dbo.SOP10200.SOPNUMBE = dbo.SOP10100.SOPNUMBE INNER JOIN
                  dbo.RM00101 ON dbo.SOP10100.CUSTNMBR = dbo.RM00101.CUSTNMBR ON dbo.IV00101.ITEMNMBR = dbo.SOP10200.ITEMNMBR LEFT OUTER JOIN
                  dbo.BI_SOP_LotAttr ON dbo.SOP10200.CMPNTSEQ = dbo.BI_SOP_LotAttr.CMPNTSEQ AND dbo.SOP10200.ITEMNMBR = dbo.BI_SOP_LotAttr.ITEMNMBR AND dbo.SOP10200.SOPTYPE = dbo.BI_SOP_LotAttr.SOPTYPE AND
                  dbo.SOP10200.SOPNUMBE = dbo.BI_SOP_LotAttr.SOPNUMBE AND dbo.SOP10200.LNITMSEQ = dbo.BI_SOP_LotAttr.LNITMSEQ LEFT OUTER JOIN
                      (SELECT DISTINCT SOPNUMBE
                       FROM        dbo.SOP10104
                       WHERE     (DELETE1 = 0)) AS PHolds ON dbo.SOP10100.SOPNUMBE = PHolds.SOPNUMBE
WHERE     (dbo.SOP10200.SOPTYPE = 2) AND (dbo.SOP10100.PICTICNU > '0') AND (PHolds.SOPNUMBE IS NULL)

GO


Friday, October 11, 2019

Dynamics GP - The stored procedure create SQLTmpTable returned the following results: DBMS:2627

Issue:
Users experience this issue for a single customer or vendor when opening the inquiry screen

Cause:
There are duplicate records across your work and posted tables.

Resolution:
Review all of the connected tables and records for the specific customer/vendor that is giving this issue

Refer to this article for duplicate checking scripts
http://cowmasterscorner.blogspot.com/2018/02/dynamics-gp-error-occurred-when.html

LS NAV - Only allow Managers to process certain member club cards


o   T99009000 - Add Req. Mgr. Login Boolean
o   P99009000 - Add Req. Mgr. Login Boolean
o   P99009001 - Add Req. Mgr. Login Boolean
o   C99001570
§  InputMemberCard> MemberClub_g
·        If MgrKey=False, then Errorbeep
o   X10032992
§  MemberClub- Add field for Req. Mgr Login
o   T99009643
§  GetMemberInfoForPos
§  Click Publisher & subscriber to reload web requests
·        Updates Request and Response with Req. Mgr Login field

NAV CAL - Boolean Yes / No vs True / False

Boolean type can accept Yes/No and True/False values.
However, if Yes/No is used, it must be explicitly called.

Eg.

This Works
----------------------------------
BooleanTest := True

If BooleanTest THEN
 Message ('true!');
----------------------------------

This does not work
----------------------------------
BooleanTest := Yes

If BooleanTest THEN
 Message ('true!');
-----------------------------------

This works
----------------------------------
BooleanTest := Yes

If BooleanTest = TRUE THEN
 Message ('true!');
-----------------------------------

Wednesday, October 9, 2019

Dynamics NAV - How to update an AL extension

https://cloudblogs.microsoft.com/dynamics365/no-audience/2018/01/16/generate-symbols-in-a-modern-development-environment-with-microsoft-dynamics-nav-2018/

Ensure the following are ticked on your instance
  •  Development>Enable Developer Service Endpoint
  • Odata Services>Enable Odata Services
Run This in CMD

  • Open the CMD in administrator mode. Navigate to the Role Tailored Client folder (CD Path to folder). Run the following command
  • cd 'C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\140\RoleTailored Client'
  • .\finsql.exe Command=generatesymbolreference, Database=MYDB, ServerName=[Sql server/Instance]
  • Go to Task Manager>Details to see if it's running. It silent, and takes about 15 minutes.
  • If you get any errors with the next scripts, the finsql is still running
Run this in Powershell
  • Uninstall-NAVApp -ServerInstance YourDynamicsNAVServer -Name 'App Name'
  • UnPublish-NAVApp -ServerInstance YourDynamicsNAVServer -Name 'App Name'
  • Publish-NAVApp -ServerInstance YourDynamicsNAVServer -Path ".\MyExtension.app" -SkipVerification
  • Sync-NAVApp -ServerInstance YourDynamicsNAVServer -Name 'App Name'
  • Install-NAVApp -ServerInstance YourDynamicsNAVServer -Name 'App Name'

example


Publish-NAVApp -ServerInstance UAT -Path 'C:\Mods\Module_1.0.0.0\Module_1.0.0.0.app' -SkipVerification



Sync-NAVApp -ServerInstance UAT -Name ‘Module’



Install-NAVApp -ServerInstance UAT -Name ‘Module’


Dynamics GP - Item Lot Quantity SQL View

IV00300 - Item Lot quantities
IV00301 - Lot Attributes


/****** Object:  View [dbo].[BI_ItemLotQty]    Script Date: 09/10/2019 12:01:05 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

ALTER VIEW [dbo].[BI_ItemLotQty]
AS
SELECT     dbo.IV00300.ITEMNMBR, dbo.IV00300.LOCNCODE, SUM(dbo.IV00300.QTYRECVD - dbo.IV00300.QTYSOLD) AS LotQtyOnHnd, SUM(dbo.IV00300.ATYALLOC) AS LotQtyAllocated, dbo.IV00101.ITMTRKOP,
                  SUM(dbo.IV00300.QTYRECVD - dbo.IV00300.QTYSOLD - dbo.IV00300.ATYALLOC) AS LotQtyAvlbl, dbo.IV00101.USCATVLS_2 AS Category, dbo.IV00101.CURRCOST, SUM(dbo.IV00300.QTYRECVD - dbo.IV00300.QTYSOLD * dbo.IV00101.CURRCOST) AS CostOnHand,
                  dbo.IV00101.ITEMDESC, CASE WHEN iv00101.itmclscd LIKE '%fg%' THEN 'Finished Goods' ELSE 'Other' END AS FGOTH, dbo.IV00301.LOTNUMBR, dbo.IV00301.LOTATRB1, dbo.IV00301.LOTATRB2, dbo.IV00301.LOTATRB3, dbo.IV00301.LOTATRB4 AS BestBefore,
                  dbo.IV00301.LOTATRB5, dbo.IV00300.DATERECD AS Received, dbo.IV00300.MFGDATE AS Manufactured, dbo.IV00300.EXPNDATE AS Expiry
FROM        dbo.IV00101 INNER JOIN
                  dbo.IV00300 ON dbo.IV00101.ITEMNMBR = dbo.IV00300.ITEMNMBR LEFT OUTER JOIN
                  dbo.IV00301 ON dbo.IV00300.LOTNUMBR = dbo.IV00301.LOTNUMBR AND dbo.IV00300.ITEMNMBR = dbo.IV00301.ITEMNMBR
GROUP BY dbo.IV00300.ITEMNMBR, dbo.IV00300.LOCNCODE, dbo.IV00101.ITMTRKOP, dbo.IV00101.USCATVLS_2, dbo.IV00101.CURRCOST, dbo.IV00101.ITEMDESC, dbo.IV00301.LOTNUMBR, dbo.IV00301.LOTATRB1, dbo.IV00301.LOTATRB2, dbo.IV00301.LOTATRB3,
                  dbo.IV00301.LOTATRB4, dbo.IV00301.LOTATRB5, dbo.IV00300.DATERECD, dbo.IV00300.MFGDATE, dbo.IV00300.EXPNDATE, CASE WHEN iv00101.itmclscd LIKE '%fg%' THEN 'Finished Goods' ELSE 'Other' END
HAVING     (dbo.IV00101.ITMTRKOP = 3) AND (dbo.IV00300.LOCNCODE > '') AND (SUM(dbo.IV00300.QTYRECVD - dbo.IV00300.QTYSOLD) <> 0)

GO


Sunday, September 29, 2019

Dynamics GP - GP crashes when VBA mods are present when trying to send e-mail using Office 365 Outlook ProPlus after version 1808

https://community.dynamics.com/gp/b/dynamicsgp/posts/dynamics-gp-crashes-closes-when-emailing-after-office-update

Office ProPlus versions
https://www.msoutlook.info/question/200
https://docs.microsoft.com/en-us/officeupdates/update-history-office365-proplus-by-date

Version Numbers
Outlook 978.0
Outlook 988.5
Outlook 20009.0
Outlook XP/200210.0
Outlook 200311.0
Outlook 200712.0
Outlook 201014.0
Outlook 201315.0
Outlook 201616.0
Outlook 201916.0
Office 36516.0
Original Method
https://superuser.com/questions/1380385/how-to-downgrade-office-365





  • Download the Office Deployment Tool.

    • Install and extract it to a ODT folder in Desktop. It contains two files: Setup.exe and Configuration.xml.
    • Open Configuration.xml file, edit it with the following text, then save it as a new file RevertOffice.xml in the same folder of Setup.exe:
    • <Configuration> <Updates Enabled="TRUE" TargetVersion="16.0.10730.20380" /> </Configuration>
      1. In Windows, click Start, search for cmd, right-click Command Prompt, click Run as Administrator.
      2. Switch to the file location for the Setup.exe file. For example, type cd C:\Users\Administrator\Desktop\ODT
      3. Run the following command: setup.exe /configure RevertOffice.xml
      4. Start Word 2016, go to File > Account, under Product Information, click Update Options > Update Now.
      5. Check if the Office is reverted to your targeted version.
      6. Disable Office Update to avoid it update to higher version: In Word 2016, click File > Account, under Product Information, click Update Options > Disable Updates.
    Note: Even after doing the downgrade, there will be no visible indication that outlook has been downgraded.
    Simply try to send your e-mail from GP and see if that works.

    Thursday, September 26, 2019

    NAV-"There is no value entry in the filter" after posting sales invoice or any inventory transaction


    • Review Item Ledger Entries, 
    • Confirm that each item ledger entry has a corresponding value entry
    • If not, you must insert a value entry for the appropriate item ledger entry that is missing a line

    Monday, September 23, 2019

    GP - A get/change operation on table 'ivexceptiondays' failed accessing sql data. Conversion failed when converting date and/or time from character string.

    SQL Profiler shows an error like this

    exec TWO.dbo.zDP_IV41001SS_1 '-4714.11.25'

    SELECT TOP 25 EXCEPTIONDATE,DATETYPE,DEX_ROW_ID FROM TWO.dbo.IV41001 WHERE EXCEPTIONDATE = '-4714.11.25' ORDER BY EXCEPTIONDATE ASC

    Most likely this stock count was imported, or marked as verified using an sql script or some external method that did not set the Countdate and counttime on the stock count lines.

    Run these scripts to set a proper date and time, update with the values you need. Add filters if you have a specific count only.

    update iv10301 set countdate = '2019-09-23 00:00:00.000'
    update iv10301 set counttime = '1900-01-01 06:51:16.000'

    Saturday, September 21, 2019

    NAV - Service Orders vs Service Contracts


    • Service Orders 
      • Used to record costs, labor, parts, inventory, fees associated with repairing a Service Item
      • Eg. Repairing a Photo Copier
      • Can be connected to a service contract, but is informational only. Does not affect the Service Contract Cost or Value in any way.
      • Posting a service order can occur in three stages, ship, invoice, consume
      • An invoice appears on the customer's AR as any other invoice
    • Service contracts
      • Used to record the monthly cost and selling price of a Service Item to a customer
      • Only Items with a type of "Inventory"
      • You cannot use items with a type of service or non-inventory
      • Can be for a specific Service Item with a serial number, or a generic item
      • Eg. Monthly rental of a photo copier

    NAV - Service Items vs Item Type Service


    • Items with the item type "Service" do not track inventory and can be used on purchase and sales orders.
      • They CANNOT be used one Service contracts
      • They do not generate Item Ledger Entries
    • Service Items represent a piece of equipment at a customer's location, or under contract for a customer
      • It can also be a generic item not assigned to any specific customer

    Saturday, September 14, 2019

    Wednesday, September 11, 2019

    Business Central - Hide or show tax based on currency code on Sales Invoice


    • Currency Code does not exist on sales invoice as a field (silly)
    • We must use the TotalInclVatText field which includes the currency code
    • Insert row inside the list detail group
    • copy and paste the tax details tablix into this row
    • Set the row visibility formula to hide or show the entire row because the tablix does not respond to visibility code as it cannot "see" the value of the TotalInclVAtText field
      • =IIf(InStr(Max(Fields!TotalInclVATText.Value), "USD") > 0, False, True)

    Check SQL version and Server Version

    SELECT @@version

    Tuesday, September 10, 2019

    Dynamics GP - Remove all VBA from GP

    find all *.vba files in the gp folder
    Delete all vba files.

    Dynamics GP - How to setup Quick Printing

    http://dynamicsgpblogster.blogspot.com/2009/05/wonders-of-ctrlq-saving-and-printing.html

    Allows you to define Invoice, Picking Ticket and Packing Slip to print all at once

    Sales Transaction Entry>Quick Print Setup
    Press Crtl+Q to quick print

    Dynamics GP - AR Trial Balance - Add additional buckets


    • You must modify all of these reports to give the customer a full experience
      • RM Detail Historical Aged Trial Balance
      • RM Summary Historical Aged Trial Balance 
      • If using the Options Report (I usually don't, because the Historical has everything i need)
        • RM Detail Aged Trial Balance - Options
        • RM Summary Aged Trial Balance - Options
      • If using Multicurrency
        • MC RM Detail Historical Aged Trial Balance
        • MC RM Summary Historical Aged Trial Balance
    • How to modify
      • Remove Discount Taken
      • Add Description
      • Pull all balance fields left until in line with doc type
      • Add Calc Legend 5
      • Add Calc Period Amount 5
      • Width 69
      • Height 8
      • Helvetica Generic
      • Font Size 7
      • Bold on headers and footers
      • Right align on legend labels
      • Backcolor none
      • Underline footer
      • Formatfield: Calc-Func/Rept Index
      • Doc and Body Visibility: Hide when empty

    Friday, September 6, 2019

    Dynamics GP - Modifier and VBA Visual Basic ODBC connection- Update multiple fields on navigation


    • Before starting, ensure you check this
    • Tools > References > Check the checkbox in front of "Microsoft ActiveX Data Objects 2.5 Library"

    '---------------------------------------------------------------------------------------------------

    Option Explicit




    Private Function GetCurrCost() As String

        Dim cn As New ADODB.Connection

        Dim rst As New ADODB.Recordset

        Dim cmd As New ADODB.Command

        Dim SqlStr As String
        Dim TheCost As Currency, ThePrice As Currency
     



        On Error GoTo GetCurrCost_Err



        'Retrieve an ADO connection for the current user

        Set cn = UserInfoGet.CreateADOConnection()



        'Set the connection properties

        cn.CursorLocation = adUseClient



        'Set the current database, using the IntercompanyID property

        cn.DefaultDatabase = UserInfoGet.IntercompanyID



        SqlStr = ""

        'Create a command to select result

        cmd.ActiveConnection = cn

        cmd.CommandType = adCmdText

        'Get Current Cost
        SqlStr = " select top 1 CURRCOST from dbo.IV00101 where ITEMNMBR = '" + ItemNumber + "'"

        cmd.CommandText = SqlStr

        Set rst = cmd.Execute



        'Display the rows retrieved

    '    MsgBox ">>" + rst!ResultText

        TheCost = rst!CURRCOST

     '--------------------------------------------------------------------
        'Get BasePrice
        SqlStr = " select top 1 Price from dbo.BI_ExtPrc_BasePrices where ITEMNMBR = '" + ItemNumber
        SqlStr = SqlStr + "' and UofM = '" + BaseUofM + "'"

        cmd.CommandText = SqlStr

        Set rst = cmd.Execute
        ThePrice = rst!Price
     
    'Close connection
        cn.Close
     
    'Write results
        StringM18 = TheCost
        StringM17 = ThePrice

    Exit Function



    GetCurrCost_Err:



        Select Case Err.Number

        Case 91

            'Object variable or With block variable not set (Error 91)

            'MsgBox "Error 91:" + Str(Err.Number) + "<" + Err.Description + ">"

            Resume

        Case Else

            'MsgBox "Unknown Error:" + Str(Err.Number) + "<" + Err.Description + ">"

            Exit Function

        End Select



    End Function

    Private Function GetBasePrice() As String

        Dim cn As New ADODB.Connection

        Dim rst As New ADODB.Recordset

        Dim cmd As New ADODB.Command

        Dim SqlStr



        On Error GoTo GetBasePrice_Err



        'Retrieve an ADO connection for the current user

        Set cn = UserInfoGet.CreateADOConnection()



        'Set the connection properties

        cn.CursorLocation = adUseClient



        'Set the current database, using the IntercompanyID property

        cn.DefaultDatabase = UserInfoGet.IntercompanyID



        SqlStr = ""

        '--------------------------------------------------------------------
        'Get BasePrice
        SqlStr = " select top 1 Price from dbo.BI_ExtPrc_BasePrices where (ITEMNMBR = '" + ItemNumber
        SqlStr = SqlStr + "') and UofM = ('" + BaseUofM + "')"

        cmd.CommandText = SqlStr

        Set rst = cmd.Execute



        'Display the rows retrieved

    '    MsgBox ">>" + rst!ResultText

        StringM17 = rst!Price


        'Close the connection

        cn.Close

    Exit Function



    GetBasePrice_Err:



        Select Case Err.Number

        Case 91

            'Object variable or With block variable not set (Error 91)

            'MsgBox "Error 91:" + Str(Err.Number) + "<" + Err.Description + ">"

            Resume

        Case Else

            'MsgBox "Unknown Error:" + Str(Err.Number) + "<" + Err.Description + ">"

            Exit Function

        End Select
    End Function


    Private Function GETRunningUser(ByVal request As String) As String

        Dim UserInfoObj As UserInfo



        Dim CompanyName As String

        Dim IntercompanyID As String

        Dim SystemDatabase As String

        Dim UserDate As Date

        Dim UserID As String

        Dim UserName As String



        'Get the UserInfo object

        Set UserInfoObj = VbaGlobal.UserInfoGet()



        'Retrieve and display the UserInfo

        Select Case request

           Case "CompanyName"

                GETRunningUser = UserInfoObj.CompanyName

           Case "IntercompanyID"

                GETRunningUser = UserInfoObj.IntercompanyID

           Case "SystemDatabaseName"

                GETRunningUser = UserInfoObj.SystemDatabaseName

           Case "UserDate"

                GETRunningUser = UserInfoObj.UserDate

           Case "UserID"

                GETRunningUser = UserInfoObj.UserID

           Case "UserName"

                GETRunningUser = UserInfoObj.UserName

          Case Else

                GETRunningUser = ""

        End Select



    End Function
    Private Sub UpdateScreen()
    StringM17 = 0
    StringM18 = 0
    If ItemNumber > "" Then
        GetCurrCost
    End If
    End Sub

    Private Sub EndofFileButtonToolbar_AfterUserChanged()
    UpdateScreen
    End Sub

    Private Sub ItemNumber_Changed()
    UpdateScreen
    End Sub

    Private Sub NextButtonToolbar_AfterUserChanged()
    UpdateScreen
    End Sub

    Private Sub PreviousButtonToolbar_AfterUserChanged()
    UpdateScreen
    End Sub
    Private Sub TopofFileButtonToolbar_AfterUserChanged()
    UpdateScreen
    End Sub
    Private Sub Window_BeforeOpen(OpenVisible As Boolean)

    End Sub

    Thursday, September 5, 2019

    GP Views - Fiscal Period Map

    /****** Object:  View [dbo].[BI_FYPeriods]    Script Date: 9/5/2019 3:54:04 PM ******/
    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER ON
    GO

    CREATE VIEW [dbo].[BI_FYPeriods]
    AS
    SELECT DISTINCT PERIODID AS FPeriod, YEAR(PERIODDT) AS PYr, MONTH(PERIODDT) AS PMth, YEAR1 AS FYr, RIGHT('00' + CAST(MONTH(PERIODDT) AS varchar), 2) AS PMth0
    FROM            dbo.SY40100
    WHERE        (PERIODID > 0)
    GO

    GP AUDIT View - All SOP documents with incorrect expected VAT

    SELECT SOPLines.sopnumbe, 
           SOPLines.itemnmbr, 
           SOPLines.itemdesc, 
           SOPLines.itmtshid, 
           SOPLines.xtndprce, 
           SOPLines.taxamnt, 
           SOPLines.docdate, 
           SOPLines.custnmbr, 
           SOPLines.custname, 
           SOPLines.posted, 
           tx00201.txdtlpct, 
           SOPLines.calctaxpc, 
           SOPLines.calctaxpc - tx00201.txdtlpct AS TaxDiff, 
           SOPLines.docid, 
           SOPLines.soptype, 
           SOPLines.cstponbr, 
           SOPLines.orignumb, 
           SOPLines.prbtadcd                     AS BillToAddress, 
           SOPLines.prstadcd                     AS ShipToAddress, 
           SOPLines.taxschid                     AS AddressTaxSchedule 
    FROM   (SELECT sop10200.sopnumbe, 
                   sop10200.itemnmbr, 
                   sop10200.itemdesc, 
                   sop10200.itmtshid, 
                   sop10200.xtndprce, 
                   sop10200.taxamnt, 
                   sop10100.docdate, 
                   sop10100.custnmbr, 
                   sop10100.custname, 
                   'Unposted' AS Posted, 
                   CASE 
                     WHEN xtndprce <> 0 THEN Round(( sop10200.taxamnt / xtndprce ) * 
                                                   100, 2 
                                             ) 
                     ELSE 0 
                   END        AS CalcTaxPC, 
                   sop10100.docid, 
                   sop10200.soptype, 
                   sop10100.cstponbr, 
                   sop10100.orignumb, 
                   sop10100.prbtadcd, 
                   sop10200.prstadcd, 
                   sop10200.taxschid 
            FROM   sop10200 
                   INNER JOIN sop10100 
                           ON sop10200.soptype = sop10100.soptype 
                              AND sop10200.sopnumbe = sop10100.sopnumbe 
            WHERE  ( sop10200.soptype IN ( 3, 4 ) ) 
            UNION 
            SELECT sop30300.sopnumbe, 
                   sop30300.itemnmbr, 
                   sop30300.itemdesc, 
                   sop30300.itmtshid, 
                   sop30300.xtndprce, 
                   sop30300.taxamnt, 
                   sop30200.docdate, 
                   sop30200.custnmbr, 
                   sop30200.custname, 
                   'Posted' AS Posted, 
                   CASE 
                     WHEN xtndprce <> 0 THEN Round(( sop30300.taxamnt / xtndprce ) * 
                                                   100, 2 
                                             ) 
                     ELSE 0 
                   END      AS CalcTaxpc, 
                   sop30200.docid, 
                   sop30300.soptype, 
                   sop30200.cstponbr, 
                   sop30200.orignumb, 
                   sop30200.prbtadcd, 
                   sop30300.prstadcd, 
                   sop30300.taxschid 
            FROM   sop30300 
                   INNER JOIN sop30200 
                           ON sop30300.soptype = sop30200.soptype 
                              AND sop30300.sopnumbe = sop30200.sopnumbe 
            WHERE  ( sop30300.soptype IN ( 3, 4 ) )) AS SOPLines 
           LEFT OUTER JOIN tx00201 
                        ON SOPLines.itmtshid = tx00201.taxdtlid 
    WHERE  ( NOT ( SOPLines.calctaxpc - tx00201.txdtlpct BETWEEN -0.05 AND 0.05 ) )