Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Excise Rate

Posted on by Microsoft Employee

Good day

Let me give a background of what I am currently doing in terms of getting to the excise rate

I have joined the item , item unit of measure , location and Excise Rate tables. Below is the script how I have done it , I have also attached my result below. For each item it has a location code , with its different unit rate for starting dates 2013 ,2014, 2015, 2016 as you can see in my result. so for each item it is 4 location codes for the 4 starting dates. I have extracted the data into one table 'Transfer Excise Tbl. Now I need to join this table to the Value Entry table based on the following. The join to the value entry table will be joined on Item no and location code. The filter I am specifying is Posting Date >= Starting Date , but I do not get the same result, see second screenshot and my second script that joins the value entry table with the transfer excise Tbl. I would like to expect the same result as my first screen. I also need to write the script in a way that it updates the unit rate automatically , so when the unit rates change in Navision the SQL script will automatically update the data. So that I do not have to hardcode it

SELECT DISTINCT a.[No_], b.[Excise Location], b.[Code] AS [Location Code], c.[Starting Date], c.[Unit Rate], c.[Excise Type Code], d.[Code] AS [Unit Of Measure Code],
                d.[Qty_ per Unit of Measure] AS [Litre Conversion Factor]
    INTO [dbo].[Transfer Excise Tbl]
    FROM [Spier Live$Item] a, [Spier Live$Location] b, [Spier Live$Excise Rate] c, [Spier Live$Item Unit of Measure] d
    WHERE a.[Excise Type] = c.[Excise Type Code]
    AND a.[No_] = d.[Item No_]
	AND b.[Excise Location] = 'NONBOND'	
	AND d.[Code] = 'LITRES'
	
	 
GROUP BY
          a.[No_], b.[Excise Location], b.[Code],
          c.[Starting Date], c.[Unit Rate], c.[Excise Type Code],
          d.[Qty_ per Unit of Measure], d.[Code],b.[Code]
GO

First-Result.JPG

--a = Value Entry Table 
--b = Transfer Excise Tbl
SELECT  DISTINCT a.[Item No_], a.[Location Code], a.[Invoiced Quantity], b.[Starting Date],
	             a.[Posting Date], b.[Unit Rate], b.[Litre Conversion Factor], 
				 b.[Excise Type Code], b.[Unit Of Measure Code]
				
                 FROM  [Spier Live$Value Entry] a, [Transfer Excise Tbl] b
                 WHERE b.[No_] = a.[Item No_]
                 AND a.[Gen_ Bus_ Posting Group] IN ('LOCA','EXSA')
                 AND a.[Location Code] = b.[Location Code]
				 AND a.[Posting Date] >= b.[Starting Date]
				 and a.[Item No_] = '600011266'
							
                 GROUP BY a.[Item No_], a.[Location Code], a.[Invoiced Quantity], 
                          b.[Starting Date], a.[Posting Date], b.[Unit Rate], 
			              b.[Litre Conversion Factor], b.[Excise Type Code], b.[Unit Of Measure Code]

                              HAVING COUNT (*) >=1
Second-Result.JPG



*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Excise Rate

    Hi Hope you well

    My Transfer Excise Tbl and Value entry table is below , I am joining the value entry table with transfer excise table on , Item No_ = No_ , Location code = Location code,  [Gen_ Bus_ Posting Group] IN ('LOCA','EXSA')

    and posting date >= starting date. when I do this I get duplicates , however if you see the data in my excise Tbl , after joining both tables I still expect the result to be as the result in my excise table , how can this be achieved

    Value Entry Table

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Excise Rate

    if the data is correct I need to have the correct dates for each unit rate , like 28-02-2016 to 26-02-2014 that is the date range for the first unit rate, then it start again at 27-02-2014 to 25-02-2015 for the second rate
    see screenshot of the NAV excise rate table

    this is my code

    SELECT DISTINCT a.[Item No_], a.[Location Code], a.[Invoiced Quantity], b.[Starting Date],
    	   MAX(a.[Posting Date]), b.[Unit Rate], b.[Litre Conversion Factor], 
    	   b.[Excise Type Code], b.[Unit Of Measure Code]
           
    
    FROM   [Spier Live$Value Entry] a
           LEFT OUTER JOIN [Transfer Excise Tbl] b
    
           ON b.[No_] = a.[Item No_]
           AND a.[Gen_ Bus_ Posting Group] IN ('LOCA','EXSA')
           AND a.[Location Code] = b.[Location Code]
    	   AND a.[Posting Date] >= b.[Starting Date]
           GROUP  BY a.[Item No_], a.[Location Code], a.[Invoiced Quantity], 
                     b.[Starting Date], a.[Posting Date], b.[Unit Rate], 
    			     b.[Litre Conversion Factor], b.[Excise Type Code], b.[Unit Of Measure Code]


     Please note if I join the value entry table to my transfer excise table the dates must not duplicate it must give me the exact rows for each unit rate. You will notice that for every year there is a new unite rate , starting from 2013-2016 , and every time some enters a new rate in NAV the code must automatically detects the data in NAV

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Excise Rate

    Are you getting item wise, location wise, date wise duplicate records?

    Can you attach ur query n result here?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Excise Rate

    I tried to use sum(Invoiced Quantity) but I still get duplicates

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Excise Rate

    Currently I am getting duplicate items per location code when joining to the value entry table , I will try an sum the Invoiced quantity now and see what result  I get.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Excise Rate

    You need to sum the Invoiced Quantity, as you might have multiple item records in Value Entry Table.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans