All files / src/app/core/utils/dev basket-mock-data.ts

100% Statements 10/10
60% Branches 3/5
100% Functions 9/9
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205                    48x   160x                         216x                                   1x                 13x                             400x                                             193x                 47x                                               174x                 186x                                                                                                                                                
import { Address } from 'ish-core/models/address/address.model';
import { BasketRebate } from 'ish-core/models/basket-rebate/basket-rebate.model';
import { BasketTotal } from 'ish-core/models/basket-total/basket-total.model';
import { BasketView } from 'ish-core/models/basket/basket.model';
import { LineItemView } from 'ish-core/models/line-item/line-item.model';
import { Order } from 'ish-core/models/order/order.model';
import { PaymentMethod } from 'ish-core/models/payment-method/payment-method.model';
import { Payment } from 'ish-core/models/payment/payment.model';
import { ShippingMethod } from 'ish-core/models/shipping-method/shipping-method.model';
 
export class BasketMockData {
  static getBasket(): BasketView {
    return {
      id: '4711',
      lineItems: [BasketMockData.getBasketItem()],
      invoiceToAddress: BasketMockData.getAddress(),
      commonShipToAddress: BasketMockData.getAddress(),
      commonShippingMethod: BasketMockData.getShippingMethod(),
      payment: BasketMockData.getPayment(),
      totals: BasketMockData.getTotals(),
      externalOrderReference: '111-222-333',
    } as BasketView;
  }
 
  static getBasketItem(): LineItemView {
    return {
      id: '4712',
      quantity: { value: 10 },
      productSKU: '4713',
      singleBasePrice: { gross: 3, net: 2, currency: 'USD', type: 'PriceItem' },
      price: { gross: 3, net: 2, currency: 'USD', type: 'PriceItem' },
      itemSurcharges: [
        {
          amount: {},
          description: 'test',
          displayName: 'test',
        },
      ],
      totals: {},
    } as LineItemView;
  }
 
  static getBasketUser(isB2BUser: boolean = false) {
    return {
      companyName: isB2BUser ? 'KlausInc.' : undefined,
      companyName2: isB2BUser ? 'Department Klaustown' : undefined,
      firstName: 'Klaus',
      lastName: 'Klausen',
    };
  }
 
  static getOrder() {
    return {
      id: '4711',
      documentNo: '12345678',
      customerNo: 'OilCorp',
      lineItems: [BasketMockData.getBasketItem()],
      invoiceToAddress: BasketMockData.getAddress(),
      commonShipToAddress: BasketMockData.getAddress(),
      commonShippingMethod: BasketMockData.getShippingMethod(),
      payment: BasketMockData.getPayment(),
      totals: BasketMockData.getTotals(),
    } as Order;
  }
 
  static getAddress(): Address {
    // spell-checker: disable
    return {
      urn: 'urn:address:customer:JgEKAE8BA50AAAFgDtAd1LZU:ilMKAE8BlIUAAAFgEdAd1LZU',
      id: 'ilMKAE8BlIUAAAFgEdAd1LZU',
      addressName: 'customeraddr-ABCDEFGPRMuMCscyXgSRVU',
      title: 'Ms.',
      firstName: 'Patricia',
      lastName: 'Miller',
      addressLine1: 'Potsdamer Str. 20',
      postalCode: '14483',
      phoneHome: '049364112677',
      country: 'Germany',
      countryCode: 'DE',
      city: 'Berlin',
      email: 'patricia@test.intershop.de',
      usage: [true, true],
      shipToAddress: true,
      invoiceToAddress: true,
      shipFromAddress: false,
    } as Address;
    // spell-checker: enable
  }
 
  static getShippingMethod(): ShippingMethod {
    return {
      id: 'STD_GRD',
      name: 'Standard Ground',
      shippingTimeMin: 3,
      shippingTimeMax: 7,
    } as ShippingMethod;
  }
 
  static getPaymentMethod(): PaymentMethod {
    return {
      id: 'ISH_CreditCard',
      displayName: 'Credit Card',
      parameters: [
        {
          key: 'IBAN',
          type: 'input',
          props: {
            type: 'text',
            required: true,
          },
        },
      ],
      paymentInstruments: [
        {
          id: 'instrumentId',
          accountIdentifier: '*******4321',
        },
      ],
      saveAllowed: true,
    } as PaymentMethod;
  }
 
  static getPayment(): Payment {
    return {
      displayName: 'Invoice',
      paymentInstrument: { id: 'ISH_INVOICE' },
      id: 'open-tender',
      status: 'Unprocessed',
    } as Payment;
  }
 
  static getTotals(): BasketTotal {
    return {
      itemTotal: {
        gross: 141796.98,
        currency: 'USD',
        type: 'PriceItem',
      },
      itemRebatesTotal: {
        gross: 4446,
        currency: 'USD',
        type: 'PriceItem',
      },
      shippingTotal: {
        gross: 87.06,
        currency: 'USD',
        type: 'PriceItem',
      },
      itemShippingRebatesTotal: {
        gross: 0,
        currency: 'USD',
        type: 'PriceItem',
      },
      valueRebatesTotal: {
        gross: 4457.9,
        currency: 'USD',
        type: 'PriceItem',
      },
      shippingRebatesTotal: {
        gross: 0,
        currency: 'USD',
        type: 'PriceItem',
      },
      paymentCostsTotal: {
        gross: 3.57,
        currency: 'USD',
        type: 'PriceItem',
      },
      taxTotal: {
        value: 22747.55,
        currency: 'USD',
        type: 'Money',
      },
      total: {
        gross: 142470.71,
        net: 13000.0,
        currency: 'USD',
        type: 'PriceItem',
      },
      valueRebates: [
        {
          amount: {
            gross: 11.9,
            currency: 'USD',
            type: 'PriceItem',
          },
          rebateType: 'OrderValueOffDiscount',
        } as BasketRebate,
      ],
      itemSurchargeTotalsByType: [
        {
          amount: {
            gross: 595,
            currency: 'USD',
            type: 'PriceItem',
          },
          description: 'Surcharge for battery deposit',
          displayName: 'Battery Deposit Surcharge',
        },
      ],
      isEstimated: false,
    } as BasketTotal;
  }
}