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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Address } from './address.js';
import { Assignment } from './assignment.js';
import { Company } from './company.js';
import { CountryTax } from './country_tax.js';
import { DomainTag } from './domain_tag.js';
import { Entity } from '../entity.js';
import { InternalTag } from './internal_tag.js';
import { Invoice } from './invoice.js';
import { Quote } from './quote.js';
import { Reminder } from './reminder.js';
import { Job } from './job.js';
import { MerchiFile } from './file.js';
import { User } from './user.js';
import { ShipmentItem } from './shipment_item.js';
import { ShipmentLog } from './shipment_log.js';
import { ShipmentMethod } from './shipment_method.js';
interface CalculateOptions {
strictEmbed?: boolean;
}
export class Shipment extends Entity {
protected static resourceName = 'shipments';
protected static singularName = 'shipment';
protected static pluralName = 'shipments';
@Shipment.property({type: Date})
public archived?: Date | null;
@Shipment.property()
public id?: number;
@Shipment.property()
public name?: string;
@Shipment.property()
public shipmentServiceBookingInfo?: string;
@Shipment.property()
public shipmentServiceQuote?: string;
@Shipment.property()
public pickUp?: boolean;
@Shipment.property({arrayType: 'InternalTag'})
public internalTags?: InternalTag[];
@Shipment.property({type: MerchiFile})
public shipmentLabel?: MerchiFile | null;
@Shipment.property({type: Date})
public creationDate?: Date | null;
@Shipment.property({type: Date})
public dispatchedDate?: Date | null;
@Shipment.property({type: Date})
public dispatchDate?: Date | null;
@Shipment.property({type: Date})
public expectedReceiveDate?: Date | null;
@Shipment.property({type: Date})
public receivedDate?: Date | null;
@Shipment.property()
public senderResponsible?: boolean;
@Shipment.property({type: String})
public senderNotes?: string | null;
@Shipment.property({type: String})
public receiverNotes?: string | null;
@Shipment.property({type: Number})
public transportCompany?: number | null;
@Shipment.property({type: String})
public transportCompanyName?: string | null;
@Shipment.property({type: String})
public trackingNumber?: string | null;
@Shipment.property({type: Number})
public buyCost?: number | null;
@Shipment.property({type: String})
public buyCurrency?: string | null;
@Shipment.property({type: Number})
public cost?: number | null;
@Shipment.property({type: Number})
public taxAmount?: number | null;
@Shipment.property({type: Number})
public maxWeight?: number | null;
@Shipment.property({type: Number})
public maxVolume?: number | null;
@Shipment.property()
public sendSms?: boolean;
@Shipment.property()
public sendEmail?: boolean;
@Shipment.property({type: CountryTax})
public taxType?: CountryTax | null;
@Shipment.property()
public isOnBehalfOf?: boolean;
@Shipment.property({type: User})
public onBehalfOf?: User | null;
@Shipment.property({type: Company})
public onBehalfOfCompany?: Company | null;
@Shipment.property({type: User})
public sender?: User | null;
@Shipment.property({type: Company})
public senderCompany?: Company | null;
@Shipment.property({type: Address})
public senderAddress?: Address | null;
@Shipment.property({type: String})
public blindShipTo?: string | null;
@Shipment.property({type: User})
public receiver?: User | null;
@Shipment.property({type: Company})
public receiverCompany?: Company | null;
@Shipment.property({type: Address})
public receiverAddress?: Address | null;
@Shipment.property({arrayType: 'Invoice'})
public invoices?: Invoice[];
@Shipment.property({type: Quote})
public quote?: Quote | null;
@Shipment.property({type: ShipmentMethod})
public shipmentMethod?: ShipmentMethod | null;
@Shipment.property({arrayType: 'DomainTag'})
public tags?: DomainTag[];
@Shipment.property({arrayType: 'Assignment'})
public assignments?: Assignment[];
@Shipment.property({arrayType: 'ShipmentItem'})
public items?: ShipmentItem[];
@Shipment.property({arrayType: 'Job'})
public jobs?: Job[];
@Shipment.property({arrayType: 'Reminder'})
public reminders?: Reminder[];
@Shipment.property({ arrayType: 'ShipmentLog' })
public logs?: ShipmentLog[];
public calculateSubTotal = (options?: CalculateOptions) => {
const { strictEmbed = true } = options ? options : {};
Iif (strictEmbed){
Iif (this.cost === undefined) {
throw new Error('cost is undefined, did you forget to embed it?');
}
}
const cost = this.cost ? this.cost : 0;
return parseFloat(String(cost)).toFixed(3);
};
public calculateTaxAmount = (options?: CalculateOptions) => {
const taxPercent = this.taxType && this.taxType.taxPercent ?
this.taxType.taxPercent : 0;
const taxRate = taxPercent ? Number(taxPercent) / 100 : 0;
return (parseFloat(
this.calculateSubTotal(options)) * taxRate).toFixed(3);
};
public calculateTotal = (options?: CalculateOptions) => {
return (
parseFloat(this.calculateSubTotal(options)) +
parseFloat(this.calculateTaxAmount(options))
).toFixed(3);
};
}
|