Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions cypress/e2e/ui/reports/standard.csv.reports.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,68 @@ describe("csv export", () => {
expect(response.body).to.not.include("Parse error");
});
});

it("should include address columns in CSV export with family fallback", () => {
// Test default format (format=0) includes address fields when requested
cy.request({
method: "POST",
url: "/CSVCreateFile.php",
form: true,
body: {
output: "csv",
format: "default",
familyonly: "false",
Comment on lines 31 to 38
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request body uses format (lowercase), but CSVCreateFile.php reads $_POST['Format'] (capital F) and the UI form uses name="Format" (see src/CSVExport.php). With the current payload this test may not exercise the intended code path (and can trigger unintended default filters). Update the POST parameter to Format (and consider matching the UI values like Default/Rollup), and include any required date-range fields so the export returns real rows.

Copilot uses AI. Check for mistakes.
Source: "all",
Address1: "1",
Address2: "1",
City: "1",
State: "1",
Zip: "1"
}
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers["content-type"]).to.include("text/csv");

// Verify CSV header contains address columns
const lines = response.body.split('\n');
expect(lines.length).to.be.greaterThan(1);
const header = lines[0].toLowerCase();
expect(header).to.include("address 1");
expect(header).to.include("city");
expect(header).to.include("state");
});
});

it("should include address columns in rollup format CSV export", () => {
// Test rollup format includes address fields when requested
cy.request({
method: "POST",
url: "/CSVCreateFile.php",
form: true,
body: {
output: "csv",
format: "rollup",
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue here: the test posts format: "rollup", but the endpoint expects Format (capital F). As written, this may not actually be testing rollup behavior and could silently return an empty export/header-only response due to missing expected filters. Use Format: "Rollup" (or at least Format: "rollup") and post the other form fields the script assumes are present.

Suggested change
format: "rollup",
Format: "Rollup",

Copilot uses AI. Check for mistakes.
familyonly: "false",
Source: "all",
Address1: "1",
Address2: "1",
City: "1",
State: "1",
Zip: "1"
}
}).then((response) => {
expect(response.status).to.eq(200);
expect(response.headers["content-type"]).to.include("text/csv");

// Verify CSV header contains address columns
const lines = response.body.split('\n');
expect(lines.length).to.be.greaterThan(1);
const header = lines[0].toLowerCase();
expect(header).to.include("address 1");
expect(header).to.include("city");
expect(header).to.include("state");
});
});
});

describe("advanced deposit report", () => {
Expand Down
39 changes: 20 additions & 19 deletions src/CSVCreateFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,31 +374,32 @@
extract($aRow);
$person = PersonQuery::create()->findOneById($per_ID);

// Use person data only - each person must enter their own information
// Use person data with fallback to family data for addresses
// This ensures members without personal addresses still get exported with their family's address
if ($sFormat === 'rollup') {
// Even in rollup format, use person data (no family inheritance)
$sHomePhone = $per_HomePhone ?? '';
// Rollup format: use person data with family fallback for address/contact fields
$sHomePhone = !empty($per_HomePhone) ? $per_HomePhone : ($fam_HomePhone ?? '');
$sWorkPhone = $per_WorkPhone ?? '';
$sCellPhone = $per_CellPhone ?? '';
$sCountry = $per_Country ?? '';
$sAddress1 = $per_Address1 ?? '';
$sAddress2 = $per_Address2 ?? '';
$sCity = $per_City ?? '';
$sState = $per_State ?? '';
$sZip = $per_Zip ?? '';
$sEmail = $per_Email ?? '';
$sCountry = !empty($per_Country) ? $per_Country : ($fam_Country ?? '');
$sAddress1 = !empty($per_Address1) ? $per_Address1 : ($fam_Address1 ?? '');
$sAddress2 = !empty($per_Address2) ? $per_Address2 : ($fam_Address2 ?? '');
$sCity = !empty($per_City) ? $per_City : ($fam_City ?? '');
$sState = !empty($per_State) ? $per_State : ($fam_State ?? '');
$sZip = !empty($per_Zip) ? $per_Zip : ($fam_Zip ?? '');
$sEmail = !empty($per_Email) ? $per_Email : ($fam_Email ?? '');
} else {
// Individual data - use person data only
$sHomePhone = $per_HomePhone ?? '';
// Default format: use person data with family fallback for address/contact fields
$sHomePhone = !empty($per_HomePhone) ? $per_HomePhone : ($fam_HomePhone ?? '');
$sWorkPhone = $per_WorkPhone ?? '';
$sCellPhone = $per_CellPhone ?? '';
$sCountry = $per_Country ?? '';
$sAddress1 = $per_Address1 ?? '';
$sAddress2 = $per_Address2 ?? '';
$sCity = $per_City ?? '';
$sState = $per_State ?? '';
$sZip = $per_Zip ?? '';
$sEmail = $per_Email ?? '';
$sCountry = !empty($per_Country) ? $per_Country : ($fam_Country ?? '');
$sAddress1 = !empty($per_Address1) ? $per_Address1 : ($fam_Address1 ?? '');
$sAddress2 = !empty($per_Address2) ? $per_Address2 : ($fam_Address2 ?? '');
$sCity = !empty($per_City) ? $per_City : ($fam_City ?? '');
$sState = !empty($per_State) ? $per_State : ($fam_State ?? '');
$sZip = !empty($per_Zip) ? $per_Zip : ($fam_Zip ?? '');
$sEmail = !empty($per_Email) ? $per_Email : ($fam_Email ?? '');
}
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rollup and default branches now perform the same address/contact-field assignments. This conditional duplication makes the code harder to maintain (any future change must be applied twice). Consider collapsing this into a single assignment block (or a small helper) and only branching where rollup/default behavior actually differs.

Copilot uses AI. Check for mistakes.

// Check if we're filtering out people with incomplete addresses
Expand Down
17 changes: 9 additions & 8 deletions src/Reports/DirectoryReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,17 @@
$pdf->sRecordName .= ' ' . MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, $per_Flags);
}

// Use person data only - each person must enter their own information
$sAddress1 = $per_Address1 ?? '';
$sAddress2 = $per_Address2 ?? '';
$sCity = $per_City ?? '';
$sState = $per_State ?? '';
$sZip = $per_Zip ?? '';
$sHomePhone = $per_HomePhone ?? '';
// Use person data with fallback to family data for addresses
// This ensures members without personal addresses still appear in the directory with their family's address
$sAddress1 = !empty($per_Address1) ? $per_Address1 : ($fam_Address1 ?? '');
$sAddress2 = !empty($per_Address2) ? $per_Address2 : ($fam_Address2 ?? '');
$sCity = !empty($per_City) ? $per_City : ($fam_City ?? '');
$sState = !empty($per_State) ? $per_State : ($fam_State ?? '');
$sZip = !empty($per_Zip) ? $per_Zip : ($fam_Zip ?? '');
$sHomePhone = !empty($per_HomePhone) ? $per_HomePhone : ($fam_HomePhone ?? '');
$sWorkPhone = $per_WorkPhone ?? '';
$sCellPhone = $per_CellPhone ?? '';
$sEmail = $per_Email ?? '';
$sEmail = !empty($per_Email) ? $per_Email : ($fam_Email ?? '');

if ($bDirAddress) {
if (strlen($sAddress1)) {
Expand Down
Loading