Revision 714
- Date:
- 2018/08/17 20:29:17
- Files:
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/webshop/lib/webshop/Order.pm
81 81 ) 82 82 } 83 83 84 sub recount { 85 my $self = shift; 86 my $basket = $self->keeper->{webshop}->get_basket( order_id => $self->id ); 87 my $store = 0; 88 if ( ref $basket && @$basket ) { 89 my $sum = 0; 90 foreach my $bi ( @$basket ) { 91 $sum += $bi->price * $bi->number; 92 } 93 if ( $sum != $self->sum ) { 94 $self->sum( $sum ); 95 $store = 1; 96 } 97 my $coupons = $self->keeper->get_documents( 98 class => 'webshop::Coupon', 99 lclass => 'webshop::OrderCouponLink', 100 ); 101 } 102 if ( $store ) { 103 $self->store; 104 } 105 } 84 106 85 107 sub sum_total { 86 108 my $self = shift; … … 177 199 $action = 'cancel'; 178 200 } 179 201 } 180 if ( $action ) { 181 my $op = payments::Operation->new( $keeper ); 182 $op->name( $action ); 183 $op->order_id( $self->id ); 184 $op->uid( $self->uid ); 185 if ( ref $user ) { 186 $op->uuid( $user->id ); 187 } 188 $op->sum( $self->sum_total ); 189 $op->store; 202 if ( $action && exists $keeper->{payments} ) { 203 my $op = $keeper->{payments}->add( order => $self, type => $action, ref $user ? (uuid => $user->id) : () ); 190 204 } 191 205 } 192 206 return 1;