diff --git a/fyo/core/converter.ts b/fyo/core/converter.ts index 09d51296..4671ba30 100644 --- a/fyo/core/converter.ts +++ b/fyo/core/converter.ts @@ -56,6 +56,10 @@ export class Converter { } static toDocValue(value: RawValue, field: Field, fyo: Fyo): DocValue { + if (!field?.fieldtype) { + console.log(value, field); + console.trace(); + } switch (field.fieldtype) { case FieldTypeEnum.Currency: return toDocCurrency(value, field, fyo); @@ -102,6 +106,9 @@ export class Converter { for (const fieldname in rawValueMap) { const field = fieldValueMap[fieldname]; const rawValue = rawValueMap[fieldname]; + if (!field) { + continue; + } if (Array.isArray(rawValue)) { const parentSchemaName = (field as TargetField).target; diff --git a/schemas/app/GetStarted.json b/schemas/app/GetStarted.json index a0c0ce40..91a2a14c 100644 --- a/schemas/app/GetStarted.json +++ b/schemas/app/GetStarted.json @@ -24,8 +24,13 @@ "fieldtype": "Check" }, { - "fieldname": "itemCreated", - "label": "Item Created", + "fieldname": "salesItemCreated", + "label": "Purchase Item Created", + "fieldtype": "Check" + }, + { + "fieldname": "purchaseItemCreated", + "label": "Sales Item Created", "fieldtype": "Check" }, { diff --git a/src/components/Charts/LineChart.vue b/src/components/Charts/LineChart.vue index 9e17ad8f..3e4469f6 100644 --- a/src/components/Charts/LineChart.vue +++ b/src/components/Charts/LineChart.vue @@ -122,7 +122,7 @@ >

- {{ xi > -1 ? xLabels[xi] : '' }} + {{ xi > -1 ? formatX(xLabels[xi]) : '' }}

{{ yi > -1 ? format(points[yi][xi]) : '' }} diff --git a/src/components/MouseFollower.vue b/src/components/MouseFollower.vue new file mode 100644 index 00000000..bfbbe496 --- /dev/null +++ b/src/components/MouseFollower.vue @@ -0,0 +1,35 @@ + + + diff --git a/src/pages/Dashboard/Cashflow.vue b/src/pages/Dashboard/Cashflow.vue index 93c6cc7f..3b116997 100644 --- a/src/pages/Dashboard/Cashflow.vue +++ b/src/pages/Dashboard/Cashflow.vue @@ -46,7 +46,8 @@ import { ModelNameEnum } from 'models/types'; import LineChart from 'src/components/Charts/LineChart.vue'; import { fyo } from 'src/initFyo'; import { formatXLabels, getYMax } from 'src/utils/chart'; -import { getDatesAndPeriodicity } from 'src/utils/misc'; +import { getDatesAndPeriodList } from 'src/utils/misc'; +import { getMapFromList } from 'utils/'; import PeriodSelector from './PeriodSelector'; export default { @@ -89,8 +90,25 @@ export default { }, methods: { async setData() { - const { fromDate, toDate } = await getDatesAndPeriodicity(this.period); - this.data = await fyo.db.getCashflow(fromDate, toDate); + const { periodList, fromDate, toDate } = await getDatesAndPeriodList( + this.period + ); + + const data = await fyo.db.getCashflow(fromDate, toDate); + const dataMap = getMapFromList(data, 'month-year'); + this.data = periodList.map((p) => { + const key = p.toFormat('yyyy-MM'); + const item = dataMap[key]; + if (item) { + return item; + } + + return { + inflow: 0, + outflow: 0, + 'month-year': key, + }; + }); }, async setHasData() { const accounts = await fyo.db.getAllRaw('Account', { diff --git a/src/pages/Dashboard/UnpaidInvoices.vue b/src/pages/Dashboard/UnpaidInvoices.vue index d2a1c4dc..db731ce5 100644 --- a/src/pages/Dashboard/UnpaidInvoices.vue +++ b/src/pages/Dashboard/UnpaidInvoices.vue @@ -2,7 +2,7 @@

@@ -10,7 +10,7 @@ diff --git a/src/pages/GetStarted.vue b/src/pages/GetStarted.vue index 0d24d407..82eff24f 100644 --- a/src/pages/GetStarted.vue +++ b/src/pages/GetStarted.vue @@ -166,43 +166,40 @@ export default { return; } - if (!fyo.singles.GetStarted.itemCreated) { - const count = await fyo.db.count('Item'); - if (count > 0) { - toUpdate.itemCreated = 1; - } + if (!fyo.singles.GetStarted.salesItemCreated) { + const count = await fyo.db.count('Item', { filters: { for: 'Sales' } }); + toUpdate.salesItemCreated = count > 0; + } + + if (!fyo.singles.GetStarted.purchaseItemCreated) { + const count = await fyo.db.count('Item', { + filters: { for: 'Purchases' }, + }); + toUpdate.purchaseItemCreated = count > 0; } if (!fyo.singles.GetStarted.invoiceCreated) { const count = await fyo.db.count('SalesInvoice'); - if (count > 0) { - toUpdate.invoiceCreated = 1; - } + toUpdate.invoiceCreated = count > 0; } if (!fyo.singles.GetStarted.customerCreated) { - const count = fyo.db.count('Party', { + const count = await fyo.db.count('Party', { filters: { role: 'Customer' }, }); - if (count > 0) { - toUpdate.customerCreated = 1; - } + toUpdate.customerCreated = count > 0; } if (!fyo.singles.GetStarted.billCreated) { const count = await fyo.db.count('SalesInvoice'); - if (count > 0) { - toUpdate.billCreated = 1; - } + toUpdate.billCreated = count > 0; } if (!fyo.singles.GetStarted.supplierCreated) { - const count = fyo.db.count('Party', { + const count = await fyo.db.count('Party', { filters: { role: 'Supplier' }, }); - if (count > 0) { - toUpdate.supplierCreated = 1; - } + toUpdate.supplierCreated = count > 0; } await this.updateChecks(toUpdate); }, @@ -211,10 +208,10 @@ export default { await fyo.doc.getSingle('GetStarted'); }, isCompleted(item) { - return fyo.singles.GetStarted.get(item.fieldname) || 0; + return fyo.singles.GetStarted.get(item.fieldname) || false; }, getIconComponent(item) { - let completed = fyo.singles.GetStarted[item.fieldname] || 0; + let completed = fyo.singles.GetStarted[item.fieldname] || false; let name = completed ? 'green-check' : item.icon; let size = completed ? '24' : '18'; return { diff --git a/src/utils/getStartedConfig.ts b/src/utils/getStartedConfig.ts index 6f195c62..45717f15 100644 --- a/src/utils/getStartedConfig.ts +++ b/src/utils/getStartedConfig.ts @@ -84,8 +84,8 @@ export function getGetStartedConfig() { label: t`Add Items`, icon: 'item', description: t`Add products or services that you sell to your customers`, - action: () => routeTo('/list/Item'), - fieldname: 'itemCreated', + action: () => routeTo(`/list/Item/for/Sales/${t`Sales Items`}`), + fieldname: 'salesItemCreated', documentation: 'https://frappebooks.com/docs/setting-up#3-add-items', }, { @@ -93,7 +93,7 @@ export function getGetStartedConfig() { label: t`Add Customers`, icon: 'customer', description: t`Add a few customers to create your first invoice`, - action: () => routeTo('/list/Customer'), + action: () => routeTo(`/list/Party/role/Customer/${t`Customers`}`), fieldname: 'customerCreated', documentation: 'https://frappebooks.com/docs/setting-up#4-add-customers', @@ -118,15 +118,16 @@ export function getGetStartedConfig() { label: t`Add Items`, icon: 'item', description: t`Add products or services that you buy from your suppliers`, - action: () => routeTo('/list/Item'), - fieldname: 'itemCreated', + action: () => + routeTo(`/list/Item/for/Purchases/${t`Purchase Items`}`), + fieldname: 'purchaseItemCreated', }, { key: 'Add Suppliers', label: t`Add Suppliers`, icon: 'supplier', description: t`Add a few suppliers to create your first bill`, - action: () => routeTo('/list/Supplier'), + action: () => routeTo(`/list/Party/role/Supplier/${t`Suppliers`}`), fieldname: 'supplierCreated', }, { diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 92965fa4..f4e18e18 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -7,9 +7,9 @@ import SetupWizardSchema from 'schemas/app/SetupWizard.json'; import { Schema } from 'schemas/types'; import { fyo } from 'src/initFyo'; -export function getDatesAndPeriodicity( +export function getDatesAndPeriodList( period: 'This Year' | 'This Quarter' | 'This Month' -): { fromDate: string; toDate: string } { +): { periodList: DateTime[]; fromDate: string; toDate: string } { const toDate: DateTime = DateTime.now(); let fromDate: DateTime; @@ -23,7 +23,22 @@ export function getDatesAndPeriodicity( fromDate = toDate.minus({ days: 1 }); } + /** + * periodList: Monthly decrements before toDate until fromDate + */ + const periodList: DateTime[] = [toDate]; + while (true) { + const nextDate = periodList.at(0)!.minus({ months: 1 }); + if (nextDate.toMillis() < fromDate.toMillis()) { + break; + } + + periodList.unshift(nextDate); + } + periodList.shift(); + return { + periodList, fromDate: fromDate.toISO(), toDate: toDate.toISO(), }; diff --git a/src/utils/vueUtils.ts b/src/utils/vueUtils.ts index 93b2c88d..8a476256 100644 --- a/src/utils/vueUtils.ts +++ b/src/utils/vueUtils.ts @@ -29,3 +29,21 @@ export function useKeys(callback?: (keys: Set) => void) { return keys; } + +export function useMouseLocation() { + const loc = ref({ clientX: 0, clientY: 0 }); + + const mousemoveListener = (e: MouseEvent) => { + loc.value.clientX = e.clientX; + loc.value.clientY = e.clientY; + }; + + onMounted(() => { + window.addEventListener('mousemove', mousemoveListener); + }); + onUnmounted(() => { + window.removeEventListener('mousemove', mousemoveListener); + }); + + return loc; +}