build version 400

This commit is contained in:
Mohit Panjwani
2020-12-02 17:54:08 +05:30
parent 326508e567
commit 89ee58590c
963 changed files with 62887 additions and 48868 deletions

View File

@ -0,0 +1,219 @@
<template>
<sw-card v-if="chartData" class="flex flex-col mt-6">
<div class="grid grid-cols-12">
<div class="col-span-12 xl:col-span-9 xxl:col-span-10">
<div class="flex justify-between mt-1 mb-6">
<h6 class="flex items-center sw-section-title">
<chart-square-bar-icon class="h-5 text-primary-400" />{{
$t('dashboard.monthly_chart.title')
}}
</h6>
<div class="w-40 h-10">
<sw-select
v-model="selectedYear"
:options="years"
:allow-empty="false"
:show-labels="false"
:placeholder="$t('dashboard.select_year')"
@select="onChangeYear"
/>
</div>
</div>
<line-chart
:format-money="$utils.formatMoney"
:format-graph-money="$utils.formatGraphMoney"
:invoices="getChartInvoices"
:expenses="getChartExpenses"
:receipts="getReceiptTotals"
:income="getNetProfits"
:labels="getChartMonths"
class="sm:w-full"
/>
</div>
<div
class="grid col-span-12 mt-6 text-center xl:mt-0 sm:grid-cols-4 xl:text-right xl:col-span-3 xl:grid-cols-1 xxl:col-span-2"
>
<div class="px-6 py-2">
<span class="text-xs leading-5 lg:text-sm">
{{ $t('dashboard.chart_info.total_sales') }}
</span>
<br />
<span class="block mt-1 text-xl font-semibold leading-8">
<div v-html="getFormattedSalesTotal" />
</span>
</div>
<div class="px-6 py-2">
<span class="text-xs leading-5 lg:text-sm">
{{ $t('dashboard.chart_info.total_receipts') }}
</span>
<br />
<span
class="block mt-1 text-xl font-semibold leading-8"
style="color: #00c99c"
>
<div v-html="getFormattedTotalReceipts" />
</span>
</div>
<div class="px-6 py-2">
<span class="text-xs leading-5 lg:text-sm">
{{ $t('dashboard.chart_info.total_expense') }}
</span>
<br />
<span
class="block mt-1 text-xl font-semibold leading-8"
style="color: #fb7178"
>
<div v-html="getFormattedTotalExpenses" />
</span>
</div>
<div class="px-6 py-2">
<span class="text-xs leading-5 lg:text-sm">
{{ $t('dashboard.chart_info.net_income') }}
</span>
<br />
<span
class="block mt-1 text-xl font-semibold leading-8"
style="color: #5851d8"
>
<div v-html="getFormattedTotalNetProfit" />
</span>
</div>
</div>
</div>
<!-- basic info -->
<customer-info />
</sw-card>
</template>
<script>
import CustomerInfo from './CustomerInfo'
import LineChart from '../../../components/chartjs/LineChart'
import { mapActions, mapGetters } from 'vuex'
import { ChartSquareBarIcon } from '@vue-hero-icons/outline'
export default {
components: {
LineChart,
CustomerInfo,
ChartSquareBarIcon,
},
data() {
return {
id: null,
customers: [],
isLoaded: false,
chartData: null,
years: ['This year', 'Previous year'],
selectedYear: 'This year',
}
},
computed: {
...mapGetters('company', ['defaultCurrency']),
getChartInvoices() {
if (this.chartData && this.chartData.invoiceTotals) {
return this.chartData.invoiceTotals
}
return []
},
getChartExpenses() {
if (this.chartData && this.chartData.expenseTotals) {
return this.chartData.expenseTotals
}
return []
},
getReceiptTotals() {
if (this.chartData && this.chartData.receiptTotals) {
return this.chartData.receiptTotals
}
return []
},
getNetProfits() {
if (this.chartData && this.chartData.netProfits) {
return this.chartData.netProfits
}
return []
},
getChartMonths() {
if (this.chartData && this.chartData.months) {
return this.chartData.months
}
return []
},
getFormattedSalesTotal() {
if (this.chartData && this.chartData.salesTotal) {
return this.$utils.formatMoney(
this.chartData.salesTotal,
this.defaultCurrency
)
}
return 0
},
getFormattedTotalReceipts() {
if (this.chartData && this.chartData.totalReceipts) {
return this.$utils.formatMoney(
this.chartData.totalReceipts,
this.defaultCurrency
)
}
return 0
},
getFormattedTotalExpenses() {
if (this.chartData && this.chartData.totalExpenses) {
return this.$utils.formatMoney(
this.chartData.totalExpenses,
this.defaultCurrency
)
}
return 0
},
getFormattedTotalNetProfit() {
if (this.chartData && this.chartData.netProfit) {
return this.$utils.formatMoney(
this.chartData.netProfit,
this.defaultCurrency
)
}
return 0
},
},
watch: {
$route(to, from) {
this.loadCustomer()
this.selectedYear = 'This year'
},
},
created() {
this.loadCustomer()
},
methods: {
...mapActions('customer', ['fetchViewCustomer']),
async loadCustomer() {
this.isLoaded = false
let response = await this.fetchViewCustomer({ id: this.$route.params.id })
if (response.data) {
this.chartData = response.data.chartData
}
this.isLoaded = false
},
async onChangeYear(data) {
if (data == 'Previous year') {
let response = await this.fetchViewCustomer({
id: this.$route.params.id,
previous_year: true,
})
if (response.data) {
this.chartData = response.data.chartData
}
return true
}
let response = await this.fetchViewCustomer({ id: this.$route.params.id })
if (response.data) {
this.chartData = response.data.chartData
}
return true
},
},
}
</script>

