Browse Source

Jul 31 [UPDT] Updated 'odoo_accounting_dashboard'

pull/331/head
AjmalCybro 9 months ago
parent
commit
8bb5f4ef72
  1. 46
      odoo_accounting_dashboard/static/src/js/accounting_dashboard.js

46
odoo_accounting_dashboard/static/src/js/accounting_dashboard.js

@ -1,8 +1,8 @@
/** @odoo-module */ /** @odoo-module */
import { registry } from "@web/core/registry" import { registry } from "@web/core/registry"
import { loadJS} from '@web/core/assets'; import { loadJS } from '@web/core/assets';
import { useService } from "@web/core/utils/hooks" import { useService } from "@web/core/utils/hooks"
const { Component, useRef, onMounted ,useState , onWillStart} = owl const { Component, useRef, onMounted, useState , onWillStart } = owl
export class AccountDashboard extends Component { export class AccountDashboard extends Component {
setup(){ setup(){
@ -22,14 +22,14 @@ export class AccountDashboard extends Component {
payment_data_filter: 'this_month', payment_data_filter: 'this_month',
payment_list_filter: 'customer_payment', payment_list_filter: 'customer_payment',
}) })
this.All = useRef("All"), this.All = useRef("All");
this.AgedRecords = useRef("AgedRecords"), this.AgedRecords = useRef("AgedRecords");
this.Balance = useRef("Balance"), this.Balance = useRef("Balance");
this.orm = useService("orm"); this.orm = useService("orm");
onWillStart(async () => { onWillStart(async () => {
await this.FetchData(); await this.FetchData();
}) })
onMounted(async() => { onMounted(() => {
this.RenderChart() this.RenderChart()
}) })
} }
@ -38,9 +38,15 @@ export class AccountDashboard extends Component {
this.state.chart.forEach((chart)=> { this.state.chart.forEach((chart)=> {
chart.destroy() chart.destroy()
}) })
this.FetchData() await this.fetchAndRender()
} }
} }
async fetchAndRender() {
await this.FetchData()
this.RenderChart()
}
async FetchData(){ async FetchData(){
this.state.data = await this.orm.call('account.move','get_datas',[]); this.state.data = await this.orm.call('account.move','get_datas',[]);
this.state.income_chart = await this.orm.call("account.move","get_income_chart", [this.state.income]); this.state.income_chart = await this.orm.call("account.move","get_income_chart", [this.state.income]);
@ -49,23 +55,21 @@ export class AccountDashboard extends Component {
this.state.aged_payable = await this.orm.call("account.move","get_aged_payable", [this.state.aged_filter,this.state.aged_payable_filter]); this.state.aged_payable = await this.orm.call("account.move","get_aged_payable", [this.state.aged_filter,this.state.aged_payable_filter]);
this.state.top_sale_cust = await this.orm.call("account.move","get_sale_revenue", [this.state.top_sale_cust_filter]); this.state.top_sale_cust = await this.orm.call("account.move","get_sale_revenue", [this.state.top_sale_cust_filter]);
this.state.balance = await this.orm.call("account.move","get_bank_balance", []); this.state.balance = await this.orm.call("account.move","get_bank_balance", []);
this.RenderChart()
} }
async RenderChart(){
this.aged_chart(this.AgedRecords.el,'bar',this.state.aged_payable.partner,'Amount',this.state.aged_payable.amount) RenderChart() {
if (this.state.IncomeExpense == 'income'){ this.aged_chart(this.AgedRecords.el, 'bar', this.state.aged_payable.partner, 'Amount', this.state.aged_payable.amount)
this.income_charts(this.All.el,'bar',this.state.income_chart.date,this.state.income_chart.income) if (this.state.IncomeExpense == 'income') {
} this.income_charts(this.All.el, 'bar', this.state.income_chart.date, this.state.income_chart.income)
else if (this.state.IncomeExpense == 'expense'){ } else if (this.state.IncomeExpense == 'expense') {
this.expense_charts(this.All.el,'bar',this.state.income_chart.date,this.state.income_chart.expense) this.expense_charts(this.All.el, 'bar', this.state.income_chart.date, this.state.income_chart.expense)
} } else if (this.state.IncomeExpense == 'profit') {
else if (this.state.IncomeExpense == 'profit'){ this.profit_charts(this.All.el, 'line', this.state.income_chart.date, this.state.income_chart.profit)
this.profit_charts(this.All.el,'line',this.state.income_chart.date,this.state.income_chart.profit) } else {
} this.AllInOneChart(this.All.el, 'bar', this.state.income_chart.date, this.state.income_chart.income, this.state.income_chart.expense, this.state.income_chart.profit)
else {
this.AllInOneChart(this.All.el,'bar',this.state.income_chart.date,this.state.income_chart.income,this.state.income_chart.expense,this.state.income_chart.profit)
} }
} }
aged_chart(canvas,type,labels,label,data){ aged_chart(canvas,type,labels,label,data){
this.state.chart.push(new Chart( this.state.chart.push(new Chart(
canvas, canvas,

Loading…
Cancel
Save