mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
fix: minor fixes
This commit is contained in:
parent
7e7e3ed3cd
commit
ffbce23f03
@ -394,7 +394,8 @@ export class BespokeQueries {
|
|||||||
|
|
||||||
static async getPOSTransactedAmount(
|
static async getPOSTransactedAmount(
|
||||||
db: DatabaseCore,
|
db: DatabaseCore,
|
||||||
fromDate: Date
|
fromDate: Date,
|
||||||
|
toDate: Date
|
||||||
): Promise<Record<string, Money> | undefined> {
|
): Promise<Record<string, Money> | undefined> {
|
||||||
const sinvNames = (
|
const sinvNames = (
|
||||||
await db.knex!(ModelNameEnum.SalesInvoice)
|
await db.knex!(ModelNameEnum.SalesInvoice)
|
||||||
@ -403,7 +404,9 @@ export class BespokeQueries {
|
|||||||
.andWhereRaw('datetime(date) > datetime(?)', [
|
.andWhereRaw('datetime(date) > datetime(?)', [
|
||||||
new Date(fromDate.setHours(0, 0, 0)).toISOString(),
|
new Date(fromDate.setHours(0, 0, 0)).toISOString(),
|
||||||
])
|
])
|
||||||
.andWhereRaw('datetime(date) < datetime(?)', [new Date().toISOString()])
|
.andWhereRaw('datetime(date) < datetime(?)', [
|
||||||
|
new Date(toDate.setHours(0, 0, 0)).toISOString(),
|
||||||
|
])
|
||||||
).map((row: { name: string }) => row.name);
|
).map((row: { name: string }) => row.name);
|
||||||
|
|
||||||
if (!sinvNames.length) {
|
if (!sinvNames.length) {
|
||||||
|
@ -344,11 +344,13 @@ export class DatabaseHandler extends DatabaseBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getPOSTransactedAmount(
|
async getPOSTransactedAmount(
|
||||||
fromDate: Date
|
fromDate: Date,
|
||||||
|
toDate: Date
|
||||||
): Promise<Record<string, Money> | undefined> {
|
): Promise<Record<string, Money> | undefined> {
|
||||||
return (await this.#demux.callBespoke(
|
return (await this.#demux.callBespoke(
|
||||||
'getPOSTransactedAmount',
|
'getPOSTransactedAmount',
|
||||||
fromDate
|
fromDate,
|
||||||
|
toDate
|
||||||
)) as Promise<Record<string, Money> | undefined>;
|
)) as Promise<Record<string, Money> | undefined>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,14 +31,15 @@ let sinvDocOne: SalesInvoice | undefined;
|
|||||||
|
|
||||||
test('check pos transacted amount', async (t) => {
|
test('check pos transacted amount', async (t) => {
|
||||||
const transactedAmountBeforeTxn = await fyo.db.getPOSTransactedAmount(
|
const transactedAmountBeforeTxn = await fyo.db.getPOSTransactedAmount(
|
||||||
new Date('2022-01-01')
|
new Date('2023-01-01'),
|
||||||
|
new Date('2023-01-02')
|
||||||
);
|
);
|
||||||
|
|
||||||
t.equals(transactedAmountBeforeTxn, undefined);
|
t.equals(transactedAmountBeforeTxn, undefined);
|
||||||
|
|
||||||
sinvDocOne = fyo.doc.getNewDoc(ModelNameEnum.SalesInvoice, {
|
sinvDocOne = fyo.doc.getNewDoc(ModelNameEnum.SalesInvoice, {
|
||||||
isPOS: true,
|
isPOS: true,
|
||||||
date: new Date('2022-01-02'),
|
date: new Date('2023-01-01'),
|
||||||
account: 'Debtors',
|
account: 'Debtors',
|
||||||
party: customer.name,
|
party: customer.name,
|
||||||
}) as SalesInvoice;
|
}) as SalesInvoice;
|
||||||
@ -56,7 +57,7 @@ test('check pos transacted amount', async (t) => {
|
|||||||
|
|
||||||
const sinvDocTwo = fyo.doc.getNewDoc(ModelNameEnum.SalesInvoice, {
|
const sinvDocTwo = fyo.doc.getNewDoc(ModelNameEnum.SalesInvoice, {
|
||||||
isPOS: true,
|
isPOS: true,
|
||||||
date: new Date('2022-01-02'),
|
date: new Date('2023-01-01'),
|
||||||
account: 'Debtors',
|
account: 'Debtors',
|
||||||
party: customer.name,
|
party: customer.name,
|
||||||
}) as SalesInvoice;
|
}) as SalesInvoice;
|
||||||
@ -72,14 +73,17 @@ test('check pos transacted amount', async (t) => {
|
|||||||
|
|
||||||
await paymentDocTwo.setMultiple({
|
await paymentDocTwo.setMultiple({
|
||||||
paymentMethod: 'Transfer',
|
paymentMethod: 'Transfer',
|
||||||
clearanceDate: new Date(),
|
clearanceDate: new Date('2023-01-01'),
|
||||||
referenceId: 'xxxxxxxx',
|
referenceId: 'xxxxxxxx',
|
||||||
});
|
});
|
||||||
|
|
||||||
await paymentDocTwo.sync();
|
await paymentDocTwo.sync();
|
||||||
|
|
||||||
const transactedAmountAfterTxn: Record<string, Money> | undefined =
|
const transactedAmountAfterTxn: Record<string, Money> | undefined =
|
||||||
await fyo.db.getPOSTransactedAmount(new Date('2022-01-02'));
|
await fyo.db.getPOSTransactedAmount(
|
||||||
|
new Date('2023-01-01'),
|
||||||
|
new Date('2023-01-02')
|
||||||
|
);
|
||||||
|
|
||||||
t.true(transactedAmountAfterTxn);
|
t.true(transactedAmountAfterTxn);
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@
|
|||||||
<div class=""></div>
|
<div class=""></div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="row.links && row.links?.item.hasBatch"
|
v-if="row.links?.item && row.links?.item.hasBatch"
|
||||||
class="pl-6 px-4 pt-6 col-span-2"
|
class="pl-6 px-4 pt-6 col-span-2"
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
@ -213,7 +213,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="row.links && row.links?.item.hasBatch"
|
v-if="row.links?.item && row.links?.item.hasBatch"
|
||||||
class="px-2 pt-6 col-span-2"
|
class="px-2 pt-6 col-span-2"
|
||||||
>
|
>
|
||||||
<Float
|
<Float
|
||||||
@ -233,7 +233,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="row.links && row.links?.item.hasSerialNumber"
|
v-if="row.links?.item && row.links?.item.hasSerialNumber"
|
||||||
class="px-2 pt-8 col-span-2"
|
class="px-2 pt-8 col-span-2"
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
|
@ -109,7 +109,10 @@ export default defineComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const fromDate = fyo.singles.POSShift?.openingDate;
|
const fromDate = fyo.singles.POSShift?.openingDate;
|
||||||
this.transactedAmount = await fyo.db.getPOSTransactedAmount(fromDate);
|
this.transactedAmount = await fyo.db.getPOSTransactedAmount(
|
||||||
|
fromDate,
|
||||||
|
new Date()
|
||||||
|
);
|
||||||
},
|
},
|
||||||
seedClosingCash() {
|
seedClosingCash() {
|
||||||
if (!this.posShiftDoc) {
|
if (!this.posShiftDoc) {
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
@set-cash-amount="setCashAmount"
|
@set-cash-amount="setCashAmount"
|
||||||
@set-transfer-amount="setTransferAmount"
|
@set-transfer-amount="setTransferAmount"
|
||||||
@set-transfer-ref-no="setTransferRefNo"
|
@set-transfer-ref-no="setTransferRefNo"
|
||||||
|
@set-transfer-clearance-date="setTransferClearanceDate"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@ -58,8 +59,8 @@
|
|||||||
<div class="flex flex-col gap-3" style="height: calc(100vh - 6rem)">
|
<div class="flex flex-col gap-3" style="height: calc(100vh - 6rem)">
|
||||||
<div class="bg-white border grow h-full p-4 rounded-md">
|
<div class="bg-white border grow h-full p-4 rounded-md">
|
||||||
<!-- Customer Search -->
|
<!-- Customer Search -->
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
|
v-if="sinvDoc.fieldMap"
|
||||||
class="flex-shrink-0"
|
class="flex-shrink-0"
|
||||||
:border="true"
|
:border="true"
|
||||||
:value="sinvDoc.party"
|
:value="sinvDoc.party"
|
||||||
@ -116,11 +117,8 @@
|
|||||||
:text-right="true"
|
:text-right="true"
|
||||||
/>
|
/>
|
||||||
<FloatingLabelCurrencyInput
|
<FloatingLabelCurrencyInput
|
||||||
:df="{
|
v-if="sinvDoc.fieldMap"
|
||||||
label: t`Total`,
|
:df="sinvDoc.fieldMap.grandTotal"
|
||||||
fieldtype: 'Currency',
|
|
||||||
fieldname: 'total',
|
|
||||||
}"
|
|
||||||
size="large"
|
size="large"
|
||||||
:value="sinvDoc.grandTotal"
|
:value="sinvDoc.grandTotal"
|
||||||
:read-only="true"
|
:read-only="true"
|
||||||
@ -212,8 +210,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
provide() {
|
provide() {
|
||||||
return {
|
return {
|
||||||
doc: computed(() => this.sinvDoc),
|
|
||||||
cashAmount: computed(() => this.cashAmount),
|
cashAmount: computed(() => this.cashAmount),
|
||||||
|
doc: computed(() => this.sinvDoc),
|
||||||
isDiscountingEnabled: computed(() => this.isDiscountingEnabled),
|
isDiscountingEnabled: computed(() => this.isDiscountingEnabled),
|
||||||
itemDiscounts: computed(() => this.itemDiscounts),
|
itemDiscounts: computed(() => this.itemDiscounts),
|
||||||
itemQtyMap: computed(() => this.itemQtyMap),
|
itemQtyMap: computed(() => this.itemQtyMap),
|
||||||
@ -221,6 +219,7 @@ export default defineComponent({
|
|||||||
sinvDoc: computed(() => this.sinvDoc),
|
sinvDoc: computed(() => this.sinvDoc),
|
||||||
totalTaxedAmount: computed(() => this.totalTaxedAmount),
|
totalTaxedAmount: computed(() => this.totalTaxedAmount),
|
||||||
transferAmount: computed(() => this.transferAmount),
|
transferAmount: computed(() => this.transferAmount),
|
||||||
|
transferClearanceDate: computed(() => this.transferClearanceDate),
|
||||||
transferRefNo: computed(() => this.transferRefNo),
|
transferRefNo: computed(() => this.transferRefNo),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<Modal class="w-2/6 ml-auto mr-3.5" :set-close-listener="false">
|
<Modal class="w-2/6 ml-auto mr-3.5" :set-close-listener="false">
|
||||||
<div class="px-4 py-6 grid" style="height: 95vh">
|
<div v-if="sinvDoc.fieldMap" class="px-4 py-6 grid" style="height: 95vh">
|
||||||
<div class="grid grid-cols-2 gap-6">
|
<div class="grid grid-cols-2 gap-6">
|
||||||
<Currency
|
<Currency
|
||||||
:df="{
|
:df="fyo.fieldMap.PaymentFor.amount"
|
||||||
label: t`Cash`,
|
|
||||||
fieldtype: 'Currency',
|
|
||||||
fieldname: 'cash',
|
|
||||||
}"
|
|
||||||
:read-only="!transferAmount.isZero()"
|
:read-only="!transferAmount.isZero()"
|
||||||
:border="true"
|
:border="true"
|
||||||
:text-right="true"
|
:text-right="true"
|
||||||
@ -27,11 +23,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Currency
|
<Currency
|
||||||
:df="{
|
:df="fyo.fieldMap.PaymentFor.amount"
|
||||||
label: t`Transfer`,
|
|
||||||
fieldtype: 'Currency',
|
|
||||||
fieldname: 'transfer',
|
|
||||||
}"
|
|
||||||
:read-only="!cashAmount.isZero()"
|
:read-only="!cashAmount.isZero()"
|
||||||
:border="true"
|
:border="true"
|
||||||
:text-right="true"
|
:text-right="true"
|
||||||
@ -54,11 +46,7 @@
|
|||||||
<div class="mt-8 grid grid-cols-2 gap-6">
|
<div class="mt-8 grid grid-cols-2 gap-6">
|
||||||
<Data
|
<Data
|
||||||
v-show="!transferAmount.isZero()"
|
v-show="!transferAmount.isZero()"
|
||||||
:df="{
|
:df="fyo.fieldMap.Payment.referenceId"
|
||||||
label: t`Transfer Ref No.`,
|
|
||||||
fieldtype: 'Data',
|
|
||||||
fieldname: 'transferRefNo',
|
|
||||||
}"
|
|
||||||
:show-label="true"
|
:show-label="true"
|
||||||
:border="true"
|
:border="true"
|
||||||
:required="!transferAmount.isZero()"
|
:required="!transferAmount.isZero()"
|
||||||
@ -68,14 +56,11 @@
|
|||||||
|
|
||||||
<Date
|
<Date
|
||||||
v-show="!transferAmount.isZero()"
|
v-show="!transferAmount.isZero()"
|
||||||
:df="{
|
:df="fyo.fieldMap.Payment.clearanceDate"
|
||||||
label: t`Clearance Date`,
|
|
||||||
fieldtype: 'Date',
|
|
||||||
fieldname: 'transferClearanceDate',
|
|
||||||
}"
|
|
||||||
:show-label="true"
|
:show-label="true"
|
||||||
:border="true"
|
:border="true"
|
||||||
:required="!transferAmount.isZero()"
|
:required="!transferAmount.isZero()"
|
||||||
|
:value="transferClearanceDate"
|
||||||
@change="(value:Date) => $emit('setTransferClearanceDate', value)"
|
@change="(value:Date) => $emit('setTransferClearanceDate', value)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -114,11 +99,7 @@
|
|||||||
class="mb-14 row-start-4 row-span-2 grid grid-cols-2 gap-x-6 gap-y-11"
|
class="mb-14 row-start-4 row-span-2 grid grid-cols-2 gap-x-6 gap-y-11"
|
||||||
>
|
>
|
||||||
<Currency
|
<Currency
|
||||||
:df="{
|
:df="sinvDoc.fieldMap.netTotal"
|
||||||
label: t`Net Total`,
|
|
||||||
fieldtype: 'Currency',
|
|
||||||
fieldname: 'netTotal',
|
|
||||||
}"
|
|
||||||
:read-only="true"
|
:read-only="true"
|
||||||
:show-label="true"
|
:show-label="true"
|
||||||
:border="true"
|
:border="true"
|
||||||
@ -140,11 +121,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Currency
|
<Currency
|
||||||
:df="{
|
:df="sinvDoc.fieldMap.baseGrandTotal"
|
||||||
label: t`Total Amount`,
|
|
||||||
fieldtype: 'Currency',
|
|
||||||
fieldname: 'totalAmount',
|
|
||||||
}"
|
|
||||||
:read-only="true"
|
:read-only="true"
|
||||||
:show-label="true"
|
:show-label="true"
|
||||||
:border="true"
|
:border="true"
|
||||||
@ -154,11 +131,7 @@
|
|||||||
|
|
||||||
<Currency
|
<Currency
|
||||||
v-if="isDiscountingEnabled"
|
v-if="isDiscountingEnabled"
|
||||||
:df="{
|
:df="sinvDoc.fieldMap.discountAmount"
|
||||||
label: t`Discount Amount`,
|
|
||||||
fieldtype: 'Currency',
|
|
||||||
fieldname: 'discountAmount',
|
|
||||||
}"
|
|
||||||
:read-only="true"
|
:read-only="true"
|
||||||
:show-label="true"
|
:show-label="true"
|
||||||
:border="true"
|
:border="true"
|
||||||
@ -167,11 +140,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Currency
|
<Currency
|
||||||
:df="{
|
:df="sinvDoc.fieldMap.grandTotal"
|
||||||
label: t`Grand Total`,
|
|
||||||
fieldtype: 'Currency',
|
|
||||||
fieldname: 'grandTotal',
|
|
||||||
}"
|
|
||||||
:read-only="true"
|
:read-only="true"
|
||||||
:show-label="true"
|
:show-label="true"
|
||||||
:border="true"
|
:border="true"
|
||||||
@ -262,6 +231,7 @@ export default defineComponent({
|
|||||||
transferAmount: inject('transferAmount') as Money,
|
transferAmount: inject('transferAmount') as Money,
|
||||||
sinvDoc: inject('sinvDoc') as SalesInvoice,
|
sinvDoc: inject('sinvDoc') as SalesInvoice,
|
||||||
transferRefNo: inject('transferRefNo') as string,
|
transferRefNo: inject('transferRefNo') as string,
|
||||||
|
transferClearanceDate: inject('transferClearanceDate') as Date,
|
||||||
totalTaxedAmount: inject('totalTaxedAmount') as Money,
|
totalTaxedAmount: inject('totalTaxedAmount') as Money,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -273,15 +243,16 @@ export default defineComponent({
|
|||||||
return grandTotal.sub(this.transferAmount);
|
return grandTotal.sub(this.transferAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.transferAmount.isZero()) {
|
|
||||||
return grandTotal.sub(this.cashAmount);
|
return grandTotal.sub(this.cashAmount);
|
||||||
}
|
|
||||||
|
|
||||||
const totalPaidAmount = this.cashAmount.add(this.transferAmount);
|
|
||||||
return grandTotal.sub(totalPaidAmount);
|
|
||||||
},
|
},
|
||||||
paidChange(): Money {
|
paidChange(): Money {
|
||||||
return this.cashAmount.sub(this.sinvDoc?.grandTotal ?? fyo.pesa(0));
|
const grandTotal = this.sinvDoc?.grandTotal ?? fyo.pesa(0);
|
||||||
|
|
||||||
|
if (this.cashAmount.isZero()) {
|
||||||
|
return this.transferAmount.sub(grandTotal);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.cashAmount.sub(grandTotal);
|
||||||
},
|
},
|
||||||
showBalanceAmount(): boolean {
|
showBalanceAmount(): boolean {
|
||||||
if (
|
if (
|
||||||
@ -309,15 +280,15 @@ export default defineComponent({
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.cashAmount.lt(this.sinvDoc?.grandTotal ?? fyo.pesa(0))) {
|
if (this.cashAmount.gt(this.sinvDoc?.grandTotal ?? fyo.pesa(0))) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.transferAmount.gte(this.sinvDoc?.grandTotal ?? fyo.pesa(0))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.transferAmount.gt(this.sinvDoc?.grandTotal ?? fyo.pesa(0))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
Loading…
Reference in New Issue
Block a user