View File

@ -0,0 +1,273 @@
<template>
<div
class="pt-6 mt-5 border-t-2 border-solid lg:pt-8 md:pt-4"
style="border-top-color: #f9fbff"
>
<div class="col-span-12">
<p class="text-gray-500 uppercase sw-section-title">
{{ $t('customers.basic_info') }}
</p>
<div
class="grid grid-cols-1 gap-4 mt-5 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1"
>
<div>
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ $t('customers.display_name') }}
</p>
<p class="text-sm font-bold leading-5 text-black non-italic">
{{
selectedViewCustomer.customer &&
selectedViewCustomer.customer.name
? selectedViewCustomer.customer.name
: ''
}}
</p>
</div>
<div>
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ $t('customers.primary_contact_name') }}
</p>
<p class="text-sm font-bold leading-5 text-black non-italic">
{{
selectedViewCustomer.customer &&
selectedViewCustomer.customer.contact_name
? selectedViewCustomer.customer.contact_name
: ''
}}
</p>
</div>
<div>
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ $t('customers.email') }}
</p>
<p class="text-sm font-bold leading-5 text-black non-italic">
{{
selectedViewCustomer.customer &&
selectedViewCustomer.customer.email
? selectedViewCustomer.customer.email
: ''
}}
</p>
</div>
</div>
<div
class="grid grid-cols-1 gap-4 mt-5 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1"
>
<div>
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ $t('wizard.currency') }}
</p>
<p class="text-sm font-bold leading-5 text-black non-italic">
{{
selectedViewCustomer.customer.currency
? `${selectedViewCustomer.customer.currency.code} (${selectedViewCustomer.customer.currency.symbol})`
: ''
}}
</p>
</div>
<div>
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ $t('customers.phone_number') }}
</p>
<p class="text-sm font-bold leading-5 text-black non-italic">
{{
selectedViewCustomer.customer &&
selectedViewCustomer.customer.phone
? selectedViewCustomer.customer.phone
: ''
}}
</p>
</div>
<div>
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ $t('customers.website') }}
</p>
<p class="text-sm font-bold leading-5 text-black non-italic">
{{
selectedViewCustomer.customer &&
selectedViewCustomer.customer.website
? selectedViewCustomer.customer.website
: ''
}}
</p>
</div>
</div>
<p
v-if="
getFormattedShippingAddress.length ||
getFormattedBillingAddress.length
"
class="mt-8 text-gray-500 uppercase sw-section-title"
>
{{ $t('customers.address') }}
</p>
<div
class="grid grid-cols-1 gap-4 md:grid-cols-2 sm:grid-cols-1 lg:grid-cols-2"
>
<div v-if="getFormattedBillingAddress.length" class="mt-5">
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ $t('customers.billing_address') }}
</p>
<p
class="text-sm font-bold leading-5 text-black non-italic"
v-html="getFormattedBillingAddress"
/>
</div>
<div v-if="getFormattedShippingAddress.length" class="mt-5">
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ $t('customers.shipping_address') }}
</p>
<p
class="text-sm font-bold leading-5 text-black non-italic"
v-html="getFormattedShippingAddress"
/>
</div>
</div>
<!-- Custom Fields -->
<p
v-if="getCustomField.length > 0"
class="mt-8 text-gray-500 uppercase sw-section-title"
>
{{ $t('settings.custom_fields.title') }}
</p>
<div
class="grid grid-cols-1 gap-4 mt-5 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1"
>
<div
v-for="(field, index) in getCustomField"
:key="index"
:required="field.is_required ? true : false"
>
<p
class="mb-1 text-sm font-normal leading-5 non-italic text-primary-800"
>
{{ field.custom_field.label }}
</p>
<p
v-if="field.type === 'Switch'"
class="text-sm font-bold leading-5 text-black non-italic"
>
<span v-if="field.defaultAnswer === 1"> Yes </span>
<span v-else> No </span>
</p>
<p v-else class="text-sm font-bold leading-5 text-black non-italic">
{{ field.defaultAnswer }}
</p>
</div>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
data() {
return {
customer: null,
customFields: [],
}
},
computed: {
getFormattedBillingAddress() {
let billingAddress = ``
if (!this.selectedViewCustomer.customer) {
return billingAddress
}
if (!this.selectedViewCustomer.customer.billing_address) {
return billingAddress
}
if (this.selectedViewCustomer.customer.billing_address.address_street_1) {
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.address_street_1},</span><br>`
}
if (this.selectedViewCustomer.customer.billing_address.address_street_2) {
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.address_street_2},</span><br>`
}
if (this.selectedViewCustomer.customer.billing_address.city) {
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.city},</span> `
}
if (this.selectedViewCustomer.customer.billing_address.state) {
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.state},</span><br>`
}
if (this.selectedViewCustomer.customer.billing_address.country) {
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.country.name}.</span> `
}
if (this.selectedViewCustomer.customer.billing_address.zip) {
billingAddress += `<span>${this.selectedViewCustomer.customer.billing_address.zip}.</span> `
}
return billingAddress
},
getFormattedShippingAddress() {
let shippingAddress = ``
if (!this.selectedViewCustomer.customer) {
return shippingAddress
}
if (!this.selectedViewCustomer.customer.shipping_address) {
return shippingAddress
}
if (
this.selectedViewCustomer.customer.shipping_address.address_street_1
) {
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.address_street_1},</span><br>`
}
if (
this.selectedViewCustomer.customer.shipping_address.address_street_2
) {
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.address_street_2},</span><br>`
}
if (this.selectedViewCustomer.customer.shipping_address.city) {
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.city},</span> `
}
if (this.selectedViewCustomer.customer.shipping_address.state) {
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.state},</span><br>`
}
if (this.selectedViewCustomer.customer.shipping_address.country) {
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.country.name}.</span> `
}
if (this.selectedViewCustomer.customer.shipping_address.zip) {
shippingAddress += `<span>${this.selectedViewCustomer.customer.shipping_address.zip}.</span> `
}
return shippingAddress
},
getCustomField() {
if (this.selectedViewCustomer.customer.fields) {
return this.selectedViewCustomer.customer.fields
}
return []
},
...mapGetters('customer', ['selectedViewCustomer']),
},
watch: {
$route(to, from) {
this.customer = this.selectedViewCustomer
},
},
}
</script>

