VAT REPORT BASED ON CURRENT LOGGED IN USER

Hi Guys,
I am Working for a client and it they are having 9 branches and for each branch there will be  divided by different Series and different Tax Codes and  they want a  TAX Report based on the User Logged in.Each User Will be Assigned a branch and in the tax code an UDF(Location) has been created and for each tax code location has been entered there.
So when User 1 of Branch 1 is running the report then the report should show only the record of that particular Branch 1 and
     When User 2 of Branch 2 is running the Report then it should show only branch 2 records .
I Tired using an FMS to record the Current User Logged in but i am unable to include this in the below query.
SELECT T0.U_NAME FROM OUSR T0 WHERE INTERNAL_K = $[USER]
In the Below query , the Report needs to be filtered automatically based on the Current user Logged in(User who is running the report).
There will be different Branches and Each Branch has One O Two Licenses and whenever the User1 Of Branch 1  runs the report then the report should display only the record related to that particular branch within the given date range.
So ,to differentiate the Tax codes for each Branches we have created an UDF(Location) in tax codes and enter the branch name in the UDF and also each branch will have 3 different document series and each series.
Instead of Giving the Location as a Parameter to choose we need to filter the report by the User logged in .
SELECT distinct  M.DocNum AS 'AR Inv. #', M.DocDate as 'Date',
l.targettype AS 'TARGET TYPE',
t4.series,T4.SeriesName,
case when T4.SeriesName='LOC/HOF' then 'HEAD OFFICE'
       when T4.SeriesName='LOC/CHN' then 'CHENNAI'
        when t4.seriesName ='INS/CHN' THEN 'CHENNAI'
        WHEN T4.SERIESNAME ='STF/CHN' THEN 'CHENNAI'
        WHEN T4.SERIESNAME ='INS/HOF' THEN 'HEAD OFFICE'
       end Location,L.TAXCODE,T6.RATE,
case when t.statype ='1' then  'VAT'
       WHEN T.STATYPE ='4' THEN 'CST'
       END TAXTYPE,T.STATYPE,
M.CARDCODE,M.CardName as 'Customer Name',M.NumAtCard as 'Bill No. & Dt.',M.DiscSum,M.RoundDif,
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',M.VATSUM,
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry and statype =1  ) as 'VAT  SALES',
(SELECT SUM(TaxSum) FROM INV4 t where t.docentry=m.docentry and statype=1  ) as '  VAT COLLECTED ',
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry and statype =4  ) as 'CST  SALES',
(SELECT SUM(TaxSum) FROM INV4 where statype=4 and  DocEntry=M.DocEntry   ) as ' CST COLLECTED ',
(Select Sum(LineTotal) FROM INV3 Q Where Q.DocEntry=M.DocEntry) as 'FREIGHT',
M.DocTotal as 'Total (Rs.)'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry
LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
INNER JOIN NNM1 T4 ON M.SERIES=T4.SERIES
LEFT JOIN OSTC T6 ON T6.CODE= L.TAXCODE
LEFT JOIN OUBR T7 ON  T7.NAME = T6.U_LOC
LEFT JOIN OUSR T8 ON T8.BRANCH = T7.CODE
WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]')
AND  TARGETTYPE !='14' and taxrate !='0'  A
ND T6.RATE != '0'
and t6.u_loc ='[%2]'
GROUP BY
M.DocNum,M.DocDate,M.CARDCODE,M.CardName,M.NumAtCard,M.DocEntry,
M.DiscSum,M.WTSum,
M.DocTotal,M.Series,T4.SeriesName,
T4.REMARK,M.RoundDif,M.VATSUM,T.STATYPE,T.TAXRATE,Q.LINETOTAL,t4.series,
l.targettype,t.docentry,L.TAXCODE,T6.RATE
Pls Gimme Some Ideas guys for designing this report .
Thanks And Regards,
P.V

