2
0
mirror of https://github.com/frappe/books.git synced 2025-01-10 10:16:22 +00:00

feat: submit and print functionality from POS

This commit is contained in:
AbleKSaju 2024-12-28 11:58:31 +05:30
parent d803151cf9
commit b8ce9673d4

View File

@ -575,8 +575,8 @@ export default defineComponent({
async createTransaction(shouldPrint = false) { async createTransaction(shouldPrint = false) {
try { try {
await this.validate(); await this.validate();
await this.submitSinvDoc(shouldPrint); await this.submitSinvDoc();
await this.makePayment(); await this.makePayment(shouldPrint);
await this.makeStockTransfer(); await this.makeStockTransfer();
await this.afterTransaction(); await this.afterTransaction();
await this.setItems(); await this.setItems();
@ -587,7 +587,7 @@ export default defineComponent({
}); });
} }
}, },
async makePayment() { async makePayment(shouldPrint: boolean) {
this.paymentDoc = this.sinvDoc.getPayment() as Payment; this.paymentDoc = this.sinvDoc.getPayment() as Payment;
const paymentMethod = this.paymentMethod; const paymentMethod = this.paymentMethod;
@ -623,6 +623,13 @@ export default defineComponent({
try { try {
await this.paymentDoc?.sync(); await this.paymentDoc?.sync();
await this.paymentDoc?.submit(); await this.paymentDoc?.submit();
if (shouldPrint) {
await routeTo(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`/print/${this.sinvDoc.schemaName}/${this.sinvDoc.name}`
);
}
} catch (error) { } catch (error) {
return showToast({ return showToast({
type: 'error', type: 'error',
@ -660,20 +667,13 @@ export default defineComponent({
}); });
} }
}, },
async submitSinvDoc(shouldPrint: boolean) { async submitSinvDoc() {
this.sinvDoc.once('afterSubmit', async () => { this.sinvDoc.once('afterSubmit', () => {
showToast({ showToast({
type: 'success', type: 'success',
message: t`Sales Invoice ${this.sinvDoc.name as string} is Submitted`, message: t`Sales Invoice ${this.sinvDoc.name as string} is Submitted`,
duration: 'short', duration: 'short',
}); });
if (shouldPrint) {
await routeTo(
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
`/print/${this.sinvDoc.schemaName}/${this.sinvDoc.name}`
);
}
}); });
try { try {