diff --git a/POS/src/components/invoices/InvoiceManagement.vue b/POS/src/components/invoices/InvoiceManagement.vue index 573eaa3c3..ed313071a 100644 --- a/POS/src/components/invoices/InvoiceManagement.vue +++ b/POS/src/components/invoices/InvoiceManagement.vue @@ -1032,6 +1032,7 @@ import { DEFAULT_CURRENCY, formatCurrency as formatCurrencyUtil } from "@/utils/ 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"; @@ -1045,6 +1046,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({ @@ -1405,6 +1407,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 700731279..76f9dd143 100644 --- a/POS/src/components/partials/PartialPayments.vue +++ b/POS/src/components/partials/PartialPayments.vue @@ -345,6 +345,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"; @@ -363,6 +364,8 @@ const props = defineProps({ const emit = defineEmits(["update:modelValue"]); +const { currentShift } = useShift(); + const show = ref(props.modelValue); const loading = ref(false); const invoices = ref([]); @@ -455,6 +458,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 7494535d2..67e8a4308 100644 --- a/pos_next/api/partial_payments.py +++ b/pos_next/api/partial_payments.py @@ -346,6 +346,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. @@ -450,6 +451,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}" @@ -700,7 +705,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. @@ -799,6 +806,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)