fix payment edit issue when invoice selected from url

This commit is contained in:
Mohit Panjwani
2021-12-09 12:41:17 +05:30
parent 769e16cfca
commit f4e3688216
3 changed files with 37 additions and 3 deletions

View File

@ -0,0 +1,29 @@
<?php
use Crater\Models\Setting;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateCraterVersion505 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Setting::setSetting('version', '5.0.5');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -6,7 +6,7 @@ export default {
customer_id: '',
payment_number: '',
payment_date: '',
amount: 100,
amount: 0,
invoice_id: '',
notes: '',
payment_method_id: '',

View File

@ -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)
}