This repository has been archived by the owner on Oct 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PurchaseOrderLineItem.ts
156 lines (156 loc) · 3.51 KB
/
PurchaseOrderLineItem.ts
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
/**
* Auto-generated file. Do not change.
*/
import { Address } from './Address'
import { HsCode } from './HsCode'
import { Metadata } from './Metadata'
import { Money } from './Money'
import { Place } from './Place'
import { Product } from './Product'
import { TransportationMode } from './TransportationMode'
import { Type } from './Type'
import { ApiCollectionRef } from '../types/ApiCollectionRef'
import { ApiObjectRef } from '../types/ApiObjectRef'
import { linkCollection } from '../links'
import { linkObject } from '../links'
import { Option } from 'fp-ts/lib/Option'
import { ResolvableCollection } from '../types/Link'
import { ResolvableObject } from '../types/Link'
import { TypedApiObject } from '../types/TypedApiObject'
export enum PurchaseOrderLineItemIncotermTypes {
EXW = 'EXW',
FOB = 'FOB',
FAS = 'FAS',
FCA = 'FCA',
CPT = 'CPT',
CFR = 'CFR',
CIF = 'CIF',
CIP = 'CIP',
DAT = 'DAT',
DAP = 'DAP',
DDP = 'DDP',
DPU = 'DPU',
}
export enum PurchaseOrderLineItemUnitOfMeasureTypes {
BBL = 'BBL',
CAR = 'CAR',
CGM = 'CGM',
CKG = 'CKG',
CM = 'CM',
CM2 = 'CM2',
CTN = 'CTN',
CYK = 'CYK',
DPC = 'DPC',
DPR = 'DPR',
DS = 'DS',
FBM = 'FBM',
G = 'G',
GBQ = 'GBQ',
GR = 'GR',
GRL = 'GRL',
HUN = 'HUN',
IRG = 'IRG',
JWL = 'JWL',
K = 'K',
KG = 'KG',
KM = 'KM',
KM3 = 'KM3',
KWH = 'KWH',
L = 'L',
LNM = 'LNM',
M = 'M',
M2 = 'M2',
M3 = 'M3',
MBQ = 'MBQ',
NO = 'NO',
OSG = 'OSG',
PCS = 'PCS',
PDG = 'PDG',
PFL = 'PFL',
PK = 'PK',
PRS = 'PRS',
PTG = 'PTG',
PX = 'PX',
RHG = 'RHG',
RUG = 'RUG',
T = 'T',
TDWB = 'TDWB',
W = 'W',
X = 'X',
}
export type PurchaseOrderLineItem = {
/**
* Type of the object
*/
readonly _object: Type.PurchaseOrderLineItem
/**
* Unique identifier for the line item on the latest version of the PO
*
* JSON-schema: integer
* @example 123456
*/
readonly id?: number
readonly purchase_order?: ApiObjectRef
/**
* JSON-schema: integer
* @example 1
*/
readonly line_item_number?: number
/**
* Custom identifier for the line item
*
* JSON-schema: string
* @example "item1"
*/
readonly item_key?: string
readonly product?: Product
/**
* JSON-schema: integer
*/
readonly units?: number
readonly unit_cost?: Money
readonly booking_line_items?: ApiCollectionRef
/**
* JSON-schema: string
* @example "FOB"
*/
readonly incoterm?: PurchaseOrderLineItemIncotermTypes
readonly transportation_mode?: TransportationMode
/**
* JSON-schema: string
* @example "BBL"
*/
readonly unit_of_measure?: PurchaseOrderLineItemUnitOfMeasureTypes
/**
* JSON-schema: string (date)
* @example "1970-01-01"
*/
readonly must_arrive_date?: string
readonly origin_port?: Place
readonly origin_address?: Address
readonly destination_port?: Place
readonly destination_address?: Address
/**
* JSON-schema: array
*/
readonly hs_codes?: HsCode[]
readonly metadata?: Metadata
}
export type LiftedPurchaseOrderLineItem = TypedApiObject &
Omit<PurchaseOrderLineItem, 'purchase_order' | 'booking_line_items'> & {
readonly purchase_order: Option<ResolvableObject>
readonly booking_line_items: Option<ResolvableCollection>
}
/**
* Lifts an object return from a Flexport API responses into the SDK domain by augmenting them with higher level properties.
*/
export const liftPurchaseOrderLineItem = (
original: PurchaseOrderLineItem,
): LiftedPurchaseOrderLineItem => {
const { purchase_order, booking_line_items, ...rest } = original
return {
...rest,
purchase_order: linkObject(purchase_order),
booking_line_items: linkCollection(booking_line_items),
}
}