File

projects/congarevenuecloud/elements/src/lib/promotion-modal/promotion-modal.component.ts

Description

This component is a work in progress.

Promotion modal component is used to show a modal window with all the details of promotions that are applied to items in the cart.

Preview

Usage

Example :
import { PromotionModalModule } from '@congarevenuecloud/elements';

@NgModule({
imports: [PromotionModalModule, ...]
})
export class AppModule {}
Example :
```typescript
<apt-pr-modal></apt-pr-modal>
Example :

Implements

AfterViewInit

Metadata

Index

Properties
Methods
Inputs

Constructor

constructor(modalService: BsModalService, exceptionService: ExceptionService, cartItemService: CartItemService, orderLineItemService: OrderLineItemService, quoteLineItemService: QuoteLineItemService, cartService: CartService, promotionService: PromotionService, incentiveService: IncentiveService)
Parameters :
Name Type Optional
modalService BsModalService No
exceptionService ExceptionService No
cartItemService CartItemService No
orderLineItemService OrderLineItemService No
quoteLineItemService QuoteLineItemService No
cartService CartService No
promotionService PromotionService No
incentiveService IncentiveService No

Inputs

cart
Type : Cart

Instance of a cart.

Methods

applyPromotions
applyPromotions(codes: Array, recordId: string)

Applies promotions to the lineitem record.

Parameters :
Name Type Optional Description
codes Array<string> No

array of promotion codes to apply.

recordId string No

The unique identifier of the record to which promotions should be applied.

Returns : void
openIncentiveModal
openIncentiveModal(record: Incentive)

Opens the modal dialog on promotion applied to the cart. It displays the list of adjustment lineitem created for the cart and the total adjusted amount of the incentive.

Parameters :
Name Type Optional Description
record Incentive No

is an object of type Incentive.

Returns : void
openLineItemModal
openLineItemModal(record: CartItem | OrderLineItem | QuoteLineItem)

Open the Modal popup when promotion(s) are applied to the lineItem of type CartItem | OrderLineItem | QuoteLineItem. It shows the details of adjustemntmentLineItems for the linetitems applied and the total adjusted amount.

Parameters :
Name Type Optional Description
record CartItem | OrderLineItem | QuoteLineItem No

consists of object type of CartItem | OrderLineItem | QuoteLineItem.

Returns : void
removePromotions
removePromotions(codes: Array, recordId: string)

Removes promotions from the lineitem record.

Parameters :
Name Type Optional Description
codes Array<string> No

array of promotion codes to be removed.

recordId string No

The unique identifier of the record to which promotions should be applied.

Returns : void
updatePromotion
updatePromotion(codes: Array)

Updates promotions for the lineitem record based on the given array of promotion codes.

Parameters :
Name Type Optional Description
codes Array<string> No

array of promotion codes to apply or remove from the record.

Returns : void

Properties

adjustmentLI
Type : Array<AdjustmentItem>
Default value : []
adjustmentList$
Type : Observable<Array<AdjustmentItem>>

Observable of list of AdjustmentItems.

cartRecord
Type : Cart
disable
Type : boolean
incentive
Default value : new Incentive()
Public modalRef
Type : BsModalRef

reference for modal popup.

picklistValues
Type : Array<ComplexArray>
Default value : []
promoCode
Type : string | Array<string>
promoState
Type : string | Array<string>
promotionAppliedToTemplate
Type : TemplateRef<any>
Decorators :
@ViewChild('promotionAppliedToTemplate')
readOnly
Type : boolean
Default value : false
record$
Type : Observable<Incentive | CartItem | OrderLineItem | QuoteLineItem>

Observable of AObject record type of Incentive | CartItem | OrderLineItem | QuoteLineItem.

showApplyPromotion
Type : boolean
Default value : true
totalAmt$
Type : Observable<number>

Observable to store the total amount of promotion applied.

<ng-template #appliedPromotionTemplate>
  <div class="modal-header d-flex flex-row-reverse px-0 pb-1">
    <button type="button" class="close close-button pull-right pt-3" aria-label="Close" (click)="modalRef.hide()">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>
  <ng-container *ngIf="record$ | async as record; else loadingA">
    <div class="modal-body bg-white small">
      <div *ngIf="showApplyPromotion">
        <div class="pb-3">
          <h5 class="modal-title">{{'PROMOTION.PROMOTIONS' | translate}}</h5>
        </div>
        <form class="pb-1">
          <apt-input-field [entity]="incentive" [field]="'Name'" [fieldType]="'multipicklist'"
            [displayFieldType]="'dropdown'" [showLabel]="false" [(ngModel)]="promoCode" [readonly]="readOnly"
            [ngModelOptions]="{standalone: true}" [picklistValues]="picklistValues"
            (focusout)="updatePromotion(promoCode)"></apt-input-field>
        </form>
      </div>
      <div class="pb-3" *ngIf="adjustmentLI.length >0">
        <h5 class="modal-title">{{'PROMOTION.APPLIED_PROMOTIONS' | translate}}</h5>
      </div>
      <span *ngIf="adjustmentLI.length >0">
        {{'PROMOTION.PROMOTION_APPLIED' | translate}} <strong [innerHTML]="record?.Product?.Name"></strong>
      </span>
      <ul class="list-group mt-3 overflow-auto" *ngIf="adjustmentLI.length >0">
        <li class="list-group-item dashed-border border-secondary bg-light d-flex justify-content-between"
          *ngFor="let adjustment of adjustmentLI">
          <div>
            <div class="d-flex align-items-center">
              <div class="font-weight-bold">{{adjustment?.Incentive?.Name}}</div>
              <span class="badge badge-success ml-2">{{adjustment.CouponCode ? adjustment.CouponCode :
                adjustment?.IncentiveCode}}</span>
            </div>
            <p [innerHTML]="adjustment?.Incentive?.Description"></p>

            <small class="text-muted">
              {{adjustment?.Incentive?.ExpirationDate | date:'mediumDate'}} <span class="mx-2">|</span>
              {{adjustment?.LineType}}
            </small>
          </div>
          <div class="d-flex align-items-center">
            <span class="badge badge-info p-2">{{adjustment?.IncentiveAdjustmentAmount | localCurrency | async}}</span>
          </div>
        </li>
      </ul>
    </div>


  </ng-container>
  <div class="modal-footer bg-white d-flex justify-content-between font-weight-bold" *ngIf="adjustmentLI.length >0">
    <span>{{'PROMOTION.TOTAL_PROMOTION_AMOUNT' | translate}}</span>
    <span>{{totalAmt$ | async | localCurrency | async}}</span>
  </div>
  <ng-template #loadingA>
    <div class="d-flex justify-content-center my-5">
      <apt-dots></apt-dots>
    </div>
  </ng-template>
</ng-template>

<ng-template #promotionAppliedToTemplate>
  <div class="modal-header d-flex flex-row-reverse px-0 pb-1">
    <button type="button" class="close close-button pull-right pt-3" aria-label="Close" (click)="modalRef.hide()">
      <span aria-hidden="true">&times;</span>
    </button>
  </div>
  <div class="modal-body bg-white small">
    <div class="pb-3">
      <h5 class="modal-title">{{'PROMOTION.PROMOTION_APPLIEDTO' | translate}}</h5>
    </div>
    <ng-container *ngIf="record$ | async as record">
      <p>
        {{'PROMOTION.TITLE' | translate}} <strong>{{record?.Name}}</strong>
        {{'PROMOTION.APPLIED_PROMOTION' | translate}}
      </p>

      <table class="table table-sm table-responsive" *ngIf="adjustmentList$ | async as adjustmentList; else loadingB">
        <thead>
          <tr>
            <th scope="col">
              <apt-output-field [record]="adjustmentList[0]?.LineItem?.Product" field="Name" [labelOnly]="true">
              </apt-output-field>
            </th>
            <th scope="col">
              <apt-output-field [record]="adjustmentList[0]?._metadata?.columns?.LineItem?.Option" field="Name"
                [labelOnly]="true" label="Option">
              </apt-output-field>
            </th>
            <th scope="col">
              <apt-output-field [record]="adjustmentList[0]?.LineItem" field="ChargeType" [labelOnly]="true">
              </apt-output-field>
            </th>
            <th scope="col">
              <apt-output-field [record]="adjustmentList[0]?.LineItem" field="Quantity" [labelOnly]="true">
              </apt-output-field>
            </th>
            <th scope="col">
              <apt-output-field [record]="adjustmentList[0]?.LineItem" field="LineNumber" [labelOnly]="true">
              </apt-output-field>
            </th>
            <th scope="col">
              <apt-output-field [record]="adjustmentList[0]" field="IncentiveCode" [labelOnly]="true"
                *ngIf="!adjustmentList[0].CouponCode"></apt-output-field>
              <span *ngIf="adjustmentList[0].CouponCode">{{'PROMOTION.COUPON_CODE' | translate}}</span>
            </th>
            <th scope="col">
              <apt-output-field [record]="adjustmentList[0]" field="IncentiveAdjustmentAmount" [labelOnly]="true">
              </apt-output-field>
            </th>
          </tr>
        </thead>
        <tbody>
          <tr *ngFor="let item of adjustmentList">
            <td>{{item?.LineItem?.Product?.Name}}</td>
            <td>{{item?.LineItem?.Option?.Name}}</td>
            <td>{{item?.LineItem?.ChargeType}}</td>
            <td>{{item?.LineItem?.Quantity}}</td>
            <td>{{item?.LineItem?.LineNumber}}</td>
            <td>{{item?.CouponCode ? item?.CouponCode : item?.IncentiveCode}}</td>
            <td>{{item?.IncentiveAdjustmentAmount | localCurrency | async}}</td>
          </tr>
        </tbody>
      </table>

      <ng-template #loadingB>
        <div class="d-flex justify-content-center my-5">
          <apt-dots></apt-dots>
        </div>
      </ng-template>
    </ng-container>
    <div class="modal-footer d-flex justify-content-between font-weight-bold">
      <span>{{'PROMOTION.TOTAL_PROMOTION_AMOUNT' | translate}}</span>
      <span>{{totalAmt$ | async | localCurrency | async}}</span>
    </div>
  </div>
</ng-template>

./promotion-modal.component.scss

ul{
    height: 5.625rem !important;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""