Skip to content

Commit

Permalink
refactor: rename 'frappe' to 'fyo' outside src
Browse files Browse the repository at this point in the history
- cause now most of it is different from what it was
  • Loading branch information
18alantom committed May 23, 2022
1 parent 76bf6cf commit de7e5ba
Show file tree
Hide file tree
Showing 103 changed files with 570 additions and 581 deletions.
4 changes: 2 additions & 2 deletions META.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ requires resources from the _server_ side, it does so by making use of
`ipcRenderer.send` or `ipcRenderer.invoke` i.e. if the front end is being run on
electron.

The `ipcRenderer` calls are done only in `frappe/demux/*.ts` files. I.e. these
The `ipcRenderer` calls are done only in `fyo/demux/*.ts` files. I.e. these
are the only files on the _client_ side that are aware of the platform the
_client_ is being run on i.e. `electron` or Browser. So all platform specific
calls should go through these _demux_ files.
Expand Down Expand Up @@ -53,7 +53,7 @@ individual ones, check the `README.md` in those subdirectories:
| `src` | _client_ | Code that mainly deals with the view layer (all `.vue` are stored here) |
| `reports` | _client_ | Collection of logic code and view layer config files for displaying reports. |
| `models` | _client\*_ | Collection of `Model.ts` files that manage the data and some business logic on the client side. |
| `frappe` | _client\*_ | Code for the underlying library that manages the client side |
| `fyo` | _client\*_ | Code for the underlying library that manages the client side |
| `utils` | _agnostic_ | Collection of code used by either sides. |

#### _client\*_
Expand Down
2 changes: 1 addition & 1 deletion accounting/exchangeRate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NotFoundError } from 'frappe/utils/errors';
import { NotFoundError } from 'fyo/utils/errors';
import { DateTime } from 'luxon';

