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 | 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 45x 3x 3x 3x 3x 17x 1x 16x 2x 14x 12x 12x 12x 8x 6x | import { dataService } from '../../data';
import { DataObject, ObjectOptions } from "../base";
import { CreateObject } from "../item";
/**
* F: First change
* P: Price changed
* I: Invoice created
* D: Destination change
* C: Cancelled
*/
export type TicketChangeReason = 'F' | 'P' | 'I' | 'D' | 'C';
/****************************/
/* SCHEMA DEFINITION */
/****************************/
import { Ticketbai } from './ticketbai';
import { Verifactu } from './verfiactu';
import { TicketType } from '../model';
import { TicketChangeType } from '../model';
import { TicketbaiType } from '../model';
import { VerifactuType } from '../model';
import { SessionType } from '../model';
const _schema = {
"name": "TICKETCHANGE",
"fields": [
{ name: "ticket", type: "objid" },
{ name: "prev", type: "objid" },
{ name: "session", type: "objid" },
{ name: "client", type: "objid" },
{ name: "reason", type: "string" },
{ name: "series", type: "string" },
{ name: "invoice", type: "string" },
{ name: "total", type: "number" },
{ name: "base", type: "number" },
{ name: "taxes", type: "number" }
],
relate: [
{ direction: ">", target: "TICKET", by: "ticket", name: "ticket", reason: "ticket", child: false, class: TicketType },
{ direction: ">", target: "TICKETCHANGE", by: "prev", name: "prev", reason: "prev", child: false, class: TicketChangeType },
{ direction: ">", target: "SESSION", by: "session", name: "session", reason: "session", child: false, class: SessionType },
{ direction: ">", target: "TODO", by: "client", name: "client", reason: "client", child: false }, // TODO: more classes!!
{ direction: "<", target: "VERIFACTU", by: "tckchg", name: "verifactu", reason: "verifactus", child: true, class: VerifactuType },
{ direction: "<", target: "TICKETBAI", by: "tckchg", name: "ticketbai", reason: "ticketbais", child: true, class: TicketbaiType }
]
} as const;
const _TicketChangeClass = CreateObject(_schema);
Iif (!_TicketChangeClass) {
throw new Error("Failed to create BaseClass for '" + _schema.name + "'");
}
/****************************/
/* CLASS DECLARATION */
/****************************/
export class TicketChange extends _TicketChangeClass {
constructor(objid: string | null, data: dataService, objoptions: ObjectOptions | null = null){
super(_schema, objid, data, objoptions || {});
}
Copy(store: Array<DataObject> = []): TicketChange {
return this._Copy(store) as TicketChange;
}
/****************************/
/* CUSTOM METHODS */
/****************************/
get verifactu() : Verifactu | null {
Iif (this.verifactus.length > 0){
return this.verifactus[0];
}
return null;
}
get ticketbai() : Ticketbai | null {
Iif (this.ticketbais.length > 0){
return this.ticketbais[0];
}
return null;
}
get ChangeReason(): TicketChangeReason | null{
if (!this.ticket){
return null;
}
if (this.ticket.IsCancelled){
return 'C';
}
if (this.ticket.price && this.total){
const rountprice = (Math.round(this.ticket.price) * 100)/100;
const roundtotal = (Math.round(this.total) * 100)/100;
if (rountprice != roundtotal){
return 'P';
}
}
/* TODO: pasa por aqui: Client managenent
if (this.ticket.payment != 'PAYACCOUNT'){
if (this.ticket.client != this.client){
return (this.client) ? 'D' : 'I'; // client has changed : client has been set
}
}
*/
return null;
}
} |