Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AntPos/src/components/Customer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ const selectedCustomer = computed({
if(invoiceStore.invoice.is_return) return
emit('update:customer', newVal);
emitter.emit('calctotal')
emitter.emit('clear',false)

},
});

Expand Down
10 changes: 8 additions & 2 deletions AntPos/src/components/Dialog/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@
<script setup>
import { Dialog, Button, FeatherIcon ,FormControl, Badge, ErrorMessage } from 'frappe-ui';
import ImageUploader from '@/components/Controls/ImageUploader.vue'
import { ref, inject } from 'vue';
import { ref, onBeforeMount } from 'vue';
import { getSettings } from '@/stores/settings'

const dialogVisible = ref(true);
const { setting: settings, setupBrand } = getSettings()
const { setting, settings, setupBrand } = getSettings()

function updateSettings() {
settings.save.submit(null, {
Expand All @@ -137,5 +137,11 @@ function updateSettings() {
},
})
}
onBeforeMount(()=>{
settings.get
// setupBrand()


})

</script>
1 change: 0 additions & 1 deletion AntPos/src/components/ItemDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ let sales_invoice = createResource({
async onSuccess (data) {
if ( status == 'pay'){
invoiceStore.invoice = { ...data.docs[0] ,docstatus:1 }
console.log(invoiceStore.invoice);
return

}else if (status == 'print'){
Expand Down
2 changes: 1 addition & 1 deletion AntPos/src/components/ItemSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { ref, inject, onMounted, onUnmounted } from 'vue';
import { createToast } from '@/utils';
import { showToast } from '@/utils'
import { usePosProfileStore } from '@/stores/posProfile';
import emitter from '@/utils/emitter';
import emitter from '@/utils/emitter';
import { useInvoiceStore } from '@/stores/pos';

const store = usePosProfileStore();
Expand Down
40 changes: 24 additions & 16 deletions AntPos/src/components/Payment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,16 @@
<script setup>

import { createListResource, TextInput, FormControl, FeatherIcon, createResource, TabButtons } from 'frappe-ui';
import { ref, inject, computed, watch, onBeforeMount } from 'vue';
import { ref, computed, watch, onBeforeMount, onMounted } from 'vue';
import Customer from '@/components/Customer.vue';
import { createToast } from '@/utils';
import { usePosProfileStore } from '@/stores/posProfile';
import { usePaymentStore } from '@/stores/payment'
import emitter from '@/utils/emitter';
const store = usePosProfileStore();
const paymentStore = usePaymentStore();
const searchQuery = ref("");
const currentTab = ref('credit');
const customerName = ref(paymentStore.paymentCustomer.name);
const selectAll = ref(false);
const selectedPageLength = ref(20);
const modes = ref([]);
Expand All @@ -196,7 +196,7 @@ const invoices = createListResource({
outstanding_amount: [">", 0],
docstatus: 1,
is_return: 0,
customer: customerName.value
customer: paymentStore.paymentCustomer.name
},
orderBy: 'creation asc',
pageLength: 20,
Expand All @@ -210,7 +210,7 @@ const invoices = createListResource({
});

const filteredInvoices = computed(() => {
if (!invoices.data || !customerName.value) {
if (!invoices.data || !paymentStore.paymentCustomer.name) {
return [];
}
if (!searchQuery.value) {
Expand All @@ -224,13 +224,13 @@ const filteredInvoices = computed(() => {

const hasSelectedInvoice = computed(() => {
if (currentTab.value === 'credit') return invoices.data?.some(inv => inv.selected);
else if (currentTab.value === 'advanced') return customerName.value && modes.value.some(mode => mode.amount > 0);
else if (currentTab.value === 'advanced') return paymentStore.paymentCustomer.name && modes.value.some(mode => mode.amount > 0);
else return false;
});

const calculateAmountTotal = () => {
let total = invoices.data.reduce((sum, invoice) => {
return invoice.selected ? sum + invoice.grand_total : sum;
return invoice.selected ? sum + invoice.outstanding_amount : sum;
}, 0);
paymentStore.payment.paymentAmount = total;
};
Expand Down Expand Up @@ -268,14 +268,15 @@ const addPayments = () => {
paymentStore.payment.diff=0;
};

const clearPayments = () => {
paymentStore.unmountAndRefresh(false)
modes.value.forEach(mode => {
const clearPayments = async (params) => {
paymentStore.unmountAndRefresh(params)
modes?.value?.forEach(mode => {
mode.amount = 0;
});
invoices.data.forEach(invoice => {
invoices?.data?.forEach(invoice => {
invoice.selected = false;
});
await invoices.reload()
selectAll.value = false;
invoices.reload();
};
Expand All @@ -291,10 +292,6 @@ const changemode = (index) => {
paymentStore.payment.paid_amount = paymentStore.payment.paymentAmount;
};

onBeforeMount(() => {
addPayments();
});

const now = () => {
const today = new Date();
const year = today.getFullYear();
Expand Down Expand Up @@ -409,7 +406,7 @@ watch(
() => paymentStore.paymentCustomer,
(newValue, oldValue) => {
if (oldValue != null && newValue.name !== oldValue.name) {
customerName.value = newValue.name;
paymentStore.paymentCustomer.name = newValue.name;
invoices.filters.customer = newValue.name;
invoices.fetch();
}
Expand All @@ -432,7 +429,7 @@ watch(searchQuery, (newQuery) => {
outstanding_amount: [">", 0],
docstatus: 1,
is_return: 0,
customer: customerName.value
customer: paymentStore.paymentCustomer.name
},
orFilters: newQuery
? [
Expand All @@ -442,5 +439,16 @@ watch(searchQuery, (newQuery) => {
});
invoices.reload();
});

onMounted(()=>{
emitter.on('clear', (params) => {
clearPayments(params)
});

})

onBeforeMount(() => {
addPayments();
});

</script>
2 changes: 1 addition & 1 deletion AntPos/src/stores/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const usePaymentStore = defineStore('PaymentEntry', () => {

async function unmountAndRefresh(includeCustomer) {
payment.value = {};
if (!includeCustomer) {
if (includeCustomer) {
paymentCustomer.value = {};
}
await paymentResource.fetch();
Expand Down
4 changes: 2 additions & 2 deletions AntPos/src/stores/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export const useInvoiceStore = defineStore('salesInvoice', () => {
invoiceCustomer.value = {};
}

async function unmountAndRefresh(includeCustomer) {
async function unmountAndRefresh(includeCustomer) {
invoice.value = {};
items.value = [];
await invoiceResource.fetch();

if (!includeCustomer) {
if (includeCustomer) {
invoiceCustomer.value = {};
}
}
Expand Down
2 changes: 0 additions & 2 deletions ant_pos/public/antPOS/assets/CloseShift-BeUzLskN.js

This file was deleted.

Loading