2
0
mirror of https://github.com/frappe/books.git synced 2024-11-15 01:44:04 +00:00

fix: resolve linting issues

This commit is contained in:
AbleKSaju 2024-09-28 09:42:19 +05:30
parent 53cf61d4fe
commit dc7b4b0c60
2 changed files with 13 additions and 24 deletions

View File

@ -35,8 +35,8 @@
<Button <Button
class="w-full bg-green-500" class="w-full bg-green-500"
style="padding: 1.35rem" style="padding: 1.35rem"
@click="setLoyaltyPoints()"
:disabled="validationError" :disabled="validationError"
@click="setLoyaltyPoints()"
> >
<slot> <slot>
<p class="uppercase text-lg text-white font-semibold"> <p class="uppercase text-lg text-white font-semibold">
@ -67,9 +67,7 @@
<script lang="ts"> <script lang="ts">
import Button from 'src/components/Button.vue'; import Button from 'src/components/Button.vue';
import Currency from 'src/components/Controls/Currency.vue';
import Data from 'src/components/Controls/Data.vue'; import Data from 'src/components/Controls/Data.vue';
import Date from 'src/components/Controls/Date.vue';
import Modal from 'src/components/Modal.vue'; import Modal from 'src/components/Modal.vue';
import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice'; import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice';
import { defineComponent, inject } from 'vue'; import { defineComponent, inject } from 'vue';
@ -81,17 +79,10 @@ export default defineComponent({
name: 'LoyaltyProgramModal', name: 'LoyaltyProgramModal',
components: { components: {
Modal, Modal,
Currency,
Button, Button,
Data, Data,
Date,
}, },
emits: ['setLoyaltyPoints', 'toggleModal'],
props: { props: {
sinvDoc: {
type: Object,
required: true,
},
loyaltyPoints: { loyaltyPoints: {
type: Number, type: Number,
required: true, required: true,
@ -101,16 +92,17 @@ export default defineComponent({
required: true, required: true,
}, },
}, },
data() { emits: ['setLoyaltyPoints', 'toggleModal'],
return {
validationError: false,
};
},
setup() { setup() {
return { return {
sinvDoc: inject('sinvDoc') as SalesInvoice, sinvDoc: inject('sinvDoc') as SalesInvoice,
}; };
}, },
data() {
return {
validationError: false,
};
},
methods: { methods: {
async updateLoyaltyPoints(newValue: number) { async updateLoyaltyPoints(newValue: number) {
try { try {
@ -119,7 +111,7 @@ export default defineComponent({
} else { } else {
throw new Error( throw new Error(
`${this.sinvDoc.party as string} only has ${ `${this.sinvDoc.party as string} only has ${
this.loyaltyPoints as number this.loyaltyPoints
} points` } points`
); );
} }
@ -128,7 +120,7 @@ export default defineComponent({
ModelNameEnum.LoyaltyProgram, ModelNameEnum.LoyaltyProgram,
{ {
fields: ['conversionFactor'], fields: ['conversionFactor'],
filters: { name: this.loyaltyProgram as string }, filters: { name: this.loyaltyProgram },
} }
); );
@ -136,9 +128,7 @@ export default defineComponent({
newValue * ((loyaltyProgramDoc[0]?.conversionFactor as number) || 0); newValue * ((loyaltyProgramDoc[0]?.conversionFactor as number) || 0);
if (this.sinvDoc.baseGrandTotal?.lt(loyaltyPoint)) { if (this.sinvDoc.baseGrandTotal?.lt(loyaltyPoint)) {
throw new Error( throw new Error(t`no need ${newValue} points to purchase this item`);
t`no need ${newValue as number} points to purchase this item`
);
} }
this.validationError = false; this.validationError = false;
} catch (error) { } catch (error) {

View File

@ -24,7 +24,6 @@
<LoyaltyProgramModal <LoyaltyProgramModal
:open-modal="openLoyaltyProgramModal" :open-modal="openLoyaltyProgramModal"
:sinvDoc="sinvDoc"
:loyalty-points="loyaltyPoints" :loyalty-points="loyaltyPoints"
:loyalty-program="loyaltyProgram" :loyalty-program="loyaltyProgram"
@set-loyalty-points="setLoyaltyPoints" @set-loyalty-points="setLoyaltyPoints"
@ -486,7 +485,7 @@ export default defineComponent({
const party = await this.fyo.db.getAll(ModelNameEnum.Party, { const party = await this.fyo.db.getAll(ModelNameEnum.Party, {
fields: ['loyaltyProgram', 'loyaltyPoints'], fields: ['loyaltyProgram', 'loyaltyPoints'],
filters: { name: value as string }, filters: { name: value },
}); });
this.loyaltyProgram = party[0]?.loyaltyProgram as string; this.loyaltyProgram = party[0]?.loyaltyProgram as string;
@ -561,8 +560,8 @@ export default defineComponent({
const totalLotaltyAmount = await getAddedLPWithGrandTotal( const totalLotaltyAmount = await getAddedLPWithGrandTotal(
this.fyo, this.fyo,
this.loyaltyProgram as string, this.loyaltyProgram,
value as number value
); );
const total = totalLotaltyAmount const total = totalLotaltyAmount