Create Customer Statement in MS Access - ms-access

I have tables one is invoice & other is payment, I want to make customer statement related to it
Invoice table:
Invoice Date:
Invoice Id:
Customer Id:
quantity:
Rate:
Amount:
Payment table
Payment Date
Customer Id:
Payment Method:
Reference No:
Payment Amount:
I want to create a customer statement like
Date | Invoice Detail | Debit Amount | Credit Amount|
Date From Invoice or Payment Column according to data
Invoice amount should be debit & payment amount should be credit to form the ledger, How could i do with that Please help me out
I got the balance invoice sheet etc , but cant able to make ledger / statement of customer
Database file https://www.dropbox.com/s/hnra30rpgdlzz56/invoice-test.accdb

EDIT: This answer was constructed on the basis of the requirements and table definitions posted in the question. Upon inspection of the Access DB provided, the table structures described in the question bear little resemblance to the real implementation, however the approach still solves what was requested.
The base query is something along these lines.
SELECT [Customer ID], 'DEBIT' AS Transaction_Type, [Invoice Date], [Invoice Id] As [Ref_Num], [Amount] as [Debit], Null AS [Credit]
FROM Invoice
UNION
SELECT [Customer ID], 'CREDIT' AS Transaction_Type, [Invoice Date], [Reference No] As [Ref_Num], Null as [Debit], [Payment Amount] AS [Credit]
FROM Payment
If you want to aggregate all debit/credit transactions for a particular date it becomes fiddly as you need to merge the references, but in essence this is what you need.
I've not been able to test this so please advise if it works for you.

Related

MySQL exchange rate with date query

I have a table with exchange rates by date and a second table with customers sales.
TableA:
date of excahnge_rate
from_currency
to_currency
TableB:
customerid
total_bought
user_currency
date_bought
I need to get a table with the total_bought transformed into the same currency, so I need to check the exchange_rate on each date_bought and apply the rate on that date.
I would get the same TableB but with the total_bought in the same currency for all the records.
I'm an unexperienced user of SQL and I'm having troubles with this.

Remove Duplicate Records From Left Join

I work with Microsoft Dynamics Navision 2013 and SQL 2014 as the data source. The Value entry table is the main table that host all sales transaction for customers / Items.
For some of the items we pay Excise (Tax), a certain rate we pay for all items being transferred from one warehouse to another which we call (Transfer Excise).
I work for a wine farm and for each year we enter a unit rate for each item per location(Location being the warehouse where the wine is stored before transfer out of the warehouse]. Our unit rate was created on the 28-02-28.
In order to get the calculation for the Transfer Excise I took data from various tables from Microsoft Dynamics Navision. The tables are containing the columns I took:
Location : Code, also contains a filter “NONBOND”
Item: No(PK) , Excise Type
Excise Rate: Starting Date (The starting date of the Unit Rate), Excise Type Code
Item Unit Of Measure: Item No(PK), Qty_ per unit of measure as (Litre Conversion Factor)
The data was entered into a new table called Transfer Excise Tbl 1. To simplify my example, my Transfer Excise table contains: No_ and Location Code (FK) my Value Entry Table contains Item No_(PK) , Location Code(PK). Of course I will join Transfer Excise and Value Entry table on (No_=Item No_) and Location code = Location code.
I'm trying to get all item transactions which match the Value Entry table for each unit rate for that specific starting date and the posting date when the transaction were posted using LEFT JOIN with filters.
In the Value Entry table I use Gen_ Bus_ Posting Group to filter only (LOCA & EXSA), LOCA meaning local and EXSA meaning Export South Africa. This is the query I am trying, however I get duplicates with no starting dates and posting dates. I tried using DISTINCT as seen in my query but it does not work.
SELECT DISTINCT a.[Starting Date],
b.[Posting Date],
b.[Item No_],
b.[Invoiced Quantity],
a.[Litre Conversion Factor],
a.[Unit Rate] ,
a.[Location Code],
a.[Excise Location],
a.[Excise Type Code],
a.[Unit Of Measure Code]
FROM [Transfer Excise Tbl] a
LEFT JOIN [Spier Live$Value Entry] b
ON a.[No_] = b.[Item No_]
WHERE b.[Posting Date] > '2014-03-01'
AND b.[Item No_] = 'F00335'
AND b.[Location Code] = a.[Location Code]
AND b.[Gen_ Bus_ Posting Group] IN ('LOCA','EXSA')
AND b.[Posting Date] >= a.[Starting Date]
AND b.[Invoiced Quantity] <>0
order by b.[Posting Date]

MS Access Query To Show Last Transaction

