2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 03:19:01 +00:00

incr: small fixes

This commit is contained in:
18alantom 2022-05-18 20:28:35 +05:30
parent 986d4da23e
commit 37dc3e911f
16 changed files with 38 additions and 10 deletions

View File

@ -86,6 +86,10 @@ export class Doc extends Observable<DocValue | Doc[]> {
return this._notInserted; return this._notInserted;
} }
get inserted(): boolean {
return !this._notInserted;
}
get tableFields(): TargetField[] { get tableFields(): TargetField[] {
return this.schema.fields.filter( return this.schema.fields.filter(
(f) => f.fieldtype === FieldTypeEnum.Table (f) => f.fieldtype === FieldTypeEnum.Table

View File

@ -84,7 +84,7 @@ export class Main {
.ELECTRON_NODE_INTEGRATION as unknown as boolean, .ELECTRON_NODE_INTEGRATION as unknown as boolean,
}, },
frame: this.isLinux, frame: this.isLinux,
resizable: true, resizable: false,
}; };
if (this.isDevelopment || this.isLinux) { if (this.isDevelopment || this.isLinux) {
Object.assign(options, { icon: this.icon }); Object.assign(options, { icon: this.icon });
@ -139,6 +139,10 @@ export class Main {
this.mainWindow = null; this.mainWindow = null;
}); });
this.mainWindow.on('will-resize', (e) => {
e.preventDefault();
});
this.mainWindow.webContents.on('did-finish-load', () => { this.mainWindow.webContents.on('did-finish-load', () => {
if (this.mainWindow === null) { if (this.mainWindow === null) {
return; return;

View File

@ -13,6 +13,7 @@ import { getMapFromList } from 'utils';
export class BalanceSheet extends AccountReport { export class BalanceSheet extends AccountReport {
static title = t`Balance Sheet`; static title = t`Balance Sheet`;
static reportName = 'balance-sheet'; static reportName = 'balance-sheet';
loading: boolean = false;
get rootTypes(): AccountRootType[] { get rootTypes(): AccountRootType[] {
return [ return [
@ -23,6 +24,7 @@ export class BalanceSheet extends AccountReport {
} }
async setReportData(filter?: string) { async setReportData(filter?: string) {
this.loading = true;
if (filter !== 'hideGroupAmounts') { if (filter !== 'hideGroupAmounts') {
await this._setRawData(); await this._setRawData();
} }
@ -55,6 +57,7 @@ export class BalanceSheet extends AccountReport {
this.reportData = await this.getReportDataFromRows( this.reportData = await this.getReportDataFromRows(
getMapFromList(rootTypeRows, 'rootType') getMapFromList(rootTypeRows, 'rootType')
); );
this.loading = false;
} }
async getReportDataFromRows( async getReportDataFromRows(

View File

@ -23,6 +23,7 @@ export class GeneralLedger extends LedgerReport {
static title = t`General Ledger`; static title = t`General Ledger`;
static reportName = 'general-ledger'; static reportName = 'general-ledger';
usePagination: boolean = true; usePagination: boolean = true;
loading: boolean = false;
ascending: boolean = false; ascending: boolean = false;
reverted: boolean = false; reverted: boolean = false;
@ -42,6 +43,7 @@ export class GeneralLedger extends LedgerReport {
} }
async setReportData(filter?: string) { async setReportData(filter?: string) {
this.loading = true;
let sort = true; let sort = true;
if (filter !== 'grouped' || this._rawData.length === 0) { if (filter !== 'grouped' || this._rawData.length === 0) {
await this._setRawData(); await this._setRawData();
@ -78,6 +80,7 @@ export class GeneralLedger extends LedgerReport {
}); });
this.reportData = this._convertEntriesToReportData(consolidated); this.reportData = this._convertEntriesToReportData(consolidated);
this.loading = false;
} }
_setIndexOnEntries(map: GroupedMap) { _setIndexOnEntries(map: GroupedMap) {

View File

@ -19,6 +19,7 @@ export abstract class BaseGSTR extends Report {
transferType?: TransferType; transferType?: TransferType;
usePagination: boolean = true; usePagination: boolean = true;
gstrRows?: GSTRRow[]; gstrRows?: GSTRRow[];
loading: boolean = false;
abstract gstrType: GSTRType; abstract gstrType: GSTRType;
@ -46,10 +47,12 @@ export abstract class BaseGSTR extends Report {
} }
async setReportData(): Promise<void> { async setReportData(): Promise<void> {
this.loading = true;
const gstrRows = await this.getGstrRows(); const gstrRows = await this.getGstrRows();
const filteredRows = this.filterGstrRows(gstrRows); const filteredRows = this.filterGstrRows(gstrRows);
this.gstrRows = filteredRows; this.gstrRows = filteredRows;
this.reportData = this.getReportDataFromGSTRRows(filteredRows); this.reportData = this.getReportDataFromGSTRRows(filteredRows);
this.loading = false;
} }
getReportDataFromGSTRRows(gstrRows: GSTRRow[]): ReportData { getReportDataFromGSTRRows(gstrRows: GSTRRow[]): ReportData {

View File

@ -17,12 +17,14 @@ import {
export class ProfitAndLoss extends AccountReport { export class ProfitAndLoss extends AccountReport {
static title = t`Profit And Loss`; static title = t`Profit And Loss`;
static reportName = 'profit-and-loss'; static reportName = 'profit-and-loss';
loading: boolean = false;
get rootTypes(): AccountRootType[] { get rootTypes(): AccountRootType[] {
return [AccountRootTypeEnum.Income, AccountRootTypeEnum.Expense]; return [AccountRootTypeEnum.Income, AccountRootTypeEnum.Expense];
} }
async setReportData(filter?: string) { async setReportData(filter?: string) {
this.loading = true;
if (filter !== 'hideGroupAmounts') { if (filter !== 'hideGroupAmounts') {
await this._setRawData(); await this._setRawData();
} }
@ -66,6 +68,7 @@ export class ProfitAndLoss extends AccountReport {
incomeRoot, incomeRoot,
expenseRoot expenseRoot
); );
this.loading = false;
} }
async getReportDataFromRows( async getReportDataFromRows(

View File

@ -14,6 +14,7 @@ export abstract class Report extends Observable<RawValue> {
filters: Field[] = []; filters: Field[] = [];
reportData: ReportData; reportData: ReportData;
usePagination: boolean = false; usePagination: boolean = false;
abstract loading: boolean;
constructor(fyo: Fyo) { constructor(fyo: Fyo) {
super(); super();

View File

@ -36,6 +36,7 @@ export class TrialBalance extends AccountReport {
fromDate?: string; fromDate?: string;
toDate?: string; toDate?: string;
hideGroupAmounts: boolean = false; hideGroupAmounts: boolean = false;
loading: boolean = false;
_rawData: LedgerEntry[] = []; _rawData: LedgerEntry[] = [];
_dateRanges?: DateRange[]; _dateRanges?: DateRange[];
@ -53,6 +54,7 @@ export class TrialBalance extends AccountReport {
} }
async setReportData(filter?: string) { async setReportData(filter?: string) {
this.loading = true;
if (filter !== 'hideGroupAmounts') { if (filter !== 'hideGroupAmounts') {
await this._setRawData(); await this._setRawData();
} }
@ -74,6 +76,7 @@ export class TrialBalance extends AccountReport {
.filter((row) => !!row.rootNode); .filter((row) => !!row.rootNode);
this.reportData = await this.getReportDataFromRows(rootTypeRows); this.reportData = await this.getReportDataFromRows(rootTypeRows);
this.loading = false;
} }
async getReportDataFromRows( async getReportDataFromRows(

View File

@ -161,10 +161,10 @@ export default {
format: { type: Function, default: (n) => n.toFixed(1) }, format: { type: Function, default: (n) => n.toFixed(1) },
formatY: { type: Function, default: prefixFormat }, formatY: { type: Function, default: prefixFormat },
formatX: { type: Function, default: (v) => v }, formatX: { type: Function, default: (v) => v },
fontSize: { type: Number, default: 25 }, fontSize: { type: Number, default: 22 },
fontColor: { type: String, default: '#415668' }, fontColor: { type: String, default: '#415668' },
bottom: { type: Number, default: 0 }, bottom: { type: Number, default: 0 },
width: { type: Number, default: 34 }, width: { type: Number, default: 28 },
left: { type: Number, default: 65 }, left: { type: Number, default: 65 },
radius: { type: Number, default: 17 }, radius: { type: Number, default: 17 },
extendGridX: { type: Number, default: -20 }, extendGridX: { type: Number, default: -20 },

View File

@ -160,7 +160,7 @@ export default {
format: { type: Function, default: (n) => n.toFixed(1) }, format: { type: Function, default: (n) => n.toFixed(1) },
formatY: { type: Function, default: prefixFormat }, formatY: { type: Function, default: prefixFormat },
formatX: { type: Function, default: (v) => v }, formatX: { type: Function, default: (v) => v },
fontSize: { type: Number, default: 18 }, fontSize: { type: Number, default: 20 },
fontColor: { type: String, default: '#415668' }, fontColor: { type: String, default: '#415668' },
bottom: { type: Number, default: 0 }, bottom: { type: Number, default: 0 },
left: { type: Number, default: 55 }, left: { type: Number, default: 55 },

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="overflow-hidden flex flex-col h-full"> <div class="overflow-hidden flex flex-col h-full">
<!-- Report Outer Container --> <!-- Report Outer Container -->
<div class="overflow-hidden"> <div class="overflow-hidden" v-if="dataSlice.length">
<!--Title Row --> <!--Title Row -->
<div <div
class="w-full overflow-x-hidden flex items-center border-b" class="w-full overflow-x-hidden flex items-center border-b"
@ -61,6 +61,9 @@
</WithScroll> </WithScroll>
<!-- Report Rows Container --> <!-- Report Rows Container -->
</div> </div>
<p v-else class="w-full text-center mt-20 text-gray-800 text-base">
{{ report.loading ? t`Loading Report...` : t`No Values to be Displayed` }}
</p>
<!-- Pagination Footer --> <!-- Pagination Footer -->
<div class="mt-auto flex-shrink-0" v-if="report.usePagination"> <div class="mt-auto flex-shrink-0" v-if="report.usePagination">

View File

@ -179,7 +179,7 @@ export default {
} }
// handle rename // handle rename
if (this.autosave && df.fieldname === 'name' && !this.doc.notInserted) { if (this.autosave && df.fieldname === 'name' && this.doc.inserted) {
return this.doc.rename(value); return this.doc.rename(value);
} }
@ -190,7 +190,7 @@ export default {
async onChangeCommon(df, value, oldValue) { async onChangeCommon(df, value, oldValue) {
let isSet = false; let isSet = false;
try { try {
isSet = this.doc.set(df.fieldname, value); isSet = await this.doc.set(df.fieldname, value);
} catch (err) { } catch (err) {
this.errors[df.fieldname] = getErrorMessage(err, this.doc); this.errors[df.fieldname] = getErrorMessage(err, this.doc);
} }

View File

@ -54,7 +54,7 @@
</div> </div>
<!-- Pagination Footer --> <!-- Pagination Footer -->
<div class="mt-auto"> <div class="mt-auto" v-if="data?.length">
<hr /> <hr />
<Paginator :item-count="data.length" @index-change="setPageIndices" /> <Paginator :item-count="data.length" @index-change="setPageIndices" />
</div> </div>

View File

@ -58,6 +58,7 @@
v-if="titleField" v-if="titleField"
:df="titleField" :df="titleField"
:value="doc[titleField.fieldname]" :value="doc[titleField.fieldname]"
:read-only="doc.inserted"
@change="(value) => valueChange(titleField, value)" @change="(value) => valueChange(titleField, value)"
@input="setTitleSize" @input="setTitleSize"
/> />

View File

@ -7,7 +7,7 @@ export function getSidebarConfig(): SidebarConfig {
return getFilteredSidebar(sideBar); return getFilteredSidebar(sideBar);
} }
export function getFilteredSidebar(sideBar: SidebarConfig): SidebarConfig { function getFilteredSidebar(sideBar: SidebarConfig): SidebarConfig {
return sideBar.filter((root) => { return sideBar.filter((root) => {
root.items = root.items?.filter((item) => { root.items = root.items?.filter((item) => {
if (item.hidden !== undefined) { if (item.hidden !== undefined) {

View File

@ -283,7 +283,7 @@ function getDeleteAction(doc: Doc): Action {
async action() { async action() {
const res = await deleteDocWithPrompt(doc); const res = await deleteDocWithPrompt(doc);
if (res) { if (res) {
routeTo(`/list/${doc.schemaName}`); router.back();
} }
}, },
}; };