Skip to content
Open
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
3 changes: 3 additions & 0 deletions POS/src/components/invoices/InvoiceManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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({
Expand Down Expand Up @@ -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"))
Expand Down
4 changes: 4 additions & 0 deletions POS/src/components/partials/PartialPayments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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([])
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion pos_next/api/partial_payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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}"

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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)
Expand Down
Loading