Created
March 23, 2017 10:57
-
-
Save riccoski/da5ee9604e4f0fbbc61375fca8245480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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