Skip to content

[Merton][Echo] Amend Bulky collection on same date #5474

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MorayMySoc
Copy link
Contributor

When amending a bulky booking but keeping the same collection date, don't cancel the report.

Use an update on the report to send the data to Open311 and do the update to same booking.

https://github.com/mysociety/societyworks/issues/4732

When amending a bulky booking but keeping the same
collection date, don't cancel the report.

Use an update on the report to send the data to Open311
and do the update to same booking.

mysociety/societyworks#4732
@MorayMySoc MorayMySoc requested a review from dracos April 22, 2025 08:58
Copy link

codecov bot commented Apr 22, 2025

Codecov Report

Attention: Patch coverage is 95.34884% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.40%. Comparing base (16eced5) to head (7c433f3).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
perllib/FixMyStreet/Roles/Cobrand/Echo.pm 92.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5474      +/-   ##
==========================================
+ Coverage   82.30%   82.40%   +0.10%     
==========================================
  Files         428      428              
  Lines       34053    34861     +808     
  Branches     5511     5613     +102     
==========================================
+ Hits        28026    28726     +700     
- Misses       4396     4493      +97     
- Partials     1631     1642      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

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

This all looks good, made a few small comments.
It is missing one thing however - the fact that if the current date of the booking isn't included in the list of slot dates returned by Echo then it isn't shown to the user and they can't keep the same date. We need to make sure the current chosen date is always included in the list of returned dates for an amendment, so they can choose not to change it.

extra => $p->extra,
});
$c->forward( '/admin/log_edit', [ $c->cobrand->body->comment_user->id, 'problem', 'edit' ] );
$p->photo('');
Copy link
Member

Choose a reason for hiding this comment

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

Is this line needed? Looks like amend_extra_data always sets $p->photo anyway.

}
};
$p->set_extra_fields(@fields);
$p->update;
Copy link
Member

Choose a reason for hiding this comment

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

Is this line needed, as you call $p->update soon after anyway after amend_extra_data

sub update_report_for_same_day_amend {
my ($self, $p, $data) = @_;

my $collection_date = $p->get_extra_field_value('Collection_Date');
Copy link
Member

Choose a reason for hiding this comment

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

Note that this can be different per cobrand - Kingston/Sutton it is now Collection_Date_-_Bulky_Items (might need to also default back to this for old reports though, sorry).

category => $p->category,
extra => $p->extra,
});
$c->forward( '/admin/log_edit', [ $c->cobrand->body->comment_user->id, 'problem', 'edit' ] );
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this line - the Peterborough else case a few lines below doesn't have it, and the moderation entry is logging the change. Unless you think Peterborough should have it as well?

$p->add_to_comments( {
text => 'Amend ' . $p->category,
user => $c->cobrand->body->comment_user,
problem_state => $p->state,
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we want to set a flag on this rather than rely on precise comment text.

$self->save_item_names_to_report($data);

my @fields = @{$p->get_extra_fields};
for my $field (@fields) {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than this way round, could this loop over all the fields perhaps be instead:

foreach (qw(Bulky_Collection_Bulky_Items Bulky_Collection_Notes
    TEM_-_Bulky_Collection_Description TEM_-_Bulky_Collection_Item Exact_Location)) {
    if ($data->{"extra_$_"}) {
        $p->update_extra_field({ name => $_, value => $data->{"extra_$_"} });
    }
}

Does that work okay?

Copy link
Member

Choose a reason for hiding this comment

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

Could even put the cobrand specific fields in a cobrand function and then call it for the list here and in your open_311_bulky_update_same_date perhaps

Copy link
Member

@dracos dracos left a comment

Choose a reason for hiding this comment

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

Oh, sorry, just thought of another thing, sigh - if someone amends a booking and adds items that brings it above the lower payment threshold, they have to pay more. The way the current cancellation works is it creates unconfirmed cancellation update, and new report, then awaits payment confirmation before confirming the cancellation and the payment on the new report.

With this new way, hmm. We can in theory create the unconfirmed comment the same way, so it won't update Echo until payment confirmed (and we'll have to update the payment amount then paid on the report as well for any further amendments); but that still leaves the changing of the actual report with the new information. Do we... store the new data on the comment and then if payment is confirmed (or no payment necessary) copy the new data to the existing report at that point? Not sure I can think of an easier way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants