diff --git a/pom.xml b/pom.xml index 751715b..9bd06f4 100644 --- a/pom.xml +++ b/pom.xml @@ -49,6 +49,11 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-web-services + com.azure.spring spring-cloud-azure-starter @@ -162,6 +167,15 @@ flyway-mysql + + org.glassfish.jaxb + jaxb-runtime + + + jakarta.xml.bind + jakarta.xml.bind-api + 4.0.2 + @@ -179,6 +193,26 @@ + org.jvnet.jaxb + jaxb-maven-plugin + 4.0.0 + + + + generate + + + + + ${project.basedir}/src/main/resources/wsdl + + *.wsdl + + eu.europa.ec.taxation.taric.client + + + + org.apache.maven.plugins maven-surefire-plugin 3.2.5 diff --git a/src/frontend/src/components/layout/bulkedit/BulkEditRow.vue b/src/frontend/src/components/layout/bulkedit/BulkEditRow.vue index 1b08ed4..5c787cc 100644 --- a/src/frontend/src/components/layout/bulkedit/BulkEditRow.vue +++ b/src/frontend/src/components/layout/bulkedit/BulkEditRow.vue @@ -10,7 +10,7 @@
{{ premise.material.part_number }}
HS Code: - {{ premise.material.hs_code }} + {{ premise.hs_code }}
diff --git a/src/frontend/src/components/layout/edit/MaterialEdit.vue b/src/frontend/src/components/layout/edit/MaterialEdit.vue index f470a5f..0b16a28 100644 --- a/src/frontend/src/components/layout/edit/MaterialEdit.vue +++ b/src/frontend/src/components/layout/edit/MaterialEdit.vue @@ -1,6 +1,7 @@ @@ -48,21 +86,24 @@ import Flag from "@/components/UI/Flag.vue"; import InputField from "@/components/UI/InputField.vue"; import AutosuggestSearchbar from "@/components/UI/AutoSuggestSearchBar.vue"; import ModalDialog from "@/components/UI/ModalDialog.vue"; -import {PhArrowCounterClockwise} from "@phosphor-icons/vue"; +import {PhArrowCounterClockwise, PhWarning} from "@phosphor-icons/vue"; import {useMaterialStore} from "@/store/material.js"; import {mapStores} from "pinia"; import {parseNumberFromString} from "@/common.js"; import Modal from "@/components/UI/Modal.vue"; import SelectMaterial from "@/components/layout/material/SelectMaterial.vue"; import {useCustomsStore} from "@/store/customs.js"; +import Checkbox from "@/components/UI/Checkbox.vue"; export default { name: "MaterialEdit", components: { + Checkbox, + PhWarning, SelectMaterial, Modal, PhArrowCounterClockwise, ModalDialog, AutosuggestSearchbar, InputField, Flag, IconButton }, - emits: ["update:tariffRate", "updateMaterial", "update:partNumber", "update:hsCode", "save", "close"], + emits: ["update:tariffRate", "updateMaterial", "update:partNumber", "update:hsCode", "save", "close", "startLookup"], props: { description: { type: [String, null], @@ -72,6 +113,10 @@ export default { required: true, validator: (value) => value === null || typeof value === 'string' }, + countryId: { + required: true, + validator: (value) => value === null || typeof value === 'number' + }, tariffRate: { required: true, validator: (value) => value === null || typeof value === 'number' @@ -93,11 +138,29 @@ export default { ...mapStores(useMaterialStore, useCustomsStore), tariffRatePercent() { return ((this.tariffRate ?? null) !== null) ? (this.tariffRate * 100).toFixed(2) : ''; + }, + showTariffWarning() { + return this.customsStore.showWarning(this.countryId); + }, + tariffIsDefault() { + return this.tariffInfo?.default ?? false; + }, + tariffInfo() { + return this.customsStore.findByCountryId(this.countryId); + }, + measures() { + return this.tariffInfo.measures; + }, + showCheckbox() { + return this.countryId === null; + }, + disableTariff() { + return !this.doLookup; } }, data() { return { - + doLookup: false } }, created() { @@ -115,22 +178,54 @@ export default { } }); }, - validateTariffRate(event) { - const percentValue = parseNumberFromString(event.target.value, 2, true); + validateTariffRateEvent(event) { + event.target.value = this.validateTariffRate(event.target.value); + }, + validateTariffRate(value) { + const percentValue = parseNumberFromString(value, 2, true); const validatedPercent = (percentValue === null) ? null : Math.max(0, Math.min(999.99, percentValue)); const validatedDecimal = (validatedPercent === null) ? null : validatedPercent / 100; if (validatedDecimal !== this.tariffRate) { - this.$emit('update:tariffRate', validatedDecimal); + this.$emit('update:tariffRate', this.roundNumber(validatedDecimal, 4)); } - event.target.value = validatedPercent === null ? null : validatedPercent.toFixed(2); + return validatedPercent === null ? null : validatedPercent.toFixed(2); + + }, + roundNumber(number, digits) { + const multiple = Math.pow(10, digits); + return Math.round(number * multiple) / multiple; }, async fetchHsCode(query) { - const hsCodeQuery = {searchTerm: query}; - await this.customsStore.setQuery(hsCodeQuery); - return this.customsStore.hsCodes; + return await this.customsStore.findHsCode(query); + }, + hsCodeChanged() { + const currentValue = this.$refs.hsCodeSearchbar.searchQuery; + this.$emit("update:hsCode", currentValue); + }, + async hsCodeSelected(hsCode) { + let save = false; + + if (hsCode !== this.hsCode) { + this.$emit("update:hsCode", hsCode) + save = true; + } + + if ((this.countryId ?? null) !== null) { + const query = {hsCode: hsCode, countryIds: [this.countryId]}; + await this.customsStore.findTariffRate(query); + this.validateTariffRate((this.customsStore.findByCountryId(this.countryId)?.value ?? 0.03) * 100); + save = true; + } + + if (save) + this.$emit('save', 'material'); + }, + checkBoxChanged(checked) { + this.doLookup = checked + this.$emit('startLookup', checked); } } } @@ -139,11 +234,42 @@ export default {