export async function getExchangeRate({
Expand Down
2 changes: 1 addition & 1 deletion accounting/gst.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { showMessageDialog } from '@/utils';
import frappe, { t } from 'frappe';
import frappe, { t } from 'fyo';
import { DateTime } from 'luxon';
import { stateCodeMap } from '../regional/in';
import { exportCsv, saveExportData } from '../reports/commonExporter';
Expand Down
2 changes: 1 addition & 1 deletion accounting/importCOA.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import frappe from 'frappe';
import frappe from 'fyo';
import standardCOA from '../fixtures/verified/standardCOA.json';
import { getCOAList } from '../src/utils';
const accountFields = ['accountType', 'accountNumber', 'rootType', 'isGroup'];
Expand Down
36 changes: 18 additions & 18 deletions accounting/ledgerPosting.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Frappe } from 'frappe';
import Doc from 'frappe/model/doc';
import { ValidationError } from 'frappe/utils/errors';
import { Fyo } from 'fyo';
import Doc from 'fyo/model/doc';
import { ValidationError } from 'fyo/utils/errors';
import Money from 'pesa/dist/types/src/money';
import {
AccountEntry,
Expand All @@ -19,11 +19,11 @@ export class LedgerPosting {
reverted: boolean;
accountEntries: AccountEntry[];

frappe: Frappe;
fyo: Fyo;

constructor(
{ reference, party, date, description }: LedgerPostingOptions,
frappe: Frappe
fyo: Fyo
) {
this.reference = reference;
this.party = party;
Expand All @@ -35,7 +35,7 @@ export class LedgerPosting {
// To change balance while entering ledger entries
this.accountEntries = [];

this.frappe = frappe;
this.fyo = fyo;
}

async debit(
Expand Down Expand Up @@ -66,7 +66,7 @@ export class LedgerPosting {
amount: Money
) {
const debitAccounts = ['Asset', 'Expense'];
const accountDoc = await this.frappe.doc.getDoc('Account', accountName);
const accountDoc = await this.fyo.doc.getDoc('Account', accountName);
const rootType = accountDoc.rootType as string;

if (debitAccounts.indexOf(rootType) === -1) {
Expand Down Expand Up @@ -94,8 +94,8 @@ export class LedgerPosting {
referenceName: referenceName ?? this.reference.name!,
description: this.description,
reverted: this.reverted,
debit: this.frappe.pesa(0),
credit: this.frappe.pesa(0),
debit: this.fyo.pesa(0),
credit: this.fyo.pesa(0),
};

this.entries.push(entry);
Expand All @@ -113,7 +113,7 @@ export class LedgerPosting {
async postReverse() {
this.validateEntries();

const data = await this.frappe.db.getAll('AccountingLedgerEntry', {
const data = await this.fyo.db.getAll('AccountingLedgerEntry', {
fields: ['name'],
filters: {
referenceName: this.reference.name!,
Expand All @@ -122,7 +122,7 @@ export class LedgerPosting {
});

for (const entry of data) {
const entryDoc = await this.frappe.doc.getDoc(
const entryDoc = await this.fyo.doc.getDoc(
'AccountingLedgerEntry',
entry.name as string
);
Expand Down Expand Up @@ -166,10 +166,10 @@ export class LedgerPosting {
const { debit, credit } = this.getTotalDebitAndCredit();
if (debit.neq(credit)) {
throw new ValidationError(
`Total Debit: ${this.frappe.format(
`Total Debit: ${this.fyo.format(
debit,
'Currency'
)} must be equal to Total Credit: ${this.frappe.format(
)} must be equal to Total Credit: ${this.fyo.format(
credit,
'Currency'
)}`
Expand All @@ -178,8 +178,8 @@ export class LedgerPosting {
}

getTotalDebitAndCredit() {
let debit = this.frappe.pesa(0);
let credit = this.frappe.pesa(0);
let debit = this.fyo.pesa(0);
let credit = this.fyo.pesa(0);

for (const entry of this.entries) {
debit = debit.add(entry.debit);
Expand All @@ -191,19 +191,19 @@ export class LedgerPosting {

async insertEntries() {
for (const entry of this.entries) {
const entryDoc = this.frappe.doc.getNewDoc('AccountingLedgerEntry');
const entryDoc = this.fyo.doc.getNewDoc('AccountingLedgerEntry');
Object.assign(entryDoc, entry);
await entryDoc.insert();
}
for (const entry of this.accountEntries) {
const entryDoc = await this.frappe.doc.getDoc('Account', entry.name);
const entryDoc = await this.fyo.doc.getDoc('Account', entry.name);
const balance = entryDoc.get('balance') as Money;
entryDoc.balance = balance.add(entry.balanceChange);
await entryDoc.update();
}
}

getRoundOffAccount() {
return this.frappe.singles.AccountingSettings!.roundOffAccount as string;
return this.fyo.singles.AccountingSettings!.roundOffAccount as string;
}
}
2 changes: 1 addition & 1 deletion accounting/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Doc from 'frappe/model/doc';
import Doc from 'fyo/model/doc';
import Money from 'pesa/dist/types/src/money';

export interface LedgerPostingOptions {
Expand Down
2 changes: 1 addition & 1 deletion accounting/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { t } from 'frappe';
import { t } from 'fyo';

export const ledgerLink = {
label: t`Ledger Entries`,
Expand Down
4 changes: 2 additions & 2 deletions backend/database/core.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { knex, Knex } from 'knex';
import {
CannotCommitError,
DatabaseError,
DuplicateEntryError,
LinkValidationError,
NotFoundError,
ValueError,
} from '../../frappe/utils/errors';
} from 'fyo/utils/errors';
import { knex, Knex } from 'knex';
import {
Field,
FieldTypeEnum,
Expand Down
2 changes: 1 addition & 1 deletion fixtures/standardCOA.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { t } from 'frappe';
import { t } from 'fyo';

export default {
[t`Application of Funds (Assets)`]: {
Expand Down
116 changes: 0 additions & 116 deletions frappe/telemetry/helpers.ts

This file was deleted.

File renamed without changes.
14 changes: 7 additions & 7 deletions frappe/core/authHandler.ts → fyo/core/authHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Frappe } from 'frappe';
import { AuthDemux } from 'frappe/demux/auth';
import { Fyo } from 'fyo';
import { AuthDemux } from 'fyo/demux/auth';
import { AuthDemuxBase, TelemetryCreds } from 'utils/auth/types';
import { AuthDemuxConstructor } from './types';

Expand All @@ -17,11 +17,11 @@ interface Session {
export class AuthHandler {
#config: AuthConfig;
#session: Session;
frappe: Frappe;
fyo: Fyo;
#demux: AuthDemuxBase;

constructor(frappe: Frappe, Demux?: AuthDemuxConstructor) {
this.frappe = frappe;
constructor(fyo: Fyo, Demux?: AuthDemuxConstructor) {
this.fyo = fyo;
this.#config = {
serverURL: '',
backend: 'sqlite',
Expand All @@ -34,9 +34,9 @@ export class AuthHandler {
};

if (Demux !== undefined) {
this.#demux = new Demux(frappe.isElectron);
this.#demux = new Demux(fyo.isElectron);
} else {
this.#demux = new AuthDemux(frappe.isElectron);
this.#demux = new AuthDemux(fyo.isElectron);
}
}

Expand Down
16 changes: 8 additions & 8 deletions frappe/core/converter.ts → fyo/core/converter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Frappe } from 'frappe';
import Doc from 'frappe/model/doc';
import { Fyo } from 'fyo';
import Doc from 'fyo/model/doc';
import Money from 'pesa/dist/types/src/money';
import { FieldType, FieldTypeEnum, RawValue } from 'schemas/types';
import { DatabaseHandler } from './dbHandler';
Expand All @@ -22,11 +22,11 @@ import { DocValue, DocValueMap, RawValueMap } from './types';

export class Converter {
db: DatabaseHandler;
frappe: Frappe;
fyo: Fyo;

constructor(db: DatabaseHandler, frappe: Frappe) {
constructor(db: DatabaseHandler, fyo: Fyo) {
this.db = db;
this.frappe = frappe;
this.fyo = fyo;
}

toDocValueMap(
Expand Down Expand Up @@ -54,11 +54,11 @@ export class Converter {
static toDocValue(
value: RawValue,
fieldtype: FieldType,
frappe: Frappe
fyo: Fyo
): DocValue {
switch (fieldtype) {
case FieldTypeEnum.Currency:
return frappe.pesa((value ?? 0) as string | number);
return fyo.pesa((value ?? 0) as string | number);
case FieldTypeEnum.Date:
return new Date(value as string);
case FieldTypeEnum.Datetime:
Expand Down Expand Up @@ -119,7 +119,7 @@ export class Converter {
docValueMap[fieldname] = Converter.toDocValue(
rawValue,
field.fieldtype,
this.frappe
this.fyo
);
}
}
Expand Down
Loading

0 comments on commit de7e5ba

Please sign in to comment.