fix dashbord & using FROM_MAIL_ADDRESS issues

This commit is contained in:
raishvaria
2020-01-27 13:43:48 +05:30
parent 22e7e96dfa
commit ca170f5a87
7 changed files with 38 additions and 65 deletions

View File

@ -36,7 +36,8 @@ class DashboardController extends Controller
$start = Carbon::now();
$end = Carbon::now();
$terms = explode('-', $fiscalYear);
if ($terms[0] < $start->month) {
if ($terms[0] <= $start->month) {
$startDate->month($terms[0])->startOfMonth();
$start->month($terms[0])->startOfMonth();
$end->month($terms[0])->endOfMonth();
@ -93,6 +94,7 @@ class DashboardController extends Controller
}
$start->subMonth()->endOfMonth();
$salesTotal = Invoice::whereCompany($request->header('company'))
->whereBetween(
'invoice_date',

View File

@ -168,10 +168,6 @@ class EstimatesController extends Controller
$data['user'] = User::find($userId)->toArray();
$data['company'] = Company::find($estimate->company_id);
$email = $data['user']['email'];
$notificationEmail = CompanySetting::getSetting(
'notification_email',
$request->header('company')
);
if (!$email) {
return response()->json([
@ -179,13 +175,13 @@ class EstimatesController extends Controller
]);
}
if (!$notificationEmail) {
if (!config('mail.from.name')) {
return response()->json([
'error' => 'notification_email_does_not_exist'
'error' => 'from_email_does_not_exist'
]);
}
\Mail::to($email)->send(new EstimatePdf($data, $notificationEmail));
\Mail::to($email)->send(new EstimatePdf($data));
}
$estimate = Estimate::with([
@ -340,10 +336,6 @@ class EstimatesController extends Controller
$data['company'] = Company::find($estimate->company_id);
$email = $data['user']['email'];
$notificationEmail = CompanySetting::getSetting(
'notification_email',
$request->header('company')
);
if (!$email) {
return response()->json([
@ -351,13 +343,13 @@ class EstimatesController extends Controller
]);
}
if (!$notificationEmail) {
if (!config('mail.from.name')) {
return response()->json([
'error' => 'notification_email_does_not_exist'
'error' => 'from_email_does_not_exist'
]);
}
\Mail::to($email)->send(new EstimatePdf($data, $notificationEmail));
\Mail::to($email)->send(new EstimatePdf($data));
if ($estimate->status == Estimate::STATUS_DRAFT) {
$estimate->status = Estimate::STATUS_SENT;

View File

@ -167,11 +167,6 @@ class InvoicesController extends Controller
$data['user'] = User::find($request->user_id)->toArray();
$data['company'] = Company::find($invoice->company_id);
$notificationEmail = CompanySetting::getSetting(
'notification_email',
$request->header('company')
);
$email = $data['user']['email'];
if (!$email) {
@ -180,13 +175,13 @@ class InvoicesController extends Controller
]);
}
if (!$notificationEmail) {
if (!config('mail.from.name')) {
return response()->json([
'error' => 'notification_email_does_not_exist'
'error' => 'from_email_does_not_exist'
]);
}
\Mail::to($email)->send(new invoicePdf($data, $notificationEmail));
\Mail::to($email)->send(new invoicePdf($data));
}
$invoice = Invoice::with(['items', 'user', 'invoiceTemplate', 'taxes'])->find($invoice->id);
@ -408,10 +403,6 @@ class InvoicesController extends Controller
$data['user'] = User::find($userId)->toArray();
$data['company'] = Company::find($invoice->company_id);
$email = $data['user']['email'];
$notificationEmail = CompanySetting::getSetting(
'notification_email',
$request->header('company')
);
if (!$email) {
return response()->json([
@ -419,13 +410,13 @@ class InvoicesController extends Controller
]);
}
if (!$notificationEmail) {
if (!config('mail.from.name')) {
return response()->json([
'error' => 'notification_email_does_not_exist'
'error' => 'from_email_does_not_exist'
]);
}
\Mail::to($email)->send(new invoicePdf($data, $notificationEmail));
\Mail::to($email)->send(new invoicePdf($data));
if ($invoice->status == Invoice::STATUS_DRAFT) {
$invoice->status = Invoice::STATUS_SENT;

View File

@ -12,17 +12,14 @@ class EstimatePdf extends Mailable
public $data = [];
public $notificationEmail = '';
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data, $notificationEmail)
public function __construct($data)
{
$this->data = $data;
$this->notificationEmail = $notificationEmail;
}
/**
@ -32,6 +29,6 @@ class EstimatePdf extends Mailable
*/
public function build()
{
return $this->from($this->notificationEmail)->markdown('emails.send.estimate', ['data', $this->data]);
return $this->markdown('emails.send.estimate', ['data', $this->data]);
}
}

View File

@ -12,17 +12,14 @@ class invoicePdf extends Mailable
public $data = [];
public $notificationEmail = '';
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data, $notificationEmail)
public function __construct($data)
{
$this->data = $data;
$this->notificationEmail = $notificationEmail;
}
/**
@ -32,6 +29,6 @@ class invoicePdf extends Mailable
*/
public function build()
{
return $this->from($this->notificationEmail)->markdown('emails.send.invoice', ['data', $this->data]);
return $this->markdown('emails.send.invoice', ['data', $this->data]);
}
}

View File

@ -13,13 +13,13 @@ export const loadData = ({ commit, dispatch, state }, params) => {
})
}
export const getChart = ({ commit, dispatch, state }) => {
return new Promise((resolve, reject) => {
window.axios.get(`/api/dashboard/expense/chart`).then((response) => {
commit(types.SET_INITIAL_DATA, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
// export const getChart = ({ commit, dispatch, state }) => {
// return new Promise((resolve, reject) => {
// window.axios.get(`/api/dashboard/expense/chart`).then((response) => {
// commit(types.SET_INITIAL_DATA, response.data)
// resolve(response)
// }).catch((err) => {
// reject(err)
// })
// })
// }

View File

@ -398,7 +398,6 @@ export default {
}
},
created () {
this.loadChart()
this.loadData()
},
methods: {
@ -422,11 +421,6 @@ export default {
'markEstimateAsSent': 'markAsSent'
}),
async loadChart () {
await this.$store.dispatch('dashboard/getChart')
this.isLoaded = true
},
async loadData (params) {
await this.$store.dispatch('dashboard/loadData', params)
this.isLoaded = true
@ -434,7 +428,7 @@ export default {
async removeEstimate (id) {
this.id = id
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$tc('estimates.confirm_delete', 1),
icon: '/assets/icon/trash-solid.svg',
@ -462,7 +456,7 @@ export default {
},
async convertInToinvoice (id) {
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$t('estimates.confirm_conversion'),
icon: '/assets/icon/file-alt-solid.svg',
@ -483,7 +477,7 @@ export default {
},
async onMarkAsSent (id) {
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$t('estimates.confirm_mark_as_sent'),
icon: '/assets/icon/check-circle-solid.svg',
@ -505,7 +499,7 @@ export default {
async removeInvoice (id) {
this.id = id
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$tc('invoices.confirm_delete'),
icon: '/assets/icon/trash-solid.svg',
@ -525,7 +519,7 @@ export default {
},
async sendInvoice (id) {
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$t('invoices.confirm_send'),
icon: '/assets/icon/paper-plane-solid.svg',
@ -552,7 +546,7 @@ export default {
},
async sentInvoice (id) {
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$t('invoices.invoice_mark_as_sent'),
icon: '/assets/icon/check-circle-solid.svg',
@ -573,7 +567,7 @@ export default {
},
async onMarkAsAccepted (id) {
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$t('estimates.confirm_mark_as_accepted'),
icon: '/assets/icon/check-circle-solid.svg',
@ -595,7 +589,7 @@ export default {
},
async onMarkAsRejected (id) {
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$t('estimates.confirm_mark_as_rejected'),
icon: '/assets/icon/times-circle-solid.svg',
@ -617,7 +611,7 @@ export default {
},
async sendEstimate (id) {
swal({
window.swal({
title: this.$t('general.are_you_sure'),
text: this.$t('estimates.confirm_send_estimate'),
icon: '/assets/icon/paper-plane-solid.svg',