View File

@ -0,0 +1,273 @@
<template>
<div
class="fixed top-0 left-0 hidden h-full pt-16 pb-4 ml-56 bg-white xl:ml-64 w-88 xl:block"
>
<div
class="flex items-center justify-between px-4 pt-8 pb-2 border border-gray-200 border-solid height-full"
>
<sw-input
v-model="searchData.searchText"
:placeholder="$t('general.search')"
class="mb-6"
type="text"
variant="gray"
@input="onSearch()"
>
<search-icon slot="rightIcon" class="h-5" />
</sw-input>
<div class="flex mb-6 ml-3" role="group" aria-label="First group">
<sw-dropdown
:close-on-select="false"
align="left"
position="bottom-start"
>
<sw-button slot="activator" size="md" variant="gray-light">
<filter-icon class="h-5" />
</sw-button>
<div
class="px-2 py-1 pb-2 mb-2 text-sm border-b border-gray-200 border-solid"
>
{{ $t('general.sort_by') }}
</div>
<sw-dropdown-item class="flex cursor-pointer">
<sw-input-group class="-mt-3 font-normal">
<sw-radio
:label="$t('customers.create_date')"
size="sm"
id="filter_create_date"
v-model="searchData.orderByField"
name="filter"
value="invoices.created_at"
@change="onSearch"
/>
</sw-input-group>
</sw-dropdown-item>
<sw-dropdown-item class="flex cursor-pointer">
<sw-input-group class="-mt-3 font-normal">
<sw-radio
:label="$t('customers.display_name')"
size="sm"
id="filter_display_name"
v-model="searchData.orderByField"
name="filter"
value="users.name"
@change="onSearch"
/>
</sw-input-group>
</sw-dropdown-item>
</sw-dropdown>
<sw-button
class="ml-1"
v-tooltip.top-center="{ content: getOrderName }"
size="md"
variant="gray-light"
@click="sortData"
>
<sort-ascending-icon v-if="getOrderBy" class="h-5" />
<sort-descending-icon v-else class="h-5" />
</sw-button>
</div>
</div>
<base-loader v-if="isSearching" :show-bg-overlay="true" />
<div
v-else
class="h-full pb-32 overflow-y-scroll border-l border-gray-200 border-solid sidebar sw-scroll"
>
<router-link
v-for="(customer, index) in customers"
:to="`/admin/customers/${customer.id}/view`"
:key="index"
:id="'customer-' + customer.id"
:class="[
'flex justify-between p-4 items-center cursor-pointer hover:bg-gray-100 border-l-4 border-transparent',
{
'bg-gray-100 border-l-4 border-primary-500 border-solid': hasActiveUrl(
customer.id
),
},
]"
style="border-top: 1px solid rgba(185, 193, 209, 0.41)"
>
<div>
<div
class="pr-2 text-sm not-italic font-normal leading-5 text-black capitalize truncate"
>
{{ customer.name }}
</div>
<div
class="mt-1 text-xs not-italic font-medium leading-5 text-gray-600"
v-if="customer.contact_name"
>
{{ customer.contact_name }}
</div>
</div>
<div class="flex-1 whitespace-no-wrap right">
<div
class="text-xl not-italic font-semibold leading-8 text-right text-gray-900"
v-html="$utils.formatMoney(customer.due_amount, customer.currency)"
/>
</div>
</router-link>
<p
v-if="!customers.length"
class="flex justify-center px-4 mt-5 text-sm text-gray-600"
>
{{ $t('customers.no_matching_customers') }}
</p>
</div>
</div>
</template>
<script>
import {
FilterIcon,
SortAscendingIcon,
SortDescendingIcon,
SearchIcon,
} from '@vue-hero-icons/solid'
import { mapActions, mapGetters } from 'vuex'
const _ = require('lodash')
export default {
components: {
FilterIcon,
SortAscendingIcon,
SortDescendingIcon,
SearchIcon,
},
data() {
return {
id: null,
customers: [],
customer: null,
currency: null,
searchData: {
orderBy: null,
orderByField: null,
searchText: null,
},
isSearching: false,
}
},
computed: {
getOrderBy() {
if (
this.searchData.orderBy === 'asc' ||
this.searchData.orderBy == null
) {
return true
}
return false
},
getOrderName() {
if (this.getOrderBy) {
return this.$t('general.ascending')
}
return this.$t('general.descending')
},
...mapGetters('company', ['defaultCurrency']),
...mapGetters('customer', ['selectedViewCustomer']),
},
watch: {
$route(to, from) {
this.loadCustomer()
},
},
created() {
this.loadCustomers()
this.loadCustomer()
this.onSearch = _.debounce(this.onSearch, 500)
},
methods: {
...mapActions('customer', ['fetchCustomers']),
hasActiveUrl(id) {
return this.$route.params.id == id
},
async loadCustomers() {
let response = await this.fetchCustomers({
limit: 'all',
})
if (response.data.customers) {
this.customers = response.data.customers.data
}
setTimeout(() => {
this.scrollToCustomer()
}, 500)
},
scrollToCustomer() {
const el = document.getElementById(`customer-${this.$route.params.id}`)
if (el) {
el.scrollIntoView({ behavior: 'smooth' })
el.classList.add('shake')
}
},
async loadCustomer() {
this.customer = this.selectedViewCustomer
this.currency = this.selectedViewCustomer.currency
},
async onSearch() {
let data = {}
if (
this.searchData.searchText !== '' &&
this.searchData.searchText !== null &&
this.searchData.searchText !== undefined
) {
data.display_name = this.searchData.searchText
}
if (
this.searchData.orderBy !== null &&
this.searchData.orderBy !== undefined
) {
data.orderBy = this.searchData.orderBy
}
if (
this.searchData.orderByField !== null &&
this.searchData.orderByField !== undefined
) {
data.orderByField = this.searchData.orderByField
}
this.isSearching = true
try {
let response = await this.fetchCustomers({ ...data })
this.isSearching = false
if (response.data) {
this.customers = response.data.customers.data
}
} catch (error) {
this.isSearching = false
}
},
sortData() {
if (this.searchData.orderBy === 'asc') {
this.searchData.orderBy = 'desc'
this.onSearch()
return true
}
this.searchData.orderBy = 'asc'
this.onSearch()
return true
},
},
}
</script>