mirror of
https://github.com/frappe/books.git
synced 2025-02-10 16:08:35 +00:00
feat: submit and hold invoice for later use in POS
This commit is contained in:
parent
a34e0d8712
commit
2277898afb
@ -52,7 +52,7 @@
|
||||
(date) => emitEvent('setTransferClearanceDate', date)
|
||||
"
|
||||
@create-transaction="
|
||||
(createTransaction) => emitEvent('createTransaction', createTransaction)
|
||||
(print, status) => emitEvent('createTransaction', print, status)
|
||||
"
|
||||
/>
|
||||
|
||||
@ -287,7 +287,7 @@
|
||||
>
|
||||
<slot>
|
||||
<p class="uppercase text-lg text-white font-semibold">
|
||||
{{ t`Pay` }}
|
||||
{{ t`Submit` }}
|
||||
</p>
|
||||
</slot>
|
||||
</Button>
|
||||
|
@ -52,7 +52,7 @@
|
||||
(date) => emitEvent('setTransferClearanceDate', date)
|
||||
"
|
||||
@create-transaction="
|
||||
(createTransaction) => emitEvent('createTransaction', createTransaction)
|
||||
(print, status) => emitEvent('createTransaction', print, status)
|
||||
"
|
||||
/>
|
||||
|
||||
@ -210,7 +210,7 @@
|
||||
>
|
||||
<slot>
|
||||
<p class="uppercase text-lg text-white font-semibold">
|
||||
{{ t`Pay` }}
|
||||
{{ t`Submit` }}
|
||||
</p>
|
||||
</slot>
|
||||
</Button>
|
||||
|
@ -466,6 +466,10 @@ export default defineComponent({
|
||||
|
||||
this.sinvDoc = salesInvoiceDoc;
|
||||
this.toggleModal('SavedInvoice', false);
|
||||
|
||||
if (doc.submitted) {
|
||||
this.toggleModal('Payment');
|
||||
}
|
||||
},
|
||||
setTransferAmount(amount: Money = fyo.pesa(0)) {
|
||||
this.transferAmount = amount;
|
||||
@ -571,13 +575,19 @@ export default defineComponent({
|
||||
await this.applyPricingRule();
|
||||
await this.sinvDoc.runFormulas();
|
||||
},
|
||||
|
||||
async createTransaction(shouldPrint = false) {
|
||||
async createTransaction(shouldPrint = false, isPay = false) {
|
||||
try {
|
||||
await this.validate();
|
||||
await this.submitSinvDoc();
|
||||
await this.makePayment(shouldPrint);
|
||||
await this.makeStockTransfer();
|
||||
|
||||
if (this.sinvDoc.stockNotTransferred) {
|
||||
await this.makeStockTransfer();
|
||||
}
|
||||
|
||||
if (isPay) {
|
||||
await this.makePayment(shouldPrint);
|
||||
}
|
||||
|
||||
await this.afterTransaction();
|
||||
await this.setItems();
|
||||
} catch (error) {
|
||||
|
@ -135,7 +135,7 @@
|
||||
<Button
|
||||
class="w-full bg-red-500 dark:bg-red-700"
|
||||
style="padding: 1.35rem"
|
||||
@click="$emit('toggleModal', 'Payment')"
|
||||
@click="cancelTransaction()"
|
||||
>
|
||||
<slot>
|
||||
<p class="uppercase text-lg text-white font-semibold">
|
||||
@ -144,31 +144,67 @@
|
||||
</slot>
|
||||
</Button>
|
||||
</div>
|
||||
<div class="col-span-1" v-if="fyo.singles.POSSettings?.submitInvoice">
|
||||
<Button
|
||||
class="w-full bg-blue-500 dark:bg-blue-700"
|
||||
style="padding: 1.35rem"
|
||||
:disabled="disableSubmitButton"
|
||||
@click="submitTransaction()"
|
||||
>
|
||||
<slot>
|
||||
<p
|
||||
class="uppercase text-lg text-white font-semibold"
|
||||
:disabled="sinvDoc.submitted"
|
||||
>
|
||||
{{ t`Submit` }}
|
||||
</p>
|
||||
</slot>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1" v-if="fyo.singles.POSSettings?.submitInvoice">
|
||||
<Button
|
||||
class="w-full bg-green-500 dark:bg-green-700"
|
||||
style="padding: 1.35rem"
|
||||
:disabled="disableSubmitButton"
|
||||
@click="$emit('createTransaction', true)"
|
||||
>
|
||||
<slot>
|
||||
<p
|
||||
class="uppercase text-lg text-white font-semibold"
|
||||
:disabled="sinvDoc.submitted"
|
||||
>
|
||||
{{ t`Submit & Print` }}
|
||||
</p>
|
||||
</slot>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<Button
|
||||
class="w-full bg-blue-500 dark:bg-blue-700"
|
||||
style="padding: 1.35rem"
|
||||
:disabled="disableSubmitButton"
|
||||
@click="submitTransaction()"
|
||||
:disabled="disablePayButton"
|
||||
@click="payTransaction()"
|
||||
>
|
||||
<slot>
|
||||
<p class="uppercase text-lg text-white font-semibold">
|
||||
{{ t`Submit` }}
|
||||
{{ t`Pay` }}
|
||||
</p>
|
||||
</slot>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1">
|
||||
<Button
|
||||
class="w-full bg-green-500 dark:bg-green-700"
|
||||
style="padding: 1.35rem"
|
||||
:disabled="disableSubmitButton"
|
||||
@click="$emit('createTransaction', true)"
|
||||
:disabled="disablePayButton"
|
||||
@click="$emit('createTransaction', true, true)"
|
||||
>
|
||||
<slot>
|
||||
<p class="uppercase text-lg text-white font-semibold">
|
||||
{{ t`Submit & Print` }}
|
||||
{{ t`Pay & Print` }}
|
||||
</p>
|
||||
</slot>
|
||||
</Button>
|
||||
@ -293,6 +329,27 @@ export default defineComponent({
|
||||
return false;
|
||||
},
|
||||
disableSubmitButton(): boolean {
|
||||
if (this.sinvDoc.submitted) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
!this.sinvDoc.grandTotal?.isZero() &&
|
||||
this.transferAmount.isZero() &&
|
||||
this.cashAmount.isZero()
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
this.cashAmount.isZero() &&
|
||||
(!this.transferRefNo || !this.transferClearanceDate)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
disablePayButton(): boolean {
|
||||
if (
|
||||
(this.sinvDoc.grandTotal?.float as number) < 1 &&
|
||||
this.fyo.pesa(this.paidAmount.float).isZero()
|
||||
@ -332,6 +389,12 @@ export default defineComponent({
|
||||
submitTransaction() {
|
||||
this.$emit('createTransaction');
|
||||
},
|
||||
payTransaction() {
|
||||
this.$emit('createTransaction', false, true);
|
||||
},
|
||||
cancelTransaction() {
|
||||
this.$emit('toggleModal', 'Payment');
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user