import { get } from 'lodash'; import { Entity } from './entity'; export class Modalidade extends Entity{ descricao: string; forma_pagamento: string | number; permite_troco: boolean; previsao_recebimento: number; constructor(json: any, generateId?: boolean) { super(json, generateId); json = json || {}; this.descricao = json.descricao || ''; this.forma_pagamento = json.forma_pagamento || ''; this.permite_troco = json.permite_troco || false; this.previsao_recebimento = json.previsao_recebimento || 0; } } export class Pagamento { modalidade: Modalidade | string; forma_pagamento: string; valor: number; troco: number; pago: number; codigo?: string; parcelas: number = 1; pre_pago: boolean; [_key: string]: any; constructor(json?:any) { json = json || {}; this.valor = json.valor; this.parcelas = json.parcelas || 1; this.troco = json.troco || 0.0; this.codigo = json.codigo || (Math.random() * 1000).toFixed(); this.pago = json.pago || 0.0; this.pre_pago = json.pre_pago || false; if (json.modalidade && typeof json.modalidade === 'string') { this.modalidade = json.modalidade; this.forma_pagamento = json.forma_pagamento; } else if (typeof json.modalidade === 'object') { this.modalidade = get(json, 'modalidade.descricao'); this.forma_pagamento = get(json, 'modalidade.forma_pagamento'); } } }