Skip to content

Commit

Permalink
feat(admin-ui): Allow manual payments to be added by Administrator
Browse files Browse the repository at this point in the history
Relates to #753.
  • Loading branch information
michaelbromley committed Nov 30, 2021
1 parent 107ca9a commit 0416869
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<button
class="btn btn-primary"
*ngIf="
order.state === 'ArrangingAdditionalPayment' &&
(order.state === 'ArrangingPayment' || order.state === 'ArrangingAdditionalPayment') &&
(hasUnsettledModifications(order) || 0 < outstandingPaymentAmount(order))
"
(click)="addManualPayment(order)"
Expand All @@ -29,7 +29,11 @@
</button>
<button
class="btn btn-primary"
*ngIf="order.state !== 'ArrangingAdditionalPayment' && 0 < outstandingPaymentAmount(order)"
*ngIf="
order.active === false &&
order.state !== 'ArrangingAdditionalPayment' &&
0 < outstandingPaymentAmount(order)
"
(click)="transitionToState('ArrangingAdditionalPayment')"
>
{{ 'order.arrange-additional-payment' | translate }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ import { SettleRefundDialogComponent } from '../settle-refund-dialog/settle-refu
})
export class OrderDetailComponent
extends BaseDetailComponent<OrderDetail.Fragment>
implements OnInit, OnDestroy {
implements OnInit, OnDestroy
{
detailForm = new FormGroup({});
history$: Observable<GetOrderHistory.Items[] | undefined>;
nextStates$: Observable<string[]>;
Expand Down Expand Up @@ -266,6 +267,7 @@ export class OrderDetailComponent
}

addManualPayment(order: OrderDetailFragment) {
const priorState = order.state;
this.modalService
.fromComponent(AddManualPaymentDialogComponent, {
closable: true,
Expand All @@ -291,10 +293,16 @@ export class OrderDetailComponent
switch (addManualPaymentToOrder.__typename) {
case 'Order':
this.notificationService.success(_('order.add-payment-to-order-success'));
return this.orderTransitionService.transitionToPreModifyingState(
order.id,
order.nextStates,
);
if (priorState === 'ArrangingAdditionalPayment') {
return this.orderTransitionService.transitionToPreModifyingState(
order.id,
order.nextStates,
);
} else {
return this.dataService.order
.transitionToState(this.id, 'PaymentSettled')
.pipe(mapTo('PaymentSettled'));
}
case 'ManualPaymentStateError':
this.notificationService.error(addManualPaymentToOrder.message);
return EMPTY;
Expand Down Expand Up @@ -518,9 +526,8 @@ export class OrderDetailComponent
return of(undefined);
}

const operations: Array<
Observable<RefundOrder.RefundOrder | CancelOrder.CancelOrder>
> = [];
const operations: Array<Observable<RefundOrder.RefundOrder | CancelOrder.CancelOrder>> =
[];
if (input.refund.lines.length) {
operations.push(
this.dataService.order
Expand Down

0 comments on commit 0416869

Please sign in to comment.