Hai Gordon,
Thanks for the suggestion but i am sorry to say that after adding the said  Condition  to the below query it is showing the Below error.
QUERY :
SELECT distinct  M.DocNum AS 'AR Inv. #', M.DocDate as 'Date',
l.targettype AS 'TARGET TYPE',
t4.series,T4.SeriesName,
case when T4.SeriesName='LOC/HOF' then 'HEAD OFFICE'
       when T4.SeriesName='LOC/CHN' then 'CHENNAI'
        when t4.seriesName ='INS/CHN' THEN 'CHENNAI'
        WHEN T4.SERIESNAME ='STF/CHN' THEN 'CHENNAI'
        WHEN T4.SERIESNAME ='INS/HOF' THEN 'HEAD OFFICE'
       end Location,L.TAXCODE,T6.RATE,
case when t.statype ='1' then  'VAT'
       WHEN T.STATYPE ='4' THEN 'CST'
       END TAXTYPE,T.STATYPE,
M.CARDCODE,M.CardName as 'Customer Name',M.NumAtCard as 'Bill No. & Dt.',M.DiscSum,M.RoundDif,
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',M.VATSUM,
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry and statype =1  ) as 'VAT  SALES',
(SELECT SUM(TaxSum) FROM INV4 t where t.docentry=m.docentry and statype=1  ) as '  VAT COLLECTED ',
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry and statype =4  ) as 'CST  SALES',
(SELECT SUM(TaxSum) FROM INV4 where statype=4 and  DocEntry=M.DocEntry   ) as ' CST COLLECTED ',
(Select Sum(LineTotal) FROM INV3 Q Where Q.DocEntry=M.DocEntry) as 'FREIGHT',
M.DocTotal as 'Total (Rs.)'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry
LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
INNER JOIN NNM1 T4 ON M.SERIES=T4.SERIES
LEFT JOIN OSTC T6 ON T6.CODE= L.TAXCODE
LEFT JOIN OUBR T7 ON  T7.NAME = T6.U_LOC
LEFT JOIN OUSR T8 ON T8.BRANCH = T7.CODE
WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]')
AND  TARGETTYPE !='14' and taxrate !='0'  AND T6.RATE != '0'
AND $[USER] in (SELECT USERID FROM OUSR WHERE BRANCH = T7.CODE)
GROUP BY
M.DocNum,M.DocDate,M.CARDCODE,M.CardName,M.NumAtCard,M.DocEntry,
M.DiscSum,M.WTSum,
M.DocTotal,M.Series,T4.SeriesName,
T4.REMARK,M.RoundDif,M.VATSUM,T.STATYPE,T.TAXRATE,Q.LINETOTAL,t4.series,
l.targettype,t.docentry,L.TAXCODE,T6.RATE
ERROR
1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near 'USER'.
2). [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword 'GROUP'.
3). [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement 'User-Defined Values' (CSHS) (s) could not be prepared.
Regards,
P.V

Similar Messages

  • How to get current logged-in user name in data access driver or in universe

    In universe, to get the current log in user is via @Variable('BOUSER').
    Right now, I need to be able to get the user name in the data access driver. I am writing a customized data access driver because we need to patch some where clause on the the query generated by the universe based on the logged-in user info. I only think of using end_sql parameter or adding an universe level filter to patch the @Variable('BOUSER') to the query, which would not work if user want to use customized query.
    Can anyone tell me how to get currentBO user name from connection server ? or how @Variable('BOUSER') is translated into the logged-in user name in the universe?

    I do not know your EJB Service. But you should pass the credentials of the current logged on portal user to your service. That's not by default I think.
    I had a similar problem with CAF developed webservices. I had to turn on permission checks in my web service and passed the credentials via logon ticket.
    Regards, Bernd

  • Query or Profile Option to find Current logged in user in oracle apps R12

    Query or Profile Option to find Current logged in user in oracle apps R12.
    I want to get value of current user who is logged in to that particular session, based on the value of user_id or user_name returned i have to do a Forms Personalization.
    Plz help.
    Regards,
    Sadiya P.

    Hi Sadiya,
    do you have the answer for this? please send it to me because i am also have same requirement. so plz post it here....

  • Current logged in user in PCM

    Hi,
    Is there anyway I can access the current logged in user details in Oracle PCM? We're trying to create a custom report that would show details per user. And I'd like to make it generic rather than have to create one per user. Any advices/suggestions would be appreciated.
    Thank you.
    Chandini

    Hi,
    Thanks for your response.
    if not in the database, is this information stored in the session somewhere within PCM? And would we be able to access it, more importantly? It should be stored somewhere, especially if PCM allows you to customize the dashboard etc for the currently logged in user.
    If there is no way, then we'll have to create one report per user which is so not a good option.
    Thank YOu,
    Chandini

  • Current Logged On User

    What I am needing to do is create a file with a name based on the currently logged on user in order to store some logging data.  I am using the single sign on method with the connection context cookie.  Is there a way to determine who is currently logged on with this method?  I am not interested in passwords, just the current logged on user.
    Thank You,
    Greg Johnson

    The company object in both the UI and DI have a UserName property that will contain the name of the currently logged in user.
    sboApp.MessageBox sboCompany.UserName & ":" & sboApp.Company.UserName
    John.

  • GPUpdate /force in Task Sequence as current logged on user

    Hi,
    I am currently trying to "upgrade" around 800 installations of Microsoft Office Standard 2010 to Microsoft Office 2010 Professional Plus. To do this, I'll have to:
    1: Install Office 2010 ProPlus
    2: Uninstall Office 2010 Standard
    3: Repair Office 2010 ProPlus
    Due to these steps, I've decided to make a task sequence to do the magic.
    So far, so good, the "upgrade" is installing, and the MAP toolkit reports are showing the correct results from my test lab.
    During the repair of Office 2010 ProPlus, the Office applications cannot
    run, so I've created a task to copy a custom group policy to %systemroot%\System32\GroupPolicy to deny the affected users to start the applications.
    After applying the group policies, I manually run a gpupdate /force on my test computer. The applications are not starting. Also - so far so good.
    Ok, so here is my challenge:
    Since the Task Sequence is running in context of the SYSTEM account, the applied group policy will not refresh the GPO's of the current logged on user. Meaning; during the installation / repair of Office 2010, the user can open all the applications regardless
    of the applied GPO's, and I'd very much like to avoid that. The TS will fail otherwise. Yes, I know I can perform a restart to apply the policies, but I'd like to avoid that as well.
    Any idea how can I solve this?

    I think you're making it very complex for yourself. I think that the PowerShell App Deployment Toolkit would be very benificial for a situation like this. For more information have a look here:
    https://psappdeploytoolkit.codeplex.com/
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

  • Checking to see if current logged in user is delegated by user on a task

    Hello all.
    I am looking to produce a report that will be run from a users home page (and thus can't take input at run time). It is to show the status of all tasks and appointments.
    The tricky bit is that I need it only to show tasks where the currently logged in user is the user who last delegated the task. I can make this work for the "owner" but not "delegated by".
    As a fall back position I might be able to get away with it looking to check if the current logged in user is the same as the "created by" user, as activities will only rarely be reassigned on.
    Any help appreciated.
    Bob.

    Hi,
    I am writing in to see if there is any update regarding this issue.
    Thanks,
    Linda
    Linda Li
    TechNet Community Support

  • Login to Jabber Client (Windows/Mac) with current logged in user account.

    We are deploying Jabber Client for Windows and will eventually be deploying for Macintosh.  I have no problem building the thinapp deployment package for the Jabber client.  However, when the thinapp is ran, it always shows the account that was used to initially login to the client and setup the server connection.
    Is there a way for the client to use the current logged in user in the sign in field?  I am trying to automate or SSO the process of logging into Jabber.
    Any and all ideas, tips, and/or tricks are greatly appreciated!
    Thank you,
    Wes

    This is nothing to do with the TC. This is your user issues on the Mac.
    I would do a major fix on the computer.. copy your user files to another location.. create a new administrator account.. login with the new admin account and delete the old one. Delete all the files associated with that account, so you are effectively starting with a clean Mac.
    I have just sold off a couple of computers and that is how I prepared it for the next person.. it seemed to work easily and removed all my stuff from the computer whilst still giving them full admin access.
    Please I am far from expert in doing this kind of stuff in OSX so just look up deleting original user accounts in whatever OS you run.

  • My Tasks View in my custom task list fails to display the tasks assigned to me (that is the currently logged in user)

    Hi
    I am new to sharepoint 2010.
    I created a custom task list, where I  have many tasks assigned to users (I had tasks assigned to me as well). I created a view as "My tasks "and having a filter as Assigned To is equal to [Me]. When I do that my view fails to show the
    tasks assigned to me. This happens same with the Sharepoints 'My Tasks' view as well. I tested by creating some test tasks under my name and when I selected 'My Tasks' view no tasks are getting displayed.
    Please help.
    Thanks,
    Gokulkumar.

    Hi,
    According to your post, my understanding is that you wanted to display the tasks assigned the current logged in user.
    In my environment, if I used the System Account, My Task view didn’t display any tasks.
    However , if I used other users except the System Account, My Task view could display current user tasks correctly.
    I recommend to use other accounts except System Account to log in site. Then everything will work well.
    Thank you for your understanding.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • SCCM report to show last logged on user and the Active Directory department attribute of that user.

    I need to create an SCCM report to show last logged on user on all machines and the Active Directory department attribute of that last logged on user.

    You problem is here.
    right
    join v_R_User USR on USR.ResourceID
    = CS.ResourceID
    USR.ResourceID != CS.ResourceID, you need to map the username to the user logon to the PC. By using the user’s department information you will
    end up with unreliable results.
    Anyways you need to make these changes to your query.
    left
    join v_R_User USR on USR.Unique_User_Name0
    = CS.UserName0
    http://www.enhansoft.com/

  • How to get the name of currently logged in user in the network

    Hi all,
    I want to know if there's a way to get the name of the currently logged in user in the network.
    SYS_CONTEXT('USERENV','OS_USER') won't work for me because our users do not loggin in portal.
    Any ideas?
    Thanks in advance.
    Brett

    Hello, I had the same problem. Here is a smaller version to find the Group of the current User.
    The VI get the members of a Group and match it with the Username.
    Note :
    If the User belongs to multiple Groups the the VI returns only the 1st Groupname
    If the User belongs to no Group then the VI returns "unknown Group"
    The VI is written with LabVIEW 2010 and TestStand 4.2.1
    Attachments:
    current user group.vi ‏20 KB
    TestStand get Group of current User.PNG ‏43 KB

  • Currently Logged in User

    Dear Experts
    i would like to know that how can we get the currently logged in user through query or some other option, as i want to generate different document series for every single user.
    Secondly, if i have a party which is my customer as well as my vendor, how i can perform netting so as to get the recievables and payables for the particular party.

    Hi,
    One way to get current logged in user list is through the XML file on the licensing server.  Otherwise, you can get current user by
    Select T0.U_Name From dbo.OUSR T0 Where T0.UserID = $[USER\].
    What is your B1 version and PL? It may not be the same for 2005 or 2007 to handle those BP with both types.
    Thanks,
    Gordon

  • Need query to determine current logged in user

    Because I see no way in sccm 2012 to determine if someone is currently logged into a domain joined computer.  Does anyone have a query or know of a way to get the current logged in user of a computer? I am surprised that SCCM does not show that information
    when looking at the particular device.  I did find a powershell query that I use that tells me the last logged in user but it gives me no indication if the user is currently logged in or if it was a week ago.
    Thank you.

    This PowerShell script queries a remote machine to obtain the current logged on user.  It's available on the Repository (https://gallery.technet.microsoft.com/scriptcenter/d46b1f3b-36a4-4a56-951b-e37815a2df0c).
    function Get-LoggedOnUser {
    #Requires -Version 2.0
    [CmdletBinding()]
    Param
    [Parameter(Mandatory=$true,
    Position=0,
    ValueFromPipeline=$true,
    ValueFromPipelineByPropertyName=$true)]
    [String[]]$ComputerName
    )#End Param
    Begin
    Write-Host "`n Checking Users . . . "
    $i = 0
    }#Begin
    Process
    $ComputerName | Foreach-object {
    $Computer = $_
    try
    $processinfo = @(Get-WmiObject -class win32_process -ComputerName $Computer -EA "Stop")
    if ($processinfo)
    $processinfo | Foreach-Object {$_.GetOwner().User} |
    Where-Object {$_ -ne "NETWORK SERVICE" -and $_ -ne "LOCAL SERVICE" -and $_ -ne "SYSTEM"} |
    Sort-Object -Unique |
    ForEach-Object { New-Object psobject -Property @{Computer=$Computer;LoggedOn=$_} } |
    Select-Object Computer,LoggedOn
    }#If
    catch
    "Cannot find any processes running on $computer" | Out-Host
    }#Forech-object(Comptuters)
    }#Process
    End
    }#End
    }#Get-LoggedOnUser

  • Identity User( Find Current Logged in User) Windows Forms

    I have implemented dummy code for logging in to a windows Forms Application using Identity (Owin Auth). part of my code is as follows:
    private bool validateuser()
    bool isAuthorised = false;
    Login1 log = new Login1();
    if (DialogResult.OK == log.ShowDialog())
    Splasher.Show(typeof(frmSplash));
    userC = log.usernameTextBox.Text;
    PassC = log.passwordTextBox.Text;
    if (userC == "" || PassC == "")
    count++;
    //isAuthorised = false;
    if (count > 0) log.LoginStatus.Text = "Empty passwords or usernames are not allowed. please try again";
    if (count == 2) MessageBox.Show("You have one try remaining");
    if (count == 3) { MessageBox.Show("You have exosted your tries application will now close"); Application.Exit(); }
    validateuser();
    else
    var userStore = new UserStore<IdentityUser>();
    var userManager = new UserManager<IdentityUser>(userStore);
    var user = userManager.Find(userC, PassC);
    if (user != null)
    var userIdentity = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
    isAuthorised = userIdentity.IsAuthenticated;
    userIdentity.AddClaim(new Claim("FullName", user.UserName));
    userIdentity.AddClaim(new Claim("User_Id", user.Id));
    return isAuthorised;
    else
    count++;
    //Application.Exit();
    if (count > 0) log.LoginStatus.Text = "You may have entered a wrong password or username. Please try again";
    if (count == 2) MessageBox.Show("You have one try remaining");
    if (count == 3) { MessageBox.Show("You have exosted your tries, application will now close"); Application.Exit(); }
    validateuser();
    count = 0;
    return isAuthorised;
    When the code works fine and is able to authenticate from the database. In the current form, I'm able to get the current user by using user.UserName or id by using user.Id
    How do I get to retrieve the name or Id of the current logged in user from another form. Please Help
    Thanks
    My ASP

    Type in c.Type is giving an error. could I be missing any important reference?
    My ASP
    Hi,
    Looks from Aram's code, I found a blog from Leandro Boffi.
    http://leandrob.com/2012/02/claims-identity-c-4-0-dynamics/
    Some similar code like Aram's. You should install
    Windows Identity Foundation and the companion
    WIF SDK
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Current logged on user using Powershell script

    Hi,
    i found a vb script which works fine and gives me desired output however i am looking to get this converted to powershell, so that i can add this to an existing shell script
    Purpose : the shell script should display/Echo currently logged on user, by reading the wmi
    Below is the vb script which i found, also i dont want its first line because i will be running the script locally on the computer with admin rights
    strComputer = "atl-ws-01"
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'explorer.exe'")
    If colItems.Count = 0 Then
    Wscript.Echo "No one is logged on to the computer."
    Else
    For Each objProcess in colItems
    objProcess.GetOwner strUser, strDomain
    Wscript.Echo strDomain & "\" & strUser
    Next
    End If--------RegardsTanoj
    OSLM ENGINEER - SCCM 2007 & 2012

    Thank you for the reply
    yes mjolinor you caught me, i am working with sccm 2012 trying to create a universal script which will work flawlessly on VM, windows 8, Windows 7 etc ....
    so which one you think is good to fullfill my need,
    Get-WmiObject
    -Class win32_process
    -filter "Name = 'explorer.exe'" -computer VMNAME    ?
     also it will be great help if you could help me get the complete script wich includes the above line,
    i get following error when executing the above command
    Regards
    Tanoj

Maybe you are looking for