DEALER_TRANSACTIONS Datatape¶
Transaction-level detail for Dealer Payables/Credits/Disbursements/Receipts Activity including payment processing, vendor management, and financial transaction tracking.
Overview¶
Generation Frequency: Adhoc Development Status: Stable
Key Features: - Dealer payment tracking - Transaction-level analysis - Payables/receivables management - Vendor relationship analytics
Key Stakeholders: - Alvarez & Marsal
Output Columns¶
The following columns are included in the final datatape output (filtered from SQL queries based on configuration):
Column Analysis Summary¶
- Total columns found in SQL queries: 154
- Columns specified in output_columns config: 17
- Columns found in SQL and included in output: 21
- Missing columns (in config but not found in SQL): 4
Note: Only columns that exist in SQL queries are included in the final output.
| Column Name | Required | Source Query | Source Table | Source Field | Derived | Transformations |
|---|---|---|---|---|---|---|
| Dealer Name | Yes | dealer_transactions | sfdc_staging.vwx_account | Dealer Name | Yes | |
| Hold Status | Yes | ap_payments_view | Hold Status | Yes | ||
| Invoice Status | Yes | ap_payments_view | Credit Notes | Invoice Status | No | |
| Invoice Status | Yes | dealer_transactions | sfdc_staging.vw_c2g__codapurchaseinvoice__c | Invoice Status | No | |
| Invoice Total2 | Yes | ap_payments_view | Credit Notes | Invoice Total2 | No | |
| Invoice Total2 | Yes | ap_payments_view | Payable Invoice | Invoice Total2 | No | |
| Payment Status | Yes | ap_payments_view | Credit Notes, transaction_c | Payment Status | Yes | |
| Payment Status | Yes | dealer_transactions | pi, tr | Payment Status | Yes | |
| Payment Status | Yes | ap_payments_view | Payable Invoice, transaction_c | Payment Status | Yes | |
| Period | Yes | ap_payments_view | Coda Period | Period | No | |
| Period | Yes | ap_payments_view | Coda Period | Period | No | |
| Portfolio | Yes | dealer_base_systems | Portfolio | No | ||
| Project Stage | Yes | ap_payments_view | Payable Invoice | Project Stage | No | |
| Project Stage | Yes | ap_payments_view | Credit Notes | Project Stage | No | |
| Sunnova System ID | Yes | dealer_transactions | sfdc_staging.vw_c2g__codapurchaseinvoice__c | Reference 1 | No | |
| Sunnova System ID | Yes | dealer_base_systems | Sunnova System ID | No | ||
| Transaction Amount | Yes | dealer_transactions | sfdc_staging.vw_c2g__codapurchaseinvoice__c | Transaction Amount | Yes | |
| Transaction Date | Yes | dealer_transactions | sfdc_staging.vw_c2g__codapurchaseinvoice__c | Transaction Date | Yes | |
| Unique Transaction ID | Yes | dealer_transactions | sfdc_staging.vw_c2g__codapurchaseinvoice__c | Payable Invoice Number | No | |
| VIN | Yes | ap_payments_view | Credit Notes | VIN | No | |
| VIN | Yes | ap_payments_view | Payable Invoice | VIN | No |
Note: Columns marked as 'Derived' are calculated or transformed rather than directly selected from the source table.
Data Sources¶
The configuration pulls data from the following sources:
| Source Name | Type | Query/File | Description |
|---|---|---|---|
| dealer_transactions | database | dealer_transactions.sql | SQL query for dealer_transactions data |
| ap_payments_view | database | ap_payments_view.sql | SQL query for ap_payments_view data |
| dealer_base_systems | database | dealer_base_systems.sql | SQL query for dealer_base_systems data |
| snh_eistein_data | database | snh_eistein_data.sql | SQL query for snh_eistein_data data |
Configuration¶
Portfolio Groups¶
tep_portfolios:
sla_portfolios: - Sunnova Asset Portfolio 7 Holdings LLC - Sunnova AP6 Warehouse II LLC - Sunnova EZ-Own Portfolio LLC - Sunnova Asset Portfolio 8 LLC - Sunnova Asset Portfolio 9 Holdings LLC - Sunnova Asset Portfolio 9 LLC
Database Configuration¶
- host: ${NOVA_DB_HOST}
- name: ${NOVA_DB_NAME}
- port: 5432
- pool_size: 5
- max_retries: 3
Paths¶
- sql_dir: ./sql
- cache_dir: ./Query Cache
- output_dir: ./Completed Output
SQL Queries¶
-- dealer_transactions.sql
-- Transaction-level detail for Dealer Payables/Credits/Disbursements/Receipts Activity
-- Will be filtered by portfolio_names parameter passed from config
SELECT
pi."Payable Invoice Number" AS "Unique Transaction ID",
pi."Reference 1" AS "Sunnova System ID",
COALESCE(pi."Invoice Date", pi."Created Date") AS "Transaction Date",
-pi."Outstanding Value" AS "Transaction Amount",
acc."Account Name" AS "Dealer Name",
pi."Reference 2" AS "Transaction Type", -- Use Project Stage directly instead of deriving transaction type
sp
pi."Invoice Status",
CASE
WHEN pi."Invoice Status"::text <> 'Complete'::text THEN 'Not Applicable'::text
WHEN tr."Document Outstanding Total" = 0::numeric THEN 'Paid'::text
WHEN tr."Document Total" = tr."Document Outstanding Total" THEN 'Unpaid'::text
ELSE 'Part Paid'::text
END AS "Payment Status",
CASE
WHEN pi."Invoice Status"::text <> 'Complete'::text THEN 'Not Applicable'::text
WHEN tr."Document Outstanding Total" = 0::numeric AND -pi."Outstanding Value" < 0 THEN 'Cash Disbursement actually made to Dealer'
WHEN tr."Document Outstanding Total" = 0::numeric AND -pi."Outstanding Value" > 0 THEN 'Cash Received from Dealer'
WHEN tr."Document Outstanding Total" = tr."Document Total" THEN 'Recording an amount payable'
ELSE 'Recording an amount payable'
END AS "Application",
sp."Primary Customer Name" AS "Customer Name",
acc."Account Type (1)" AS "Dealer Type",
pi."Vendor Invoice Number" AS "VIN",
pi."Invoice Total" AS "Invoice Total2",
cp."Period ID" AS "Period",
pi."Hold Status" AS "Hold Status",
comp."Name" AS "Portfolio",
'Invoice' AS "Document Type"
FROM
sfdc_staging.vw_c2g__codapurchaseinvoice__c pi
JOIN
sfdc_staging.vw_c2g__codatransaction__c tr ON pi."Record ID"::text = tr."Payable Invoice"::text
JOIN
sfdc_staging.vw_c2g__codacompany__c comp ON pi."Company"::text = comp."Record ID"::text
JOIN
sfdc_staging.vw_c2g__codaperiod__c cp ON pi."Period"::text = cp."Record ID"::text
LEFT JOIN
sfdc_staging.vwx_account acc ON pi."Account"::text = acc."Account ID (2)"::text
LEFT JOIN
(SELECT s."System Name" AS "System", s."Primary Customer Name" FROM sfdc_staging.vw_system__c s) sp
ON pi."Reference 1"::text = sp."System"::text
WHERE
-- Filter by either TEP or SLA portfolios
(comp."Name" IN :tep_portfolios OR comp."Name" IN :sla_portfolios)
-- Filter by date range
-- AND pi."Created Date" >= :start_date
-- AND pi."Created Date" <= :end_date
-- Additional filters similar to AP payments view
AND pi."Invoice Status"::text <> ALL (ARRAY ['Discarded'::text, 'In Progress'::text])
AND acc."Payment Method (1)"::text <> 'Check'::text
AND pi."Reference 1" IS NOT NULL
UNION ALL
-- Add credit notes with similar structure
SELECT
cn."Credit Note Number" AS "Unique Transaction ID",
cn."Reference 1" AS "Sunnova System ID",
COALESCE(cn."Credit Note Date", cn."Created Date") AS "Transaction Date",
-cn."Outstanding Value" AS "Transaction Amount",
acc."Account Name" AS "Dealer Name",
cn."Reference 2" AS "Project Stage", -- Use Project Stage directly
cn."Credit Note Status" AS "Invoice Status",
CASE
WHEN cn."Credit Note Status"::text <> 'Complete'::text THEN 'Not Applicable'::text
WHEN tr."Document Outstanding Total" = 0::numeric THEN 'Paid'::text
WHEN tr."Document Total" = tr."Document Outstanding Total" THEN 'Unpaid'::text
ELSE 'Part Paid'::text
END AS "Payment Status",
'Applying a credit' AS "Application", -- Credit notes are always applying a credit
sp."Primary Customer Name" AS "Customer Name",
acc."Account Type (1)" AS "Dealer Type",
cn."Vendor Credit Note Number" AS "VIN",
cn."Credit Note Total" AS "Invoice Total2",
cp."Period ID" AS "Period",
NULL::text AS "Hold Status",
comp."Name" AS "Portfolio",
'Credit Note' AS "Document Type"
FROM
sfdc_staging.vw_c2g__codapurchasecreditnote__c cn
JOIN
sfdc_staging.vw_c2g__codatransaction__c tr ON cn."Record ID"::text = tr."Payable Credit Note"::text
JOIN
sfdc_staging.vw_c2g__codacompany__c comp ON cn."Company"::text = comp."Record ID"::text
JOIN
sfdc_staging.vw_c2g__codaperiod__c cp ON cn."Period"::text = cp."Record ID"::text
LEFT JOIN
sfdc_staging.vwx_account acc ON cn."Account"::text = acc."Account ID (2)"::text
LEFT JOIN
(SELECT s."System Name" AS "System", s."Primary Customer Name" FROM sfdc_staging.vw_system__c s) sp
ON cn."Reference 1"::text = sp."System"::text
WHERE
-- Filter by either TEP or SLA portfolios
(comp."Name" IN :tep_portfolios OR comp."Name" IN :sla_portfolios)
-- Filter by date range
-- AND cn."Created Date" >= :start_date
-- AND cn."Created Date" <= :end_date
-- Additional filters similar to AP payments view
AND cn."Credit Note Status"::text <> ALL (ARRAY ['Discarded'::text, 'In Progress'::text])
AND acc."Payment Method (1)"::text <> 'Check'::text
AND cn."Reference 1" IS NOT NULL
ORDER BY
"Sunnova System ID",
"Transaction Date";
create or replace view vw_ap_payments
("PIN", "Account", "Company", "Due Date", "Invoice Date", "Invoice Status", "Invoice Total",
"Payment Status", "Period", "System Project", "Project Stage", "Payment Method", "VIN", "Homeowner Name",
"Created Date", "Invoice Total2", "Hold Status", "Dealer/Vendor", "Invoice Type")
as
WITH transaction_c AS (SELECT vw_c2g__codatransaction__c."Document Total",
vw_c2g__codatransaction__c."Document Outstanding Total",
vw_c2g__codatransaction__c."Payable Invoice",
vw_c2g__codatransaction__c."Payable Credit Note"
FROM sfdc_staging.vw_c2g__codatransaction__c
WHERE vw_c2g__codatransaction__c."Payable Invoice" IS NOT NULL
OR vw_c2g__codatransaction__c."Payable Credit Note" IS NOT NULL
ORDER BY vw_c2g__codatransaction__c."Payable Invoice",
vw_c2g__codatransaction__c."Payable Credit Note"),
system_project_c AS (SELECT primary_customer_name__c.primary_customer_name__c AS "Primary Customer Name",
sp.system__c AS "System"
FROM sfdc_staging.system_project__c sp
LEFT JOIN sfdc_staging.vw_33_22465 primary_customer_name__c
ON primary_customer_name__c.id::text = sp.id::text),
included_accounts AS (SELECT vwx_account."Account Name",
vwx_account."Payment Method (1)",
vwx_account."Account Type (1)",
vwx_account."Account ID (2)"
FROM sfdc_staging.vwx_account
WHERE vwx_account."Payment Method (1)"::text <> 'Check'::text),
payable_invoices AS (SELECT "Payable Invoice"."Payable Invoice Number" AS "PIN",
"Accounts"."Account Name" AS "Account",
"Companies"."Name" AS "Company",
"Payable Invoice"."Due Date",
"Payable Invoice"."Invoice Date",
"Payable Invoice"."Invoice Status",
- "Payable Invoice"."Outstanding Value" AS "Invoice Total",
CASE
WHEN "Payable Invoice"."Invoice Status"::text <> 'Complete'::text
THEN 'Not Applicable'::text
WHEN transaction_c."Document Outstanding Total" = 0::numeric THEN 'Paid'::text
WHEN transaction_c."Document Total" = transaction_c."Document Outstanding Total"
THEN 'Unpaid'::text
ELSE 'Part Paid'::text
END AS "Payment Status",
"Coda Period"."Period ID" AS "Period",
"Payable Invoice"."Reference 1" AS "System Project",
"Payable Invoice"."Reference 2" AS "Project Stage",
"Accounts"."Payment Method (1)" AS "Payment Method",
"Payable Invoice"."Vendor Invoice Number" AS "VIN",
system_project_c."Primary Customer Name" AS "Homeowner Name",
"Payable Invoice"."Created Date",
"Payable Invoice"."Invoice Total" AS "Invoice Total2",
"Payable Invoice"."Hold Status",
"Accounts"."Account Type (1)" AS "Dealer/Vendor",
'Payable Invoice'::text AS "Invoice Type"
FROM sfdc_staging.vw_c2g__codapurchaseinvoice__c "Payable Invoice"
JOIN transaction_c
ON "Payable Invoice"."Record ID"::text = transaction_c."Payable Invoice"::text
JOIN sfdc_staging.vw_c2g__codacompany__c "Companies"
ON "Payable Invoice"."Company"::text = "Companies"."Record ID"::text
JOIN sfdc_staging.vw_c2g__codaperiod__c "Coda Period"
ON "Payable Invoice"."Period"::text = "Coda Period"."Record ID"::text
LEFT JOIN system_project_c
ON "Payable Invoice"."System"::text = system_project_c."System"::text
JOIN included_accounts "Accounts"
ON "Payable Invoice"."Account"::text = "Accounts"."Account ID (2)"::text AND
("Payable Invoice"."Invoice Status"::text <> ALL
(ARRAY ['Discarded'::character varying::text, 'In Progress'::character varying::text])) AND
"Payable Invoice"."Hold Status" IS NULL
WHERE CASE
WHEN "Payable Invoice"."Invoice Status"::text <> 'Complete'::text
THEN 'Not Applicable'::text
WHEN transaction_c."Document Outstanding Total" = 0::numeric THEN 'Paid'::text
WHEN transaction_c."Document Total" = transaction_c."Document Outstanding Total"
THEN 'Unpaid'::text
ELSE 'Part Paid'::text
END = ANY (ARRAY ['Unpaid'::text, 'Not Applicable'::text, 'Part Paid'::text])),
credit_notes AS (SELECT "Credit Notes"."Credit Note Number" AS "PIN",
"Accounts"."Account Name" AS "Account",
"Companies"."Name" AS "Company",
"Credit Notes"."Due Date",
"Credit Notes"."Credit Note Date" AS "Invoice Date",
"Credit Notes"."Credit Note Status" AS "Invoice Status",
- "Credit Notes"."Outstanding Value" AS "Invoice Total",
CASE
WHEN "Credit Notes"."Credit Note Status"::text <> 'Complete'::text
THEN 'Not Applicable'::text
WHEN transaction_c."Document Outstanding Total" = 0::numeric THEN 'Paid'::text
WHEN transaction_c."Document Total" = transaction_c."Document Outstanding Total"
THEN 'Unpaid'::text
ELSE 'Part Paid'::text
END AS "Payment Status",
"Coda Period"."Period ID" AS "Period",
"Credit Notes"."Reference 1" AS "System Project",
"Credit Notes"."Reference 2" AS "Project Stage",
"Accounts"."Payment Method (1)" AS "Payment Method",
"Credit Notes"."Vendor Credit Note Number" AS "VIN",
system_project_c."Primary Customer Name" AS "Homeowner Name",
"Credit Notes"."Created Date",
"Credit Notes"."Credit Note Total" AS "Invoice Total2",
NULL::text AS "Hold Status",
"Accounts"."Account Type (1)" AS "Dealer/Vendor",
'Credit Note'::text AS "Invoice Type"
FROM sfdc_staging.vw_c2g__codapurchasecreditnote__c "Credit Notes"
JOIN transaction_c
ON "Credit Notes"."Record ID"::text = transaction_c."Payable Credit Note"::text
JOIN sfdc_staging.vw_c2g__codacompany__c "Companies"
ON "Credit Notes"."Company"::text = "Companies"."Record ID"::text
JOIN sfdc_staging.vw_c2g__codaperiod__c "Coda Period"
ON "Credit Notes"."Period"::text = "Coda Period"."Record ID"::text
LEFT JOIN system_project_c ON "Credit Notes"."System"::text = system_project_c."System"::text
JOIN included_accounts "Accounts"
ON "Credit Notes"."Account"::text = "Accounts"."Account ID (2)"::text AND
("Credit Notes"."Credit Note Status"::text <> ALL
(ARRAY ['Discarded'::character varying::text, 'In Progress'::character varying::text]))
WHERE CASE
WHEN "Credit Notes"."Credit Note Status"::text <> 'Complete'::text THEN 'Not Applicable'::text
WHEN transaction_c."Document Outstanding Total" = 0::numeric THEN 'Paid'::text
WHEN transaction_c."Document Total" = transaction_c."Document Outstanding Total"
THEN 'Unpaid'::text
ELSE 'Part Paid'::text
END = ANY (ARRAY ['Unpaid'::text, 'Not Applicable'::text, 'Part Paid'::text]))
SELECT payable_invoices."PIN",
payable_invoices."Account",
payable_invoices."Company",
payable_invoices."Due Date",
payable_invoices."Invoice Date",
payable_invoices."Invoice Status",
payable_invoices."Invoice Total",
payable_invoices."Payment Status",
payable_invoices."Period",
payable_invoices."System Project",
payable_invoices."Project Stage",
payable_invoices."Payment Method",
payable_invoices."VIN",
payable_invoices."Homeowner Name",
payable_invoices."Created Date",
payable_invoices."Invoice Total2",
payable_invoices."Hold Status",
payable_invoices."Dealer/Vendor",
payable_invoices."Invoice Type"
FROM payable_invoices
UNION ALL
SELECT credit_notes."PIN",
credit_notes."Account",
credit_notes."Company",
credit_notes."Due Date",
credit_notes."Invoice Date",
credit_notes."Invoice Status",
credit_notes."Invoice Total",
credit_notes."Payment Status",
credit_notes."Period",
credit_notes."System Project",
credit_notes."Project Stage",
credit_notes."Payment Method",
credit_notes."VIN",
credit_notes."Homeowner Name",
credit_notes."Created Date",
credit_notes."Invoice Total2",
credit_notes."Hold Status",
credit_notes."Dealer/Vendor",
credit_notes."Invoice Type"
FROM credit_notes;
alter table vw_ap_payments
owner to fusionods_master;
grant delete, insert, references, select, trigger, truncate, update on vw_ap_payments to group_admin;
grant select on vw_ap_payments to group_poweruser;
grant select on vw_ap_payments to group_accounts_payable;
-- dealer_base_systems.sql
WITH portfolio_systems AS (
-- Systems from the TEP Backleverage Borrowing Base as of 3/19/25
SELECT DISTINCT "System Project" AS system_id, 'TEP 3/19/25' AS portfolio
FROM vw_ap_payments
WHERE "System Project" IN (
SELECT system_id
FROM :borrowing_base_table_tep_mar
)
UNION ALL
-- Systems from the TEP Backleverage Borrowing Base as of 4/16/25
SELECT DISTINCT "System Project" AS system_id, 'TEP 4/16/25' AS portfolio
FROM vw_ap_payments
WHERE "System Project" IN (
SELECT system_id
FROM :borrowing_base_table_tep_apr
)
UNION ALL
-- Systems from the SLA as of 4/11/25
SELECT DISTINCT "System Project" AS system_id, 'SLA 4/11/25' AS portfolio
FROM vw_ap_payments
WHERE "System Project" IN (
SELECT system_id
FROM :borrowing_base_table_sla
)
)
SELECT
system_id AS "Sunnova System ID",
portfolio AS "Portfolio"
FROM portfolio_systems
WHERE system_id IS NOT NULL
ORDER BY portfolio, system_id;
-- ods.vw_sunstreet_einstein_data source
CREATE OR REPLACE VIEW ods.vw_sunstreet_einstein_data
AS SELECT a."Builder Cost Center",
a."Project Number",
a."Account Details Name" AS "Account Name",
a."Inception Date" AS "Inception Date (Year - Month - Day)",
a."System" AS "System ID",
s."System Name",
a."First Close Date",
a."Home Status",
s."Asset Portfolio - Customer",
a."ITC Owner",
p."Number of Modules" AS "Number of Panels",
p."Panel Size (W)" AS "Panel Size",
p."System Size (W)" AS "System Size",
r."Comp Cost, Material" AS "Material Cost - Component",
r."Comp Cost, Labor" AS "Labor Cost - Component",
r."Comp Cost, Material Ohd" AS "Overhead Material Cost - Component",
r."Total Comp Cost" AS "Total Cost - Component",
r."Operation Cost, Machine Ohd" AS "Overhead Machine Cost - Operations",
r."Total Operation Cost" AS "Total Cost - Operations",
q."Total System Cost",
q."Total Sunnova Purchased Equipment Cost",
b."Sum of Sales Invoice Price" AS "Sales Invoice Price",
wo.design_total_price AS "design_work_order.TotalPrice",
wo.rough_install_total_price AS "rough_install_work_order.TotalPrice",
wo.pv_install_total_price AS "pv_install_work_order.TotalPrice",
wo.commissioning_total_price AS "Commissioning_work_order.TotalPrice",
wo.adder_total_price AS "adder_work_order.TotalPrice",
wo.cf6r_total_price AS "cf6r_work_order.TotalPrice",
wo.interconnection_fees_total_price AS "interconnection_fee_work_order.TotalPrice",
wo.permit_fees_total_price AS "permit_fees__work_order.TotalPrice",
wo.pre_wire_total_price AS "pre_wire_work_order.TotalPrice",
wo.fees_total_price AS "fees_work_order.TotalPrice"
FROM sfdc_staging.vw_account_details__c a
LEFT JOIN sfdc_staging.vw_system__c s ON s."Record ID"::text = a."System"::text
LEFT JOIN sfdc_staging.vw_pvsyst_2__c p ON a."PVSyst"::text = p."Record ID"::text
LEFT JOIN sfdc_staging.vw_rstk__wocst__c r ON r."Record ID"::text = a."Material Work Order"::text
LEFT JOIN sfdc_staging.vw_quote__c q ON q."System"::text = a."System"::text
LEFT JOIN ( SELECT i."Account",
sum(i."Invoice Total") AS "Sum of Sales Invoice Price"
FROM sfdc_staging.vw_c2g__codainvoice__c i
GROUP BY i."Account") b ON b."Account"::text = a."Account"::text
LEFT JOIN ( SELECT ct."Account Details",
sum(
CASE
WHEN ct."Order Type"::text = ANY (ARRAY['PV Design'::character varying, 'PV Design Plus'::character varying, 'Revision'::character varying, 'Consumption Study'::character varying, 'Electrical Engineering'::character varying, 'Master Set'::character varying, 'Shade Analysis'::character varying, 'Structural Engineering'::character varying]::text[]) THEN ct.total_price
ELSE NULL::numeric
END) AS design_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'Rough Install'::text THEN ct.total_price
ELSE NULL::numeric
END) AS rough_install_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'PV Install'::text THEN ct.total_price
ELSE NULL::numeric
END) AS pv_install_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'Adder'::text THEN ct.total_price
ELSE NULL::numeric
END) AS adder_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'CF6R'::text THEN ct.total_price
ELSE NULL::numeric
END) AS cf6r_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'Interconnection Fees'::text THEN ct.total_price
ELSE NULL::numeric
END) AS interconnection_fees_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'Permit Fees'::text THEN ct.total_price
ELSE NULL::numeric
END) AS permit_fees_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'Pre-Wire'::text THEN ct.total_price
ELSE NULL::numeric
END) AS pre_wire_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'Fees'::text THEN ct.total_price
ELSE NULL::numeric
END) AS fees_total_price,
sum(
CASE
WHEN ct."Order Type"::text = 'Commissioning'::text THEN ct.total_price
ELSE NULL::numeric
END) AS commissioning_total_price
FROM ( SELECT t."Account Details",
t."Order Type",
sum(t."Total Price") AS total_price
FROM sfdc_staging.vw_workorder t
WHERE t."Status"::text <> 'Canceled'::text AND (t."Order Type"::text = ANY (ARRAY['PV Design'::character varying, 'PV Design Plus'::character varying, 'Revision'::character varying, 'Rough Install'::character varying, 'PV Install'::character varying, 'Adder'::character varying, 'CF6R'::character varying, 'Interconnection Fees'::character varying, 'Permit Fees'::character varying, 'Pre-Wire'::character varying, 'Fees'::character varying, 'Commissioning'::character varying, 'Consumption Study'::character varying, 'Electrical Engineering'::character varying, 'Master Set'::character varying, 'Shade Analysis'::character varying, 'Structural Engineering'::character varying]::text[]))
GROUP BY t."Account Details", t."Order Type") ct
GROUP BY ct."Account Details") wo ON wo."Account Details"::text = a."Record ID (1)"::text
WHERE a."First Close Date" IS NOT NULL AND a."First Close Date" >= (CURRENT_DATE - '2 years'::interval);
Python Modules¶
This datatape includes additional Python modules with business logic:
dealer_transactions_explorer¶
assemble_dashboard(create_summary_tab, create_distributions_tab, create_trends_tab, display_ui_and_error, load_data_and_populate_filters, mo)
¶
Assembles the final dashboard layout.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
build_filters(load_data_and_populate_filters, pd, datetime, DATE_COL, PORTFOLIO_GROUP_COL, DEALER_COL, STAGE_COL, APPLICATION_COL, PAYMENT_STATUS_COL)
¶
Builds the SQL WHERE clause based on filter values.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
create_distributions_tab(build_filters, load_data_and_populate_filters, mo, px)
¶
Generates the content for the Distributions tab.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | |
create_summary_tab(build_filters, load_data_and_populate_filters, mo, px, go, KEY_COL, AMOUNT_COL, DEALER_COL, SYSTEM_ID_COL)
¶
Generates the content for the Summary & Quality tab.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | |
create_trends_tab(build_filters, load_data_and_populate_filters, mo, px, pd, DATE_COL)
¶
Generates the content for the Trends tab.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 | |
create_ui_elements(mo, pd, datetime, timedelta, AMOUNT_COL)
¶
Define UI elements, populated later reactively.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
display_ui_and_error(load_data_and_populate_filters, create_ui_elements, mo)
¶
Displays file input and filters, or an error message.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
import_libs()
¶
Import libraries and return them for use in other cells.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
load_data_and_populate_filters(create_ui_elements, pd, duckdb, io, Path, mo, np, datetime, EXPECTED_COLS, DATE_COL, NUMERIC_COLS_FOR_DIST, CATEGORY_COLS_FOR_DIST, PORTFOLIO_GROUP_COL, DEALER_COL, STAGE_COL, APPLICATION_COL, PAYMENT_STATUS_COL, KEY_COL, SYSTEM_ID_COL, AMOUNT_COL)
¶
Loads data, registers with DuckDB, and populates filter options.
Source code in datatapes/dealer_transactions/dealer_transactions_explorer.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
dealer_explore¶
build_where_clause(update_filters, load_data, pd, datetime, DATE_COL, PORTFOLIO_GROUP_COL, DEALER_COL, STAGE_COL, APPLICATION_COL, PAYMENT_STATUS_COL)
¶
Builds the SQL WHERE clause based on potentially updated filter values.
Source code in datatapes/dealer_transactions/dealer_explore.py
display_ui(create_initial_ui, update_filters, load_data, mo)
¶
Displays the file input and dynamically updated filters.
Source code in datatapes/dealer_transactions/dealer_explore.py
load_data(create_initial_ui, Path, pd, DATE_COL, duckdb, EXPECTED_COLS, NUMERIC_COLS_FOR_DIST, np)
¶
Load data when the button is clicked.
Source code in datatapes/dealer_transactions/dealer_explore.py
update_filters(load_data, create_initial_ui, mo, pd, datetime, np, DATE_COL, PORTFOLIO_GROUP_COL, DEALER_COL, STAGE_COL, APPLICATION_COL, PAYMENT_STATUS_COL, KEY_COL, SYSTEM_ID_COL, CATEGORY_COLS_FOR_DIST, NUMERIC_COLS_FOR_DIST)
¶
Create updated filters based on loaded data.
Source code in datatapes/dealer_transactions/dealer_explore.py
dealer_transactions_report¶
Dealer Transactions Report Generator
This script generates a comprehensive report of dealer transactions including payables, credits, disbursements, and receipts for systems in three borrowing bases: 1. TEP Backleverage Borrowing Base as of 3/19/25 2. TEP Backleverage Borrowing Base as of 4/16/25 3. SLA Borrowing Base as of 4/11/25
The report includes transaction details such as transaction identifier, system ID, date, amount, dealer information, transaction type, payment status, and more.
add_custom_args(parser: argparse.ArgumentParser) -> None
¶
Add custom command line arguments to the parser.
Source code in datatapes/dealer_transactions/dealer_transactions_report.py
create_query_params(args: argparse.Namespace, config: NovaConfig) -> Dict[str, Any]
¶
Create query parameters based on command line arguments.
Source code in datatapes/dealer_transactions/dealer_transactions_report.py
main() -> int
¶
Main entry point for the script.
Source code in datatapes/dealer_transactions/dealer_transactions_report.py
process_dealer_transactions(data_frames: Dict[str, pd.DataFrame], config: NovaConfig, console: Optional[Console] = None) -> pd.DataFrame
¶
Process dealer transaction data with specialized filtering and formatting.
Parameters¶
data_frames : Dict[str, pd.DataFrame] Dictionary containing the data frames retrieved from SQL queries. Expected key: "transactions" config : NovaConfig Configuration object containing processing settings console : Optional[Console] Rich console for output
Returns¶
pd.DataFrame Processed DataFrame containing dealer transaction information
Source code in datatapes/dealer_transactions/dealer_transactions_report.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |