UNPKG

@inbridge/oif-ts

Version:

TypeScript integration for the Open Invoice Format (OIF) schema. Easily create OIF-compliant PDFs and parse/validate JSON.

2 lines (1 loc) 799 B
var R=class{constructor(E,T,D,N){this.id="";this.description="";this.quantity=1;this.unit="piece";this.currency="EUR";this.taxRate=0;this.id=E,this.price=T,this.description=N||"",this.unit=D||"piece"}get netPrice(){return this.price*this.quantity}get tax(){return this.netPrice*(this.taxRate/100)}get grossPrice(){return this.netPrice+this.tax}addDiscount(E,T){Object.assign(this,{discount:E,discountType:T}),Object.setPrototypeOf(this,s.prototype)}};var s=class extends R{constructor(){super(...arguments);this.discount=0;this.discountType="fixed";this.discountReason=""}get discountAmount(){return this.discountType==="percentage"?this.price*this.quantity*(this.discount/100):this.discount}get netPrice(){return this.price*this.quantity-this.discountAmount}};export{s as InvoiceItemWithDiscount};