I have a table called tblTransactions. On this table I log all Payments and Invoices for each customer Account. Each Payment or Invoice is its own record. In essence it's a simple accounting table showing debits and credits. My goal is to create a query which shows, by account, the last 'Payment' date and how many days ago that was. I'm sure this is fairly easy, but I've been out of Access for a while. Any help is appreciated!
Fields:
AccountID,
Transaction_Date,
Transaction_Type ("Payment" or "Invoice")
This should do the trick:
SELECT AccountID,
MAX(Transaction_Date) AS LastTranDate ,
Datediff("d",MAX(Transaction_Date),Date()) AS DaysAgo
FROM tblTransactions
WHERE Transaction_Type = 'Payment'
GROUP BY AccountID

find total amount of a customer in SQL

i'm trying to find out the total amount of a particular customer in an inventory database.
the tables are :
customer, tax, invoice, line_no, branch, items, employee
i was able to calculate the total but i get multiple amounts as it calculates the amount for each tax rate in the database. i'm trying to restrict the amount depending on the branch issues it. i hope i made it clear, here is the query:
SELECT ROUND((SUM((LINE_NO.RETAIL_PRICE - LINE_NO.DISCOUNT)* LINE_NO.DEL_QTY)* (TAX.TAX_RATE))+
SUM((LINE_NO.RETAIL_PRICE - LINE_NO.DISCOUNT)* LINE_NO.DEL_QTY),2)
AS "TOTAL PAYMENT"
FROM LINE_NO, TAX, BRANCH
WHERE LINE_NO.INVOICE_INVOICE_NO IN (SELECT INVOICE.INVOICE_NO from INVOICE
WHERE(INVOICE.CUSTOMER_CUST_NO IN (SELECT CUST_NO from CUSTOMER where CUSTOMER.FNAME='JIM' )))
AND TAX.CITY = BRANCH.CITY
GROUP BY TAX.TAX_RATE;
GROUP BY should not operate on TAX_RATE here to avoid calculate total amount for each group (TAX_RATE).
SELECT ROUND((SUM((LINE_NO.RETAIL_PRICE - LINE_NO.DISCOUNT)* LINE_NO.DEL_QTY)* (TAX.TAX_RATE))+
SUM((LINE_NO.RETAIL_PRICE - LINE_NO.DISCOUNT)* LINE_NO.DEL_QTY),2)
AS "TOTAL PAYMENT"
FROM LINE_NO, TAX, BRANCH
WHERE LINE_NO.INVOICE_INVOICE_NO IN (SELECT INVOICE.INVOICE_NO from INVOICE
WHERE(INVOICE.CUSTOMER_CUST_NO IN (SELECT CUST_NO from CUSTOMER where CUSTOMER.FNAME='JIM' )))
AND TAX.CITY = BRANCH.CITY;
exactly. yes the rate can be retrieved from the branch location, which can be tracked by the Invoice number. so i added another query after:
AND TAX.CITY = BRANCH.CITY
which helped to determine the tax rate i'm looking for and got it working, thanks anyways

Access: Auto-Fill in values in a table based on certain criteria. (Payment schedule)

I basically want to create a payment schedule in a separate table based on 4 values that a user would select. The payment schedule is very basic and the table only needs 2 columns, 1) Date of payment, 2) payment amount.
The 4 criteria values that are used to fill out this simple table would be: 1) the total amount of money, 2) number of payments, 3) the frequency of the payments (monthly, quarterly, semi-annually, annually), 4) the date of the first payment.
The way that I envision this is having a Form where these 4 values will be selected. On that form there can be a button to execute the command to fill in a datasheet with the appropriate values.
The first entry would obviously be on the date of the first payment, and the amount for that entry would be the total amount divided by the number of payments. For the second record dollar amount would be the same and the date would be the first payment date + the frequency. So if the first payment date is 1/1/2000 and the frequency annually, then the second entry date would be 1/1/2001. Etc.. until the last payment is made.
While it is a pretty simple payment schedule, I'm not sure how to best approach this in Access and if it's even possible. Would appreciate some input and direction. Thank you!
You will need
-- A numbers table with integers from 0 to the highest number of payments possible, indexed on the number.
-- A combobox called Frequency on forms payments with the following properties:
Row source: q;quarter;m;month;ww;week
Row source type : value list
Bound column : 1
Column count : 2
Column widths : 0, 1
-- A query
INSERT INTO Payments ( UserID, PaymentDate, Payment )
SELECT [Forms]![Payments]![UserID],
DateAdd([Forms]![Payments]![Frequency],
[Number],
[Forms]![Payments]![Startdate]) AS Expr2,
[Forms]![Payments]![LoanAmount]/
[Forms]![Payments]![NumberOfPayments] AS Expr3
FROM Numbers
WHERE (((Numbers.Number)<[Forms]![Payments]![NumberOfPayments]));
-- A button to run the query.