All files / examples/order-more/models order.ts

100% Statements 41/41
100% Branches 0/0
100% Functions 2/2
100% Lines 41/41

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          1x   1x                                                                                                                               47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x 47x             2x       1x            
import { UtmSource } from './utm-source';
import { Customer } from './customer';
import { PhysicalAddress } from './physical-address';
import { IModel, ICollection, IColumns } from '../../../src/index';
 
export const tableName: string = 'order';
 
export const columns: IColumns = [
  'id',
  'email',
  { column: 'customer_id', references: Customer },
  { column: 'shipping_address_id', references: PhysicalAddress },
  { column: 'billing_address_id', references: PhysicalAddress },
  'browser_ip',
  'browser_user_agent',
  'kujo_imported_date',
  'created_date',
  'cancel_reason',
  'cancelled_date',
  'closed_date',
  'processed_date',
  'updated_date',
  'note',
  'subtotal_price',
  'taxes_included',
  'total_discounts',
  'total_price',
  'total_tax',
  'total_weight',
  'order_status_url',
  { column: 'utm_source_id', references: UtmSource },
  'utm_medium_id',
  'utm_campaign',
  'utm_content',
  'utm_term'
];
 
export class Order implements IModel {
  id: number;
  email: string;
  customerId: number;
  customer?: Customer;
  shippingAddressId: number;
  shippingAddress?: PhysicalAddress;
  billingAddressId: number;
  billingAddress?: PhysicalAddress;
  browserIp: number;
  browserUserAgent: number;
  kujoImportedDate: Date;
  createdDate: Date;
  cancelReason: string;
  cancelledDate: Date;
  closedDate: Date;
  processedDate: Date;
  updatedDate: Date;
  note: string;
  subtotalPrice: number;
  taxesIncluded: boolean;
  totalDiscounts: number;
  totalPrice: number;
  totalTax: number;
  totalWeight: number;
  orderStatusUrl: string;
  utmSourceId: number;
  utmSource?: UtmSource;
  utmMediumId: number;
  utmCampaign: string;
  utmContent: string;
  utmTerm: string;
 
  constructor(props: any) {
    this.id = props.id;
    this.customerId = props.customerId;
    this.customer = props.customer;
    this.shippingAddressId = props.shippingAddressId;
    this.shippingAddress = props.shippingAddress;
    this.billingAddressId = props.billingAddressId;
    this.billingAddress = props.billingAddress;
    this.browserIp = props.browserIp;
    this.browserUserAgent = props.browserUserAgent;
    this.kujoImportedDate = props.kujoImportedDate;
    this.createdDate = props.createdDate;
    this.cancelReason = props.cancelReason;
    this.cancelledDate = props.cancelledDate;
    this.closedDate = props.closedDate;
    this.processedDate = props.processedDate;
    this.updatedDate = props.updatedDate;
    this.note = props.note;
    this.subtotalPrice = props.subtotalPrice;
    this.taxesIncluded = props.taxesIncluded;
    this.totalDiscounts = props.totalDiscounts;
    this.totalPrice = props.totalPrice;
    this.totalTax = props.totalTax;
    this.totalWeight = props.totalWeight;
    this.orderStatusUrl = props.orderStatusUrl;
    this.utmSourceId = props.utmSourceId;
    this.utmSource = props.utmSource;
    this.utmMediumId = props.utmMedium;
    this.utmCampaign = props.utmCampaign;
    this.utmContent = props.utmContent;
    this.utmTerm = props.utmTerm;
    this.email = props.email;
    this.subtotalPrice = props.subtotalPrice;
    this.taxesIncluded = props.taxesIncluded;
    this.totalDiscounts = props.totalDiscounts;
    this.totalPrice = props.totalPrice;
    this.utmSourceId = props.utmSourceId;
    this.utmSource = props.utmSource;
  }
}
 
export class Orders implements ICollection<Order> {
  models: Array<Order>;
  constructor({ models }: any) {
    this.models = models;
  }
}
 
export const orderEntity = {
  tableName,
  columns,
  Model: Order,
  Collection: Orders,
}