-
Notifications
You must be signed in to change notification settings - Fork 514
Fix CSV and directory export to use family address fallback #7964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
b54216d
4dbfd02
4284593
fcbba06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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", | ||||||
| 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", | ||||||
|
||||||
| format: "rollup", | |
| Format: "Rollup", |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 ?? ''); | ||
| } | ||
|
||
|
|
||
| // Check if we're filtering out people with incomplete addresses | ||
|
|
||
There was a problem hiding this comment.
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), butCSVCreateFile.phpreads$_POST['Format'](capital F) and the UI form usesname="Format"(seesrc/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 toFormat(and consider matching the UI values likeDefault/Rollup), and include any required date-range fields so the export returns real rows.