diff --git a/POS/src/components/invoices/InvoiceManagement.vue b/POS/src/components/invoices/InvoiceManagement.vue index 5faac78b3..8747a6426 100644 --- a/POS/src/components/invoices/InvoiceManagement.vue +++ b/POS/src/components/invoices/InvoiceManagement.vue @@ -571,6 +571,7 @@ import { import { getInvoiceStatusColor } from "@/utils/invoice" import { useFormatters } from "@/composables/useFormatters" import { useToast } from "@/composables/useToast" +import { useShift } from "@/composables/useShift" import { Button, call, LoadingIndicator } from "frappe-ui" import { computed, onMounted, ref, watch } from "vue" import { isOffline } from "@/utils/offline/offlineState" @@ -584,6 +585,7 @@ import { logger } from "@/utils/logger" const log = logger.create("InvoiceManagement") const { showSuccess, showError } = useToast() +const { currentShift } = useShift() const { formatDate, formatDateTime, formatTime } = useFormatters() const props = defineProps({ @@ -967,6 +969,7 @@ async function handlePaymentCompleted(paymentData) { await call("pos_next.api.partial_payments.add_payment_to_partial_invoice", { invoice_name: selectedInvoice.value.name, payments: paymentData.payments, + pos_opening_shift: currentShift.value?.name, }) showSuccess(__("Payment added successfully")) diff --git a/POS/src/components/partials/PartialPayments.vue b/POS/src/components/partials/PartialPayments.vue index 203b81aa2..73c38ad3d 100644 --- a/POS/src/components/partials/PartialPayments.vue +++ b/POS/src/components/partials/PartialPayments.vue @@ -213,6 +213,7 @@ import PaymentDialog from "@/components/sale/PaymentDialog.vue" import { usePOSSettingsStore } from "@/stores/posSettings" import { useToast } from "@/composables/useToast" import { useFormatters } from "@/composables/useFormatters" +import { useShift } from "@/composables/useShift" import { Button, call } from "frappe-ui" import { onMounted, ref, watch } from "vue" @@ -231,6 +232,8 @@ const props = defineProps({ const emit = defineEmits(["update:modelValue"]) +const { currentShift } = useShift() + const show = ref(props.modelValue) const loading = ref(false) const invoices = ref([]) @@ -323,6 +326,7 @@ async function handlePaymentCompleted(paymentData) { const result = await call("pos_next.api.partial_payments.add_payment_to_partial_invoice", { invoice_name: selectedInvoice.value.name, payments: paymentData.payments, + pos_opening_shift: currentShift.value?.name, }) console.log('[PartialPayments] API response:', result) diff --git a/pos_next/api/partial_payments.py b/pos_next/api/partial_payments.py index f0c087643..0373100ff 100644 --- a/pos_next/api/partial_payments.py +++ b/pos_next/api/partial_payments.py @@ -352,6 +352,7 @@ def create_payment_entry( reference_no: Optional[str] = None, remarks: Optional[str] = None, posting_date: Optional[str] = None, + pos_opening_shift: Optional[str] = None, ) -> str: """ Create a proper Payment Entry that updates Payment Ledger. @@ -458,6 +459,10 @@ def create_payment_entry( if reference_no: pe.reference_no = str(reference_no)[:140] + elif pos_opening_shift: + # Tag with the opening shift name so POS shift closing can find + # this payment entry during reconciliation. + pe.reference_no = str(pos_opening_shift)[:140] else: pe.reference_no = f"POS-{invoice_name}" @@ -710,7 +715,9 @@ def get_partial_payment_details(invoice_name: str) -> Dict: @frappe.whitelist() -def add_payment_to_partial_invoice(invoice_name: str, payments) -> Dict: +def add_payment_to_partial_invoice( + invoice_name: str, payments, pos_opening_shift: str = None +) -> Dict: """ Add payments to a partially paid invoice via Payment Entry. @@ -813,6 +820,7 @@ def add_payment_to_partial_invoice(invoice_name: str, payments) -> Dict: payment_account=payment_account, reference_no=reference_no, remarks=f"POS Payment - {mode_of_payment}", + pos_opening_shift=pos_opening_shift, ) payment_entries_created.append(pe_name)