mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 13:41:09 -04:00 
			
		
		
		
	fix payment edit issue when invoice selected from url
This commit is contained in:
		| @ -6,7 +6,7 @@ export default { | ||||
|   customer_id: '', | ||||
|   payment_number: '', | ||||
|   payment_date: '', | ||||
|   amount: 100, | ||||
|   amount: 0, | ||||
|   invoice_id: '', | ||||
|   notes: '', | ||||
|   payment_method_id: '', | ||||
|  | ||||
| @ -448,7 +448,7 @@ function onCustomerChange(customer_id) { | ||||
|           paymentStore.currentPayment.currency = res2.data.data.currency | ||||
|         } | ||||
|  | ||||
|         if (isEdit.value && paymentStore.currentPayment.invoice_id) { | ||||
|         if (paymentStore.currentPayment.invoice_id) { | ||||
|           selectedInvoice.value = invoiceList.value.find( | ||||
|             (inv) => inv.id === paymentStore.currentPayment.invoice_id | ||||
|           ) | ||||
| @ -456,9 +456,14 @@ function onCustomerChange(customer_id) { | ||||
|           paymentStore.currentPayment.maxPayableAmount = | ||||
|             selectedInvoice.value.due_amount + | ||||
|             paymentStore.currentPayment.amount | ||||
|  | ||||
|           if (amount.value === 0) { | ||||
|             amount.value = selectedInvoice.value.due_amount / 100 | ||||
|           } | ||||
|         } | ||||
|  | ||||
|         if (isEdit.value) { | ||||
|           // remove all invoices that are paid except currently selected invoice | ||||
|           invoiceList.value = invoiceList.value.filter((v) => { | ||||
|             return ( | ||||
|               v.due_amount > 0 || v.id == paymentStore.currentPayment.invoice_id | ||||
| @ -515,7 +520,7 @@ function selectNewCustomer(id) { | ||||
|   if (route.params.id) params.model_id = route.params.id | ||||
|  | ||||
|   paymentStore.currentPayment.invoice_id = selectedInvoice.value = null | ||||
|   paymentStore.currentPayment.amount = 100 | ||||
|   paymentStore.currentPayment.amount = 0 | ||||
|   invoiceList.value = [] | ||||
|   paymentStore.getNextNumber(params, true) | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user