Skip to content

Commit

Permalink
Set last_psync_shortfall in replacements when active consumer psyncs
Browse files Browse the repository at this point in the history
That way, if the invoice is not paid, the replacements won't reinvoice
for the same change when they become active.
  • Loading branch information
Mark Dominus committed Jul 12, 2012
1 parent 8a61089 commit cbe33e0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Moonpig/Role/Consumer/ByTime.pm
Expand Up @@ -371,6 +371,11 @@ has last_psync_shortfall => (
traits => [ qw(Copy) ],
);

sub reset_last_psync_shortfall {
my ($self) = @_;
$self->last_psync_shortfall($self->_predicted_shortfall);
}

sub _maybe_send_psync_quote {
my ($self) = @_;
return unless $self->is_active;
Expand Down Expand Up @@ -415,6 +420,12 @@ sub _maybe_send_psync_quote {

$self->ledger->_send_psync_email($self, $notice_info);

# Notify followers that we have already handled this shortfall
# so they don't send another notice on becoming active.
for my $c ($self->replacement_chain) {
$c->reset_last_psync_shortfall if $c->can('reset_last_psync_shortfall');
}

$_->mark_abandoned() for @old_quotes;
}

Expand Down

0 comments on commit cbe33e0

Please sign in to comment.