Monthly Direct Sales Report
Pull the monthly direct order figures in MySQL for the prior month on 1st of the month (i.e. pull June sales figures on July 1st). You can download MySQL Workbench here:
- Scroll down, click “Download”
- Click “No thanks, just start my download”
- Install, then open and begin setup:
- Name your group: RDS-PRO
- Password (save to keychain): mec5EJukuzEh
- Server: pro.cfgjkecfpua1.us-west-2.rds.amazonaws.com
- Contact Bill: if you are unable to log in. He will need to allow your IP address through our server security settings.
Running a query:
1. Click the “Add Query” icon to begin a new query.
2. Paste the following query into the body:
- Use FundyCentral;
- set @startDate = "2020/07/01";
- set @endDate = "2020/07/31";
- set @vendorId = "5dac0b32-cc53-4669-952e-3ee3540b0bbc";
- DROP TEMPORARY TABLE IF EXISTS DirectPaymentsAndCredits;
- DROP TEMPORARY TABLE IF EXISTS DirectPayments;
- DROP TEMPORARY TABLE IF EXISTS DirectCredits;
- CREATE temporary table DirectPaymentsAndCredits
- SELECT
- o.VendorId,
- u.CompanyName,
- sum(OrderTotal) as 'All Transactons'
- FROM FundyCentral.`OrderTransaction` ot
- INNER JOIN FundyCentral.`Order` o
- ON ot.OrderId = o.Id
- INNER JOIN FundyCentral.`User` u
- ON u.id = o.VendorId
- WHERE
- (o.OrderType = 'ALBUM' OR o.OrderType = 'WALLART' OR o.OrderType = "CARDS") AND ot.Status = 'APPROVED'
- AND Date(ot.TransactionDate) between @startDate and @endDate
- group by o.vendorId;
- CREATE temporary table DirectPayments
- SELECT
- o.VendorId,
- u.CompanyName,
- sum(OrderTotal) as 'Payments'
- FROM FundyCentral.`OrderTransaction` ot
- INNER JOIN FundyCentral.`Order` o
- ON ot.OrderId = o.Id
- INNER JOIN FundyCentral.`User` u
- ON u.id = o.VendorId
- WHERE
- (o.OrderType = 'ALBUM' OR o.OrderType = 'WALLART' OR o.OrderType = "CARDS") AND ot.Status = 'APPROVED'
- AND Date(ot.TransactionDate) between @startDate and @endDate
- AND ot.TransactionType <> "CREDIT"
- group by o.vendorId;
- CREATE temporary table DirectCredits
- SELECT
- o.VendorId,
- u.CompanyName,
- sum(OrderTotal) as 'Credits'
- FROM FundyCentral.`OrderTransaction` ot
- INNER JOIN FundyCentral.`Order` o
- ON ot.OrderId = o.Id
- INNER JOIN FundyCentral.`User` u
- ON u.id = o.VendorId
- WHERE
- (o.OrderType = 'ALBUM' OR o.OrderType = 'WALLART' OR o.OrderType = "CARDS") AND ot.Status = 'APPROVED'
- AND Date(ot.TransactionDate) between @startDate and @endDate
- AND ot.TransactionType = "CREDIT"
- group by o.vendorId;
- select * from DirectPaymentsAndCredits;
- select * from DirectPayments;
- select * from DirectCredits;
- select coalesce( (select payments from DirectPayments where VendorId=@vendorId), 0) - coalesce( (select credits from DirectCredits where vendorId=@vendorId), 0) as 'Total' from DirectPaymentsAndCredits where VendorId = @vendorId;
3. Update the dates to reflect the previous month (i.e. 2021/06/01 - 2021/06/30) and make sure you’re including all days for that month.
4. Click the lightning bolt icon to run your query.
5. Open the Direct Sales by Month report: https://docs.google.com/spreadsheets/d/1QUr9LFlnDUCNqVwSH8t8WFoKEOgGy0L4RqdRrOR12CA/edit?usp=sharing
6. Enter the direct sales figures for each lab from the MySQL query into the report under that specific month.
7. Re-Share document with Todd ([email protected]), Jonathan Main, Lisa ([email protected]), and Andrew. Be sure to enter a brief message stating you’ve updated the document to reflect the previous month’s figures.