Skip to content

Instantly share code, notes, and snippets.

@riccoski
Created March 23, 2017 10:57
Show Gist options
  • Save riccoski/da5ee9604e4f0fbbc61375fca8245480 to your computer and use it in GitHub Desktop.
Save riccoski/da5ee9604e4f0fbbc61375fca8245480 to your computer and use it in GitHub Desktop.
import { computed, observable } from "mobx"
import VATNumber from "./VATNumber"
export default class VATLayer {
@observable country_code
@observable country_name
@observable rate
@observable forceVATList = []
@observable vatNumber
store = null
constructor(store, data) {
if ( data != null ) {
Object.assign(this, { ...data });
}
this.store = store
this.vatNumber = new VATNumber(this.store)
}
insertMandatory(country) {
this.forceVATList.push(country)
}
@computed get VATRate() {
console.log("this.country_code", this.country_code);
return ( this.vatNumber.isValid && !["GB","UK"].includes(this.country_code) ? 0 : this.rate )
}
update(data) {
if ( data != null ) {
Object.assign(this, { ...data });
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment