update invoice, estimate & payment vars

This commit is contained in:
raishvaria
2019-12-12 16:04:12 +05:30
parent 36be395579
commit 5f7401f622
6 changed files with 15 additions and 9 deletions

View File

@ -60,9 +60,10 @@ class EstimatesController extends Controller
$estimate_num_auto_generate = CompanySetting::getSetting('estimate_auto_generate', $request->header('company')); $estimate_num_auto_generate = CompanySetting::getSetting('estimate_auto_generate', $request->header('company'));
$nextEstimateNumberAttribute = null; $nextEstimateNumberAttribute = null;
$nextEstimateNumber = Estimate::getNextEstimateNumber($estimate_prefix);
if ($estimate_num_auto_generate == "YES") { if ($estimate_num_auto_generate == "YES") {
$nextEstimateNumberAttribute = Estimate::getNextEstimateNumber($estimate_prefix); $nextEstimateNumberAttribute = $nextEstimateNumber;
} }
$tax_per_item = CompanySetting::getSetting('tax_per_item', $request->header('company')); $tax_per_item = CompanySetting::getSetting('tax_per_item', $request->header('company'));
@ -71,7 +72,8 @@ class EstimatesController extends Controller
return response()->json([ return response()->json([
'customers' => $customers, 'customers' => $customers,
'nextEstimateNumber' => $nextEstimateNumberAttribute, 'nextEstimateNumberAttribute' => $nextEstimateNumberAttribute,
'nextEstimateNumber' => $estimate_prefix.'-'.$nextEstimateNumber,
'taxes' => Tax::whereCompany($request->header('company'))->latest()->get(), 'taxes' => Tax::whereCompany($request->header('company'))->latest()->get(),
'items' => Item::whereCompany($request->header('company'))->get(), 'items' => Item::whereCompany($request->header('company'))->get(),
'tax_per_item' => $tax_per_item, 'tax_per_item' => $tax_per_item,

View File

@ -70,13 +70,15 @@ class InvoicesController extends Controller
$invoice_num_auto_generate = CompanySetting::getSetting('invoice_auto_generate', $request->header('company')); $invoice_num_auto_generate = CompanySetting::getSetting('invoice_auto_generate', $request->header('company'));
$nextInvoiceNumberAttribute = null; $nextInvoiceNumberAttribute = null;
$nextInvoiceNumber = Invoice::getNextInvoiceNumber($invoice_prefix);
if ($invoice_num_auto_generate == "YES") { if ($invoice_num_auto_generate == "YES") {
$nextInvoiceNumberAttribute = Invoice::getNextInvoiceNumber($invoice_prefix); $nextInvoiceNumberAttribute = $nextInvoiceNumber;
} }
return response()->json([ return response()->json([
'nextInvoiceNumber' => $nextInvoiceNumberAttribute, 'nextInvoiceNumberAttribute' => $nextInvoiceNumberAttribute,
'nextInvoiceNumber' => $invoice_prefix.'-'.$nextInvoiceNumber,
'items' => Item::with('taxes')->whereCompany($request->header('company'))->get(), 'items' => Item::with('taxes')->whereCompany($request->header('company'))->get(),
'invoiceTemplates' => InvoiceTemplate::all(), 'invoiceTemplates' => InvoiceTemplate::all(),
'tax_per_item' => $tax_per_item, 'tax_per_item' => $tax_per_item,

View File

@ -56,16 +56,18 @@ class PaymentController extends Controller
$nextPaymentNumberAttribute = null; $nextPaymentNumberAttribute = null;
$nextPaymentNumber = Payment::getNextPaymentNumber($payment_prefix);
if ($payment_num_auto_generate == "YES") { if ($payment_num_auto_generate == "YES") {
$nextPaymentNumberAttribute = Payment::getNextPaymentNumber($payment_prefix); $nextPaymentNumberAttribute = $nextPaymentNumber;
} }
return response()->json([ return response()->json([
'customers' => User::where('role', 'customer') 'customers' => User::where('role', 'customer')
->whereCompany($request->header('company')) ->whereCompany($request->header('company'))
->get(), ->get(),
'nextPaymentNumber' => $nextPaymentNumberAttribute, 'nextPaymentNumberAttribute' => $nextPaymentNumberAttribute,
'nextPaymentNumber' => $payment_prefix.'-'.$nextPaymentNumber,
'payment_prefix' => $payment_prefix 'payment_prefix' => $payment_prefix
]); ]);
} }

View File

@ -582,7 +582,7 @@ export default {
this.newEstimate.expiry_date = moment(today).add(7, 'days').toString() this.newEstimate.expiry_date = moment(today).add(7, 'days').toString()
this.itemList = response.data.items this.itemList = response.data.items
this.estimatePrefix = response.data.estimate_prefix this.estimatePrefix = response.data.estimate_prefix
this.estimateNumAttribute = response.data.nextEstimateNumber this.estimateNumAttribute = response.data.nextEstimateNumberAttribute
} }
this.initLoading = false this.initLoading = false
}, },

View File

@ -582,7 +582,7 @@ export default {
this.newInvoice.due_date = moment(today).add(7, 'days').toString() this.newInvoice.due_date = moment(today).add(7, 'days').toString()
this.itemList = response.data.items this.itemList = response.data.items
this.invoicePrefix = response.data.invoice_prefix this.invoicePrefix = response.data.invoice_prefix
this.invoiceNumAttribute = response.data.nextInvoiceNumber this.invoiceNumAttribute = response.data.nextInvoiceNumberAttribute
} }
this.initLoading = false this.initLoading = false
}, },

View File

@ -309,7 +309,7 @@ export default {
} else { } else {
let response = await this.fetchCreatePayment() let response = await this.fetchCreatePayment()
this.customerList = response.data.customers this.customerList = response.data.customers
this.paymentNumAttribute = response.data.nextPaymentNumber this.paymentNumAttribute = response.data.nextPaymentNumberAttribute
this.paymentPrefix = response.data.payment_prefix this.paymentPrefix = response.data.payment_prefix
this.formData.payment_date = moment(new Date()).toString() this.formData.payment_date = moment(new Date()).toString()
} }