Email the Sales team their monthly Commission at an Order level - sql

I am trying to find a way in SQL which would send email either as excel attachment or html to the Sales Teams on how much monthly commission did they earn on each order. Since it is commission, due to security reasons I cannot send a common file to everyone to look at each others commissions. Trying to put the scenario in a tabular form for a better understanding.
The first table gives you at an Order level who is getting paid how much. Which I already have in place
This table gives how much commission is paid individually and should email the same results to respective Sales Person based on Email address listed in 1st table

Related

I would like to run a query to produce a price list for each customer and product taking into consideration promotional prices and discount prices?

We have a number of different promotions (fixed prices and discount %) for each customer. I want to be able to produce an extract so that we can work out what the price the customer would pay if they were entering a Sales Order direct within Epicor. I then want to use this as part on an internal portal so I will store these prices in a seperate table.
I can extract each item individually i.e. customers & products. but I can't seem to get the logic correct for working out the correct sales price.
This is for Epicor 9.05
Thanks
It sounds like you want to use customer price lists to track pricing for your customers. This will allow you to set discounts or custom prices for some or all of your parts.
While the material is proprietary to Epicor, you can take a look at the "Customers and Accounts Receivable" chapter of the EpicorAppplication_UserGuide for your version as found on your EpicWeb customer portal for more information on using these.

SQL query for game rental website - game delivery report

http://sqlfiddle.com/#!3/f2da70/13
I am creating a game rental website using MS SQL 08 and I have to create a report which will give me a list of all the games that need to be posted and to who.
This query will have to go through different stages:-
List the users that have not reached their game quota for that month based on the subscription package they have chosen and rental table.
Compare this list of users to their favourites list and asign a game to them based on what game is their highest priority and by date.
The game or games selected must be in stock which needs compared to quantity levels in games table.
I have a SQL query but it is not taking into consideration the dates that a user added a game to their favourites list, it works solely on priority level. I need to change this query so it picks the oldest date added if the priority of the games are the same. In this sample data in SQL Fiddle it should be giving me barcode 27 to match with Need for Speed Rivals but it is giving me FIFA 14 as it is the first favourite record it sees.
Also the report needs to show more than the game barcode, it needs to show user name and game details. It is also only working for a single user at the moment with with me entering a user ID manually but it should just go through all users.
If anyone can help me with this query it would be much appreicated it, just really dont know where to go from here.
change
ORDER BY Favourites.Priority
to
ORDER BY Favourites.Priority, Favourites.DatePicked asc

How to Query for Due Dates in Access 2007

I have a 2 access 2007 tables with the following fields:
Table 1: Loan Release Table
ReleaseDate as Date
Maturity as Date
MemberName as Text
MemberNo as Text
Term (in months) as Number
Mode (M/Q/Semi-Monthly) as Text
LoanType as Text
LoanAmount as Currency
LoanCode as Text
Table 2: Payments Table
ReceiptNo as Text
DatePaid as Date
MemberName as Text
MemberNo as Text
LoanCode as Text
LoanReceivable as Currency
InterestPaid as Currency
I would like to ask on how to use Query to create a temporary table that will display Members that should pay on current date or a specified date base on their Term, Mode of Payment and Loan Type (Regular Loans every 30 days to pay, Special Loans every 45 days to pay) and their remaining balance.
Here's my First Attempted Query: I tried to subtract 30 days from Current Date and it obviously gave me just the transactions last month. I would like it to list all transactions including those for example Member with Regular Loan 12 month term on their 3rd monthly payment, Member with Special Loan that is due today.
I am thinking of creating another table that contains the schedule of payments of every Loan released and then go from there.
Is there another way than this? Like a Query that can be run everyday without the need for a bulky ScheduleOfPayments table?
I'm an office clerk who 'graduated' from Excel and a novice using Access at worst and I'm not afraid of VBA codes if that is necessary.
If you know of a better way of doing this, please do tell me or point me in the right direction. I'm all for learning new things and having read and learned a lot from stackoverflow before, I am sure that with your help, my question is as good as solved.
Thank you guys for reading my inquiry.
You have here two solutions:
You can write a procedure that will, when needed, calculate\generate a matrix containing payment schedule for each loan and compare it to payment done.
You can write a procedure that will, when a loan is created, generate corresponding records in a payment schedule table. further comparison will be done between the ScheduledPayment table and the Payment table.
So basically you have to manage a similar set of data, either as a calculated/on the fly matrix or as a permanent set of data kept in a table.
The second version is by very very far the most effective one. You think of it as bulky but it is exactly the opposite, and indeed what is done every time you get a loan from a bank, where your banker will let you sign the reimbursement schedule.
The table solution will allow you to make use of all querying facilities, while the calculated solution will force you to write specific procedures each time you'll want to do some data mining. Just think about a question like "What are the expected reimbursements for the month of April 2014?". Answering this question with the ScheduledPayment table will be as easy as getting a cafe out of your nespresso machine. The same answer without the ScheduledPayment table will be like having to do the whole coffee production process before getting your cup ready.

Payroll, OpenERP 7, U.S. payroll taxes

I have searched and searched but to no avail... has anybody created a payroll module for a U.S. based company? It seems that most of what I've seen is that companies are using payroll companies to process their payroll, but I haven't found anybody using OpenERP 7 for hourly employees with the U.S. tax system (it's not a flat tax rate).
It seems like what I may have to do, is create tax table in PostgresQL for federal, state, and local taxes, then reference those tables in the deduction calculation. I read one article on using the vendors/ or suppliers module and implementing a tax structure from that, but then again, those are still flat rates. I have to believe someone else has done this for the U.S. payroll system, and probably done it better than I could as I am fairly new to OpenERP.
I am in the process of doing something similar for LedgerSMB. The thing is that doing this on an open source model is extremely painful business-model-wise. I am working on solutions to that part but that's outside the scope of your question.
In general many US taxes are set up in marginal rates with certain minimums and maximums. For example income tax withholding is a set of marginal rates within tax brackets. Same with FICA and FUMA, but FICA taxes are capped at a certain level, so a simple tax table with rates, minimums, maximums, etc. and then a way of handling deductions to determine the correct line may be sufficient.
But users of most open source ERP's use third party services for payroll.
I have worked in an ERP. How we did is just calculate the FIT in yearly for all the employee and subtract the withholding amount with multiples.
FIT => Taxable Wages Yearly - (No.of withholding(Exemption))
Do the process as per the revision based on single or married only for annually. No need to update all the tables.
Then,
Divided it based on the frequency from the employee table information
EX:
for monthly : FIT/12
for daily : FIT/365
For SIT you have to use based on the document in the state usine case function.

Best way to structure table for commission reports

I want to have a table that will track all the commissions we are due from our wireless sales. Each plan pays a different Commission, not a problem. We do our reconciliation as sometimes the carriers don't pay (they may miss a line or 2).
The problem occurs when the carriers change how much they pay for the commissions. We want to be able to go back and see that there was 4 lines not paid for in January at commission rate x. but Feb the same types of plans were sold but their commission rates were x-10.
If I change the rate in the commission table for the plan, when i go back to pull the data from the January report I will get incorrect commission rates.
I have a table for sales set up with a date stamp so I was thinking i can cross reference that somehow.
Hope someone followed this.
I am looking for the best way to structure this.
You should "STAMP" the record with the commission rate. You could either stamp the actual rate into every record... or you could keep a commission ID and put that into each record.