feat: number to word

This commit is contained in:
puriphatt 2024-10-07 14:13:07 +07:00
parent 4e21ded2db
commit 86483506be
3 changed files with 4553 additions and 83 deletions

4612
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -22,12 +22,14 @@
"keycloak-js": "^25.0.4", "keycloak-js": "^25.0.4",
"mime": "^4.0.4", "mime": "^4.0.4",
"moment": "^2.30.1", "moment": "^2.30.1",
"number-to-words": "^1.2.4",
"open-props": "^1.7.5", "open-props": "^1.7.5",
"pinia": "^2.2.2", "pinia": "^2.2.2",
"quasar": "^2.16.9", "quasar": "^2.16.9",
"signature_pad": "^5.0.2", "signature_pad": "^5.0.2",
"socket.io-client": "^4.7.5", "socket.io-client": "^4.7.5",
"tesseract.js": "^5.1.1", "tesseract.js": "^5.1.1",
"thai-baht-text": "^2.0.5",
"uuid": "^10.0.0", "uuid": "^10.0.0",
"vue": "^3.4.38", "vue": "^3.4.38",
"vue-i18n": "^9.14.0", "vue-i18n": "^9.14.0",
@ -40,6 +42,7 @@
"@playwright/test": "^1.46.1", "@playwright/test": "^1.46.1",
"@quasar/app-vite": "2.0.0-beta.19", "@quasar/app-vite": "2.0.0-beta.19",
"@types/node": "^20.16.1", "@types/node": "^20.16.1",
"@types/number-to-words": "^1.2.3",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0", "@typescript-eslint/parser": "^7.18.0",

View file

@ -1,11 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, watch } from 'vue'; import { computed, watch } from 'vue';
import { precisionRound } from 'src/utils/arithmetic'; import { precisionRound } from 'src/utils/arithmetic';
import ThaiBahtText from 'thai-baht-text';
import { toWords } from 'number-to-words';
import { QTableProps } from 'quasar';
import TableComponents from 'src/components/TableComponents.vue'; import TableComponents from 'src/components/TableComponents.vue';
import { QuotationPayload } from 'src/stores/quotations/types'; import { QuotationPayload } from 'src/stores/quotations/types';
import { formatNumberDecimal } from 'stores/utils'; import { formatNumberDecimal } from 'stores/utils';
import { QTableProps } from 'quasar';
defineProps<{ defineProps<{
agentPrice: boolean; agentPrice: boolean;
@ -122,6 +124,11 @@ const columns = [
}, },
] satisfies QTableProps['columns']; ] satisfies QTableProps['columns'];
const EngBahtText = (number: number) => {
const [baht, satang] = number.toString().split('.');
return `${toWords(baht)} Baht${satang && ` and ${toWords(satang)} Satang`}`;
};
watch( watch(
() => summary.value, () => summary.value,
() => { () => {
@ -244,7 +251,7 @@ watch(
</div> </div>
<div <div
class="column q-ml-auto text-caption app-text-muted q-pt-md" class="column q-ml-auto text-caption app-text-muted-2 q-pt-md"
style="width: 15vw" style="width: 15vw"
> >
<div class="row"> <div class="row">
@ -273,6 +280,16 @@ watch(
</span> </span>
</div> </div>
</div> </div>
<span
v-if="summary.finalPrice"
class="text-caption app-text-muted-2 flex self-end"
>
({{
$i18n.locale === 'eng'
? EngBahtText(summary.finalPrice)
: ThaiBahtText(summary.finalPrice)
}})
</span>
</div> </div>
</template> </template>