2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

feat: sync functionality for sales invoice on save

This commit is contained in:
AbleKSaju 2024-10-11 11:44:27 +05:30
parent 55aa8bf111
commit b7d1b70971

View File

@ -331,7 +331,7 @@
class="w-full bg-green-500 dark:bg-green-700 py-6"
@click="
sinvDoc.party && sinvDoc.items?.length
? null
? saveOrder()
: null
"
:disabled="!sinvDoc.party || !sinvDoc.items?.length"
@ -559,6 +559,26 @@ export default defineComponent({
this.loyaltyProgram = party[0]?.loyaltyProgram as string;
this.loyaltyPoints = party[0].loyaltyPoints as number;
},
async saveOrder() {
try {
await this.validate();
await this.sinvDoc.runFormulas();
await this.sinvDoc.sync();
} catch (error) {
return showToast({
type: 'error',
message: t`${error as string}`,
});
}
showToast({
type: 'success',
message: t`Sales Invoice ${this.sinvDoc.name as string} is Saved`,
duration: 'short',
});
await this.afterSync();
},
async setItems() {
const items = (await fyo.db.getAll(ModelNameEnum.Item, {
fields: [],
@ -850,7 +870,10 @@ export default defineComponent({
});
}
},
async afterSync() {
this.clearValues();
this.setSinvDoc();
},
async afterTransaction() {
await this.setItemQtyMap();
await this.clearValues();