Untitled
unknown
typescript
a year ago
5.5 kB
2
Indexable
Never
export const FiscalDocumentItemPromotionSchema = new Schema<ICoreFiscalDocumentItemPromotion>({ code: { type: String, required: false }, name: { type: String, required: false }, amount: { type: Number, required: false }, percent: { type: Number, required: false }, taxAmount: { type: Number, required: false }, internalTax: { type: Number, required: false }, scope: { type: String, required: true } }) /**=========================== FISCAL DOCUMENT ======================= */ // Todas las propiedades son opcionales (inclusive el array en si mismo) export const FiscalDocumentBenefitSchema = new Schema<ICoreFiscalDocumentBenefit>({ code: String, name: String, benefitType: String, amount: Number, couponCode: String, cardType: String, cardCode: String, cardCurrentAmount: Number }) export const FiscalDocumentInfoSchema = new Schema<ICoreFiscalDocumentInfo>({ key: { type: String, required: true }, value: { type: String, required: true } }) export const FiscalDocumentItemSchema = new Schema<ICoreFiscalDocumentItem>({ action: { type: String, required: false, enum: [ "R", "S" ], default: "S" }, sku: { type: String, required: true }, code: { type: String, required: false }, name: { type: String, required: true }, barCode: String, um: { type: String, required: true }, qty: { type: Number, required: true }, serialNumber: String, lotNumber: String, tax: { type: Number, required: true }, taxCode: String, taxAmount: { type: Number, required: true, default: 0 }, internalTax: Number, internalTaxCode: String, internalTaxAmount: Number, unitPrice: { type: Number, required: true }, promotions: { type: [FiscalDocumentItemPromotionSchema], default: [] }, discount: { type: Number, default: 0 }, totalPrice: { type: Number, required: true }, itemInfo: { type: [FiscalDocumentInfoSchema], default: [] }, imageUrl: String }) export const FiscalDocumentRelatedInvoiceSchema = new Schema<ICoreFiscalDocumentRelatedInvoice>({ invoiceType: { type: String, required: false }, invoiceNumber: { type: Number, required: false }, pointOfSale: String, invoiceDate: Date }) export const FiscalDocumentRelatedTaxSchema = new Schema<ICoreFiscalDocumentRelatedTax>({ code: { type: Number, required: true }, name: { type: String, required: true }, aliquot: { type: Number, required: false }, baseAmount: { type: Number, required: true }, amount: { type: Number, required: true } }) export const FiscalDocumentOptionalSchema = new Schema<ICoreFiscalDocumentOptional>({ code: { type: String, required: true }, name: { type: String, required: true }, value: { type: String, required: true } }) export const FiscalDocumentPaymentMethodSchema = new Schema<ICoreFiscalDocumentPaymentMethod>({ code: { type: String, required: true }, name: { type: String, required: true }, amount: { type: Number, required: true }, paymentMethodsInfo: { type: [FiscalDocumentInfoSchema], default: [] } }) export const FiscalDocumentCoreSchema = new Schema<ICoreFiscalDocument>({ companyCode: { type: String, required: true }, channelCode: { type: String, required: false }, storeCode: { type: String, required: true }, terminalCode: { type: String, required: true }, invoiceNumber: { type: Number, required: true }, invoiceType: { type: String, required: true }, pointOfSale: { type: String, required: false }, internalId: { type: String, required: true }, orderNumber: { type: String, required: false }, invoiceDate: { type: Date, required: true }, taxedAmount: { type: Number, default: 0 }, amountIVA: { type: Number, default: 0 }, nonTaxedAmount: { type: Number, default: 0 }, exemptAmount: { type: Number, default: 0 }, amountOtherTaxes: { type: Number, default: 0 }, subtotalAmount: { type: Number, required: true }, discountAmount: { type: Number, required: true }, ticketDiscount: { type: Number, default: 0 }, totalAmount: { type: Number, required: true }, currency: { type: String, required: true }, currencyChange: { type: Number, required: false }, items: { type: [FiscalDocumentItemSchema], default: [] }, relatedInvoices: { type: [FiscalDocumentRelatedInvoiceSchema], default: [] }, relatedTaxes: { type: [FiscalDocumentRelatedTaxSchema], default: [] }, relatedOtherTaxes: { type: [FiscalDocumentRelatedTaxSchema], default: [] }, optionals: { type: [FiscalDocumentOptionalSchema], default: [] }, paymentMethods: { type: [FiscalDocumentPaymentMethodSchema], default: [] }, documentInfo: { type: [FiscalDocumentInfoSchema], default: [] }, benefits: { type: [FiscalDocumentBenefitSchema], default: [] }, saleCondition: { type: String, required: true }, identificationNumber: { type: String, required: true }, documentType: { type: String, required: true }, operator: { type: String, required: false }, status: { type: String, required: true }, testMode: { type: Boolean, default: false }, attempts: { type: Number, default: 0 }, authorizationCode: { type: String, required: false }, authorizationType: { type: String, required: false } }, { // Persistir fecha de creacion y actualizacion timestamps: true })