2
0
mirror of https://github.com/frappe/books.git synced 2025-02-02 12:08:27 +00:00

refactor: rename imports, frappejs → frappe

This commit is contained in:
18alantom 2022-01-21 02:27:29 +05:30
parent f602caff81
commit cc09847337
132 changed files with 1140 additions and 1122 deletions

View File

@ -1,6 +1,6 @@
import { showMessageDialog } from '@/utils';
import frappe from 'frappejs';
import { _ } from 'frappejs/utils';
import frappe from 'frappe';
import { _ } from 'frappe/utils';
import { DateTime } from 'luxon';
import { exportCsv, saveExportData } from '../reports/commonExporter';
import { getSavePath } from '../src/utils';

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import countries from '../fixtures/countryInfo.json';
import standardCOA from '../fixtures/verified/standardCOA.json';
const accountFields = ['accountType', 'accountNumber', 'rootType', 'isGroup'];

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
export default class LedgerPosting {
constructor({ reference, party, date, description }) {

View File

@ -1,173 +1,173 @@
import frappe from 'frappejs';
import frappe from 'frappe';
const _ = frappe._.bind(frappe);
export default {
[_("Application of Funds (Assets)")]: {
[_("Current Assets")]: {
[_("Accounts Receivable")]: {
[_("Debtors")]: {
"accountType": "Receivable"
}
},
[_("Bank Accounts")]: {
"accountType": "Bank",
"isGroup": 1
},
[_("Cash In Hand")]: {
[_("Cash")]: {
"accountType": "Cash"
},
"accountType": "Cash"
},
[_("Loans and Advances (Assets)")]: {
"isGroup": 1
},
[_("Securities and Deposits")]: {
[_("Earnest Money")]: {}
},
[_("Stock Assets")]: {
[_("Stock In Hand")]: {
"accountType": "Stock"
},
"accountType": "Stock",
},
[_("Tax Assets")]: {
"isGroup": 1
}
[_('Application of Funds (Assets)')]: {
[_('Current Assets')]: {
[_('Accounts Receivable')]: {
[_('Debtors')]: {
accountType: 'Receivable',
},
[_("Fixed Assets")]: {
[_("Capital Equipments")]: {
"accountType": "Fixed Asset"
},
[_("Electronic Equipments")]: {
"accountType": "Fixed Asset"
},
[_("Furnitures and Fixtures")]: {
"accountType": "Fixed Asset"
},
[_("Office Equipments")]: {
"accountType": "Fixed Asset"
},
[_("Plants and Machineries")]: {
"accountType": "Fixed Asset"
},
[_("Buildings")]: {
"accountType": "Fixed Asset"
},
[_("Softwares")]: {
"accountType": "Fixed Asset"
},
[_("Accumulated Depreciation")]: {
"accountType": "Accumulated Depreciation"
}
},
[_('Bank Accounts')]: {
accountType: 'Bank',
isGroup: 1,
},
[_('Cash In Hand')]: {
[_('Cash')]: {
accountType: 'Cash',
},
[_("Investments")]: {
"isGroup": 1
accountType: 'Cash',
},
[_('Loans and Advances (Assets)')]: {
isGroup: 1,
},
[_('Securities and Deposits')]: {
[_('Earnest Money')]: {},
},
[_('Stock Assets')]: {
[_('Stock In Hand')]: {
accountType: 'Stock',
},
[_("Temporary Accounts")]: {
[_("Temporary Opening")]: {
"accountType": "Temporary"
}
},
"rootType": "Asset"
accountType: 'Stock',
},
[_('Tax Assets')]: {
isGroup: 1,
},
},
[_("Expenses")]: {
[_("Direct Expenses")]: {
[_("Stock Expenses")]: {
[_("Cost of Goods Sold")]: {
"accountType": "Cost of Goods Sold"
},
[_("Expenses Included In Valuation")]: {
"accountType": "Expenses Included In Valuation"
},
[_("Stock Adjustment")]: {
"accountType": "Stock Adjustment"
}
},
},
[_("Indirect Expenses")]: {
[_("Administrative Expenses")]: {},
[_("Commission on Sales")]: {},
[_("Depreciation")]: {
"accountType": "Depreciation"
},
[_("Entertainment Expenses")]: {},
[_("Freight and Forwarding Charges")]: {
"accountType": "Chargeable"
},
[_("Legal Expenses")]: {},
[_("Marketing Expenses")]: {
"accountType": "Chargeable"
},
[_("Miscellaneous Expenses")]: {
"accountType": "Chargeable"
},
[_("Office Maintenance Expenses")]: {},
[_("Office Rent")]: {},
[_("Postal Expenses")]: {},
[_("Print and Stationery")]: {},
[_("Round Off")]: {
"accountType": "Round Off"
},
[_("Salary")]: {},
[_("Sales Expenses")]: {},
[_("Telephone Expenses")]: {},
[_("Travel Expenses")]: {},
[_("Utility Expenses")]: {},
[_("Write Off")]: {},
[_("Exchange Gain/Loss")]: {},
[_("Gain/Loss on Asset Disposal")]: {}
},
"rootType": "Expense"
[_('Fixed Assets')]: {
[_('Capital Equipments')]: {
accountType: 'Fixed Asset',
},
[_('Electronic Equipments')]: {
accountType: 'Fixed Asset',
},
[_('Furnitures and Fixtures')]: {
accountType: 'Fixed Asset',
},
[_('Office Equipments')]: {
accountType: 'Fixed Asset',
},
[_('Plants and Machineries')]: {
accountType: 'Fixed Asset',
},
[_('Buildings')]: {
accountType: 'Fixed Asset',
},
[_('Softwares')]: {
accountType: 'Fixed Asset',
},
[_('Accumulated Depreciation')]: {
accountType: 'Accumulated Depreciation',
},
},
[_("Income")]: {
[_("Direct Income")]: {
[_("Sales")]: {},
[_("Service")]: {}
},
[_("Indirect Income")]: {
"isGroup": 1
},
"rootType": "Income"
[_('Investments')]: {
isGroup: 1,
},
[_("Source of Funds (Liabilities)")]: {
[_("Current Liabilities")]: {
[_("Accounts Payable")]: {
[_("Creditors")]: {
"accountType": "Payable"
},
[_("Payroll Payable")]: {},
},
[_("Stock Liabilities")]: {
[_("Stock Received But Not Billed")]: {
"accountType": "Stock Received But Not Billed"
},
},
[_("Duties and Taxes")]: {
"accountType": "Tax",
"isGroup": 1
},
[_("Loans (Liabilities)")]: {
[_("Secured Loans")]: {},
[_("Unsecured Loans")]: {},
[_("Bank Overdraft Account")]: {},
},
},
"rootType": "Liability"
[_('Temporary Accounts')]: {
[_('Temporary Opening')]: {
accountType: 'Temporary',
},
},
[_("Equity")]: {
[_("Capital Stock")]: {
"accountType": "Equity"
rootType: 'Asset',
},
[_('Expenses')]: {
[_('Direct Expenses')]: {
[_('Stock Expenses')]: {
[_('Cost of Goods Sold')]: {
accountType: 'Cost of Goods Sold',
},
[_("Dividends Paid")]: {
"accountType": "Equity"
[_('Expenses Included In Valuation')]: {
accountType: 'Expenses Included In Valuation',
},
[_("Opening Balance Equity")]: {
"accountType": "Equity"
[_('Stock Adjustment')]: {
accountType: 'Stock Adjustment',
},
[_("Retained Earnings")]: {
"accountType": "Equity"
},
},
[_('Indirect Expenses')]: {
[_('Administrative Expenses')]: {},
[_('Commission on Sales')]: {},
[_('Depreciation')]: {
accountType: 'Depreciation',
},
[_('Entertainment Expenses')]: {},
[_('Freight and Forwarding Charges')]: {
accountType: 'Chargeable',
},
[_('Legal Expenses')]: {},
[_('Marketing Expenses')]: {
accountType: 'Chargeable',
},
[_('Miscellaneous Expenses')]: {
accountType: 'Chargeable',
},
[_('Office Maintenance Expenses')]: {},
[_('Office Rent')]: {},
[_('Postal Expenses')]: {},
[_('Print and Stationery')]: {},
[_('Round Off')]: {
accountType: 'Round Off',
},
[_('Salary')]: {},
[_('Sales Expenses')]: {},
[_('Telephone Expenses')]: {},
[_('Travel Expenses')]: {},
[_('Utility Expenses')]: {},
[_('Write Off')]: {},
[_('Exchange Gain/Loss')]: {},
[_('Gain/Loss on Asset Disposal')]: {},
},
rootType: 'Expense',
},
[_('Income')]: {
[_('Direct Income')]: {
[_('Sales')]: {},
[_('Service')]: {},
},
[_('Indirect Income')]: {
isGroup: 1,
},
rootType: 'Income',
},
[_('Source of Funds (Liabilities)')]: {
[_('Current Liabilities')]: {
[_('Accounts Payable')]: {
[_('Creditors')]: {
accountType: 'Payable',
},
"rootType": "Equity"
}
};
[_('Payroll Payable')]: {},
},
[_('Stock Liabilities')]: {
[_('Stock Received But Not Billed')]: {
accountType: 'Stock Received But Not Billed',
},
},
[_('Duties and Taxes')]: {
accountType: 'Tax',
isGroup: 1,
},
[_('Loans (Liabilities)')]: {
[_('Secured Loans')]: {},
[_('Unsecured Loans')]: {},
[_('Bank Overdraft Account')]: {},
},
},
rootType: 'Liability',
},
[_('Equity')]: {
[_('Capital Stock')]: {
accountType: 'Equity',
},
[_('Dividends Paid')]: {
accountType: 'Equity',
},
[_('Opening Balance Equity')]: {
accountType: 'Equity',
},
[_('Retained Earnings')]: {
accountType: 'Equity',
},
rootType: 'Equity',
},
};

View File

@ -1,6 +1,6 @@
const frappe = require('frappejs');
const Observable = require('frappejs/utils/observable');
const CacheManager = require('frappejs/utils/cacheManager');
const frappe = require('frappe');
const Observable = require('frappe/utils/observable');
const CacheManager = require('frappe/utils/cacheManager');
const Knex = require('knex');
module.exports = class Database extends Observable {

View File

@ -1,6 +1,6 @@
const frappe = require('frappejs');
const Observable = require('frappejs/utils/observable');
const triggerEvent = name => frappe.events.trigger(`http:${name}`);
const frappe = require('frappe');
const Observable = require('frappe/utils/observable');
const triggerEvent = (name) => frappe.events.trigger(`http:${name}`);
module.exports = class HTTPClient extends Observable {
constructor({ server, protocol = 'http' }) {
@ -16,9 +16,7 @@ module.exports = class HTTPClient extends Observable {
this.initTypeMap();
}
connect() {
}
connect() {}
async insert(doctype, doc) {
doc.doctype = doctype;
@ -27,7 +25,7 @@ module.exports = class HTTPClient extends Observable {
const responseDoc = await this.fetch(url, {
method: 'POST',
body: JSON.stringify(doc)
body: JSON.stringify(doc),
});
await this.uploadFilesAndUpdateDoc(filesToUpload, doctype, responseDoc);
@ -40,21 +38,24 @@ module.exports = class HTTPClient extends Observable {
let url = this.getURL('/api/resource', doctype, name);
return await this.fetch(url, {
method: 'GET',
headers: this.getHeaders()
})
headers: this.getHeaders(),
});
}
async getAll({ doctype, fields, filters, start, limit, sortBy, order }) {
let url = this.getURL('/api/resource', doctype);
url = url + '?' + frappe.getQueryString({
fields: JSON.stringify(fields),
filters: JSON.stringify(filters),
start: start,
limit: limit,
sortBy: sortBy,
order: order
});
url =
url +
'?' +
frappe.getQueryString({
fields: JSON.stringify(fields),
filters: JSON.stringify(filters),
start: start,
limit: limit,
sortBy: sortBy,
order: order,
});
return await this.fetch(url, {
method: 'GET',
@ -68,7 +69,7 @@ module.exports = class HTTPClient extends Observable {
const responseDoc = await this.fetch(url, {
method: 'PUT',
body: JSON.stringify(doc)
body: JSON.stringify(doc),
});
await this.uploadFilesAndUpdateDoc(filesToUpload, doctype, responseDoc);
@ -89,7 +90,7 @@ module.exports = class HTTPClient extends Observable {
return await this.fetch(url, {
method: 'DELETE',
body: JSON.stringify(names)
body: JSON.stringify(names),
});
}
@ -100,9 +101,11 @@ module.exports = class HTTPClient extends Observable {
async getValue(doctype, name, fieldname) {
let url = this.getURL('/api/resource', doctype, name, fieldname);
return (await this.fetch(url, {
method: 'GET',
})).value;
return (
await this.fetch(url, {
method: 'GET',
})
).value;
}
async fetch(url, args) {
@ -131,13 +134,13 @@ module.exports = class HTTPClient extends Observable {
const filesToUpload = [];
if (fileFields.length > 0) {
fileFields.forEach(df => {
fileFields.forEach((df) => {
const files = doc[df.fieldname] || [];
if (files.length) {
filesToUpload.push({
fieldname: df.fieldname,
files: files
})
files: files,
});
}
delete doc[df.fieldname];
});
@ -150,7 +153,12 @@ module.exports = class HTTPClient extends Observable {
if (filesToUpload.length > 0) {
// upload files
for (const fileToUpload of filesToUpload) {
const files = await this.uploadFiles(fileToUpload.files, doctype, doc.name, fileToUpload.fieldname);
const files = await this.uploadFiles(
fileToUpload.files,
doctype,
doc.name,
fileToUpload.fieldname
);
doc[fileToUpload.fieldname] = files[0].name;
}
}
@ -166,7 +174,7 @@ module.exports = class HTTPClient extends Observable {
let response = await frappe.fetch(url, {
method: 'POST',
body: formData
body: formData,
});
const data = await response.json();
@ -182,49 +190,46 @@ module.exports = class HTTPClient extends Observable {
getHeaders() {
const headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
Accept: 'application/json',
'Content-Type': 'application/json',
};
if (frappe.session && frappe.session.token) {
headers.token = frappe.session.token;
};
}
return headers;
}
initTypeMap() {
this.typeMap = {
'AutoComplete': true
, 'Currency': true
, 'Int': true
, 'Float': true
, 'Percent': true
, 'Check': true
, 'Small Text': true
, 'Long Text': true
, 'Code': true
, 'Text Editor': true
, 'Date': true
, 'Datetime': true
, 'Time': true
, 'Text': true
, 'Data': true
, 'Link': true
, 'DynamicLink': true
, 'Password': true
, 'Select': true
, 'Read Only': true
, 'File': true
, 'Attach': true
, 'Attach Image': true
, 'Signature': true
, 'Color': true
, 'Barcode': true
, 'Geolocation': true
}
AutoComplete: true,
Currency: true,
Int: true,
Float: true,
Percent: true,
Check: true,
'Small Text': true,
'Long Text': true,
Code: true,
'Text Editor': true,
Date: true,
Datetime: true,
Time: true,
Text: true,
Data: true,
Link: true,
DynamicLink: true,
Password: true,
Select: true,
'Read Only': true,
File: true,
Attach: true,
'Attach Image': true,
Signature: true,
Color: true,
Barcode: true,
Geolocation: true,
};
}
close() {
}
}
close() {}
};

View File

@ -1,210 +1,238 @@
const frappe = require('frappejs');
const frappe = require('frappe');
const mysql = require('mysql');
const Database = require('./database');
const debug = false;
module.exports = class mysqlDatabase extends Database {
constructor({ db_name, username, password, host }) {
super();
this.db_name = db_name;
this.username = username;
this.password = password;
this.host = host;
this.init_typeMap();
}
module.exports = class mysqlDatabase extends Database{
constructor({ db_name, username, password, host }) {
super();
this.db_name = db_name;
this.username = username;
this.password = password;
this.host = host;
this.init_typeMap();
connect(db_name) {
if (db_name) {
this.db_name = db_name;
}
connect(db_name) {
if (db_name) {
this.db_name = db_name;
return new Promise((resolve) => {
this.conn = new mysql.createConnection({
host: this.host,
user: this.username,
password: this.password,
database: this.db_name,
});
() => {
if (debug) {
this.conn.on('trace', (trace) => console.log(trace));
}
return new Promise(resolve => {
this.conn = new mysql.createConnection({
host : this.host,
user : this.username,
password : this.password,
database : this.db_name
});
() => {
if (debug) {
this.conn.on('trace', (trace) => console.log(trace));
}
};
resolve();
});
};
resolve();
});
}
}
async tableExists(table) {
const name = await this.sql(`SELECT table_name
async tableExists(table) {
const name = await this.sql(`SELECT table_name
FROM information_schema.tables
WHERE table_schema = '${this.db_name}'
AND table_name = '${table}'`);
return (name && name.length) ? true : false;
}
return name && name.length ? true : false;
}
async runCreateTableQuery(doctype, columns, values){
const query = `CREATE TABLE IF NOT EXISTS ${doctype} (
${columns.join(", ")})`;
async runCreateTableQuery(doctype, columns, values) {
const query = `CREATE TABLE IF NOT EXISTS ${doctype} (
${columns.join(', ')})`;
return await this.run(query, values);
}
return await this.run(query, values);
}
updateColumnDefinition(df, columns, indexes) {
columns.push(
`${df.fieldname} ${this.typeMap[df.fieldtype]} ${
df.required && !df.default ? 'not null' : ''
} ${df.default ? `default '${df.default}'` : ''}`
);
}
updateColumnDefinition(df, columns, indexes) {
columns.push(`${df.fieldname} ${this.typeMap[df.fieldtype]} ${df.required && !df.default ? "not null" : ""} ${df.default ? `default '${df.default}'` : ""}`);
}
async getTableColumns(doctype) {
return (await this.sql(`SHOW COLUMNS FROM ${doctype}`)).map((d) => d.Field);
}
async getTableColumns(doctype) {
return (await this.sql(`SHOW COLUMNS FROM ${doctype}`)).map(d => d.Field);
}
async runAddColumnQuery(doctype, fields) {
await this.run(
`ALTER TABLE ${doctype} ADD COLUMN ${this.get_column_definition(doctype)}`
);
}
getOne(doctype, name, fields = '*') {
fields = this.prepareFields(fields);
async runAddColumnQuery(doctype, fields) {
await this.run(`ALTER TABLE ${doctype} ADD COLUMN ${this.get_column_definition(doctype)}`);
}
getOne(doctype, name, fields = '*') {
fields = this.prepareFields(fields);
return new Promise((resolve, reject) => {
this.conn.get(`select ${fields} from ${doctype}
where name = ?`, name,
(err, row) => {
resolve(row || {});
});
});
}
async insertOne(doctype, doc) {
let fields = this.get_keys(doctype);
let placeholders = fields.map(d => '?').join(', ');
if (!doc.name) {
doc.name = frappe.getRandomString();
return new Promise((resolve, reject) => {
this.conn.get(
`select ${fields} from ${doctype}
where name = ?`,
name,
(err, row) => {
resolve(row || {});
}
);
});
}
return await this.run(`insert into ${doctype}
(${fields.map(field => field.fieldname).join(", ")})
values (${placeholders})`, this.getFormattedValues(fields, doc));
async insertOne(doctype, doc) {
let fields = this.get_keys(doctype);
let placeholders = fields.map((d) => '?').join(', ');
if (!doc.name) {
doc.name = frappe.getRandomString();
}
async updateOne(doctype, doc) {
let fields = this.getKeys(doctype);
let assigns = fields.map(field => `${field.fieldname} = ?`);
let values = this.getFormattedValues(fields, doc);
return await this.run(
`insert into ${doctype}
(${fields.map((field) => field.fieldname).join(', ')})
values (${placeholders})`,
this.getFormattedValues(fields, doc)
);
}
// additional name for where clause
values.push(doc.name);
async updateOne(doctype, doc) {
let fields = this.getKeys(doctype);
let assigns = fields.map((field) => `${field.fieldname} = ?`);
let values = this.getFormattedValues(fields, doc);
return await this.run(`update ${doctype}
set ${assigns.join(", ")} where name=?`, values);
}
// additional name for where clause
values.push(doc.name);
async runDeleteOtherChildren(field, added) {
await this.run(`delete from ${field.childtype}
return await this.run(
`update ${doctype}
set ${assigns.join(', ')} where name=?`,
values
);
}
async runDeleteOtherChildren(field, added) {
await this.run(
`delete from ${field.childtype}
where
parent = ? and
name not in (${added.slice(1).map(d => '?').join(', ')})`, added);
name not in (${added
.slice(1)
.map((d) => '?')
.join(', ')})`,
added
);
}
async deleteOne(doctype, name) {
return await this.run(`delete from ${doctype} where name=?`, name);
}
async deleteChildren(parenttype, parent) {
await this.run(`delete from ${parent} where parent=?`, parent);
}
getAll({
doctype,
fields,
filters,
start,
limit,
order_by = 'modified',
order = 'desc',
} = {}) {
if (!fields) {
fields = frappe.getMeta(doctype).getKeywordFields();
}
return new Promise((resolve, reject) => {
let conditions = this.getFilterConditions(filters);
async deleteOne(doctype, name) {
return await this.run(`delete from ${doctype} where name=?`, name);
}
async deleteChildren(parenttype, parent) {
await this.run(`delete from ${parent} where parent=?`, parent);
}
getAll({ doctype, fields, filters, start, limit, order_by = 'modified', order = 'desc' } = {}) {
if (!fields) {
fields = frappe.getMeta(doctype).getKeywordFields();
}
return new Promise((resolve, reject) => {
let conditions = this.getFilterConditions(filters);
this.conn.all(`select ${fields.join(", ")}
this.conn.all(
`select ${fields.join(', ')}
from ${doctype}
${conditions.conditions ? "where" : ""} ${conditions.conditions}
${order_by ? ("order by " + order_by) : ""} ${order_by ? (order || "asc") : ""}
${limit ? ("limit " + limit) : ""} ${start ? ("offset " + start) : ""}`, conditions.values,
(err, rows) => {
if (err) {
reject(err);
} else {
resolve(rows);
}
});
});
}
run(query, params) {
// TODO promisify
return new Promise((resolve, reject) => {
this.conn.query(query, params, (err) => {
if (err) {
if (debug) {
console.error(err);
}
reject(err);
} else {
resolve();
}
});
});
}
sql(query, params) {
return new Promise((resolve) => {
this.conn.query(query, params, (err, rows) => {
resolve(rows);
});
});
}
async commit() {
try {
await this.run('commit');
} catch (e) {
if (e.errno !== 1) {
throw e;
}
${conditions.conditions ? 'where' : ''} ${conditions.conditions}
${order_by ? 'order by ' + order_by : ''} ${
order_by ? order || 'asc' : ''
}
}
init_typeMap() {
this.typeMap = {
'AutoComplete': 'VARCHAR(140)'
, 'Currency': 'real'
, 'Int': 'INT'
, 'Float': 'decimal(18,6)'
, 'Percent': 'real'
, 'Check': 'INT(1)'
, 'Small Text': 'text'
, 'Long Text': 'text'
, 'Code': 'text'
, 'Text Editor': 'text'
, 'Date': 'DATE'
, 'Datetime': 'DATETIME'
, 'Time': 'TIME'
, 'Text': 'text'
, 'Data': 'VARCHAR(140)'
, 'Link': ' varchar(140)'
, 'DynamicLink': 'text'
, 'Password': 'varchar(140)'
, 'Select': 'VARCHAR(140)'
, 'Read Only': 'varchar(140)'
, 'File': 'text'
, 'Attach': 'text'
, 'Attach Image': 'text'
, 'Signature': 'text'
, 'Color': 'text'
, 'Barcode': 'text'
, 'Geolocation': 'text'
${limit ? 'limit ' + limit : ''} ${
start ? 'offset ' + start : ''
}`,
conditions.values,
(err, rows) => {
if (err) {
reject(err);
} else {
resolve(rows);
}
}
);
});
}
run(query, params) {
// TODO promisify
return new Promise((resolve, reject) => {
this.conn.query(query, params, (err) => {
if (err) {
if (debug) {
console.error(err);
}
reject(err);
} else {
resolve();
}
});
});
}
sql(query, params) {
return new Promise((resolve) => {
this.conn.query(query, params, (err, rows) => {
resolve(rows);
});
});
}
async commit() {
try {
await this.run('commit');
} catch (e) {
if (e.errno !== 1) {
throw e;
}
}
}
}
init_typeMap() {
this.typeMap = {
AutoComplete: 'VARCHAR(140)',
Currency: 'real',
Int: 'INT',
Float: 'decimal(18,6)',
Percent: 'real',
Check: 'INT(1)',
'Small Text': 'text',
'Long Text': 'text',
Code: 'text',
'Text Editor': 'text',
Date: 'DATE',
Datetime: 'DATETIME',
Time: 'TIME',
Text: 'text',
Data: 'VARCHAR(140)',
Link: ' varchar(140)',
DynamicLink: 'text',
Password: 'varchar(140)',
Select: 'VARCHAR(140)',
'Read Only': 'varchar(140)',
File: 'text',
Attach: 'text',
'Attach Image': 'text',
Signature: 'text',
Color: 'text',
Barcode: 'text',
Geolocation: 'text',
};
}
};

View File

@ -1,4 +1,4 @@
const frappe = require('frappejs');
const frappe = require('frappe');
const Database = require('./database');
class SqliteDatabase extends Database {

View File

@ -1,4 +1,4 @@
const frappe = require('frappejs');
const frappe = require('frappe');
class BaseError extends Error {
constructor(statusCode, message) {
@ -75,7 +75,7 @@ function throwError(message, error = 'ValidationError') {
NotFoundError: NotFoundError,
ForbiddenError: ForbiddenError,
ValueError: ValueError,
Conflict: Conflict
Conflict: Conflict,
};
const err = new errorClass[error](message);
frappe.events.trigger('throw', { message, stackTrace: err.stack });
@ -97,5 +97,5 @@ module.exports = {
CannotCommitError,
MandatoryError,
InvalidFieldError,
throw: throwError
throw: throwError,
};

View File

@ -1,8 +1,8 @@
const utils = require('../utils');
const format = require('../utils/format');
const errors = require('./errors');
const BaseDocument = require('frappejs/model/document');
const BaseMeta = require('frappejs/model/meta');
const BaseDocument = require('frappe/model/document');
const BaseMeta = require('frappe/model/meta');
module.exports = {
initLibs(frappe) {

View File

@ -9,9 +9,9 @@ const {
module.exports = {
initializeAndRegister(customModels = {}, force = false) {
this.init(force);
const common = require('frappejs/common');
const common = require('frappe/common');
this.registerLibs(common);
const coreModels = require('frappejs/models');
const coreModels = require('frappe/models');
this.registerModels(coreModels);
this.registerModels(customModels);
},

View File

@ -1,5 +1,5 @@
const frappe = require('frappejs');
const Observable = require('frappejs/utils/observable');
const frappe = require('frappe');
const Observable = require('frappe/utils/observable');
const naming = require('./naming');
const { isPesa } = require('../utils/index');
const { DEFAULT_INTERNAL_PRECISION } = require('../utils/consts');

View File

@ -1,7 +1,7 @@
const BaseDocument = require('./document');
const frappe = require('frappejs');
const frappe = require('frappe');
const model = require('./index');
const indicatorColor = require('frappejs/ui/constants/indicators');
const indicatorColor = require('frappe/ui/constants/indicators');
module.exports = class BaseMeta extends BaseDocument {
constructor(data) {

View File

@ -1,88 +1,92 @@
const frappe = require('frappejs');
const { getRandomString } = require('frappejs/utils');
const frappe = require('frappe');
const { getRandomString } = require('frappe/utils');
module.exports = {
async setName(doc) {
if (frappe.isServer) {
// if is server, always name again if autoincrement or other
if (doc.meta.naming === 'autoincrement') {
doc.name = await this.getNextId(doc.doctype);
return;
}
async setName(doc) {
if (frappe.isServer) {
// if is server, always name again if autoincrement or other
if (doc.meta.naming === 'autoincrement') {
doc.name = await this.getNextId(doc.doctype);
return;
}
if (doc.meta.settings) {
const numberSeries = (await doc.getSettings()).numberSeries;
if(numberSeries) {
doc.name = await this.getSeriesNext(numberSeries);
}
}
}
if (doc.name) {
return;
}
// name === doctype for Single
if (doc.meta.isSingle) {
doc.name = doc.meta.name;
return;
}
// assign a random name by default
// override doc to set a name
if (!doc.name) {
doc.name = getRandomString();
}
},
async getNextId(doctype) {
// get the last inserted row
let lastInserted = await this.getLastInserted(doctype);
let name = 1;
if (lastInserted) {
let lastNumber = parseInt(lastInserted.name);
if (isNaN(lastNumber)) lastNumber = 0;
name = lastNumber + 1;
}
return (name + '').padStart(9, '0');
},
async getLastInserted(doctype) {
const lastInserted = await frappe.db.getAll({
doctype: doctype,
fields: ['name'],
limit: 1,
order_by: 'creation',
order: 'desc'
});
return (lastInserted && lastInserted.length) ? lastInserted[0] : null;
},
async getSeriesNext(prefix) {
let series;
try {
series = await frappe.getDoc('NumberSeries', prefix);
} catch (e) {
if (!e.statusCode || e.statusCode !== 404) {
throw e;
}
await this.createNumberSeries(prefix);
series = await frappe.getDoc('NumberSeries', prefix);
}
let next = await series.next()
return prefix + next;
},
async createNumberSeries(prefix, setting, start=1000) {
if (!(await frappe.db.exists('NumberSeries', prefix))) {
const series = frappe.newDoc({doctype: 'NumberSeries', name: prefix, current: start});
await series.insert();
if (setting) {
const settingDoc = await frappe.getSingle(setting);
settingDoc.numberSeries = series.name;
await settingDoc.update();
}
if (doc.meta.settings) {
const numberSeries = (await doc.getSettings()).numberSeries;
if (numberSeries) {
doc.name = await this.getSeriesNext(numberSeries);
}
}
}
}
if (doc.name) {
return;
}
// name === doctype for Single
if (doc.meta.isSingle) {
doc.name = doc.meta.name;
return;
}
// assign a random name by default
// override doc to set a name
if (!doc.name) {
doc.name = getRandomString();
}
},
async getNextId(doctype) {
// get the last inserted row
let lastInserted = await this.getLastInserted(doctype);
let name = 1;
if (lastInserted) {
let lastNumber = parseInt(lastInserted.name);
if (isNaN(lastNumber)) lastNumber = 0;
name = lastNumber + 1;
}
return (name + '').padStart(9, '0');
},
async getLastInserted(doctype) {
const lastInserted = await frappe.db.getAll({
doctype: doctype,
fields: ['name'],
limit: 1,
order_by: 'creation',
order: 'desc',
});
return lastInserted && lastInserted.length ? lastInserted[0] : null;
},
async getSeriesNext(prefix) {
let series;
try {
series = await frappe.getDoc('NumberSeries', prefix);
} catch (e) {
if (!e.statusCode || e.statusCode !== 404) {
throw e;
}
await this.createNumberSeries(prefix);
series = await frappe.getDoc('NumberSeries', prefix);
}
let next = await series.next();
return prefix + next;
},
async createNumberSeries(prefix, setting, start = 1000) {
if (!(await frappe.db.exists('NumberSeries', prefix))) {
const series = frappe.newDoc({
doctype: 'NumberSeries',
name: prefix,
current: start,
});
await series.insert();
if (setting) {
const settingDoc = await frappe.getSingle(setting);
settingDoc.numberSeries = series.name;
await settingDoc.update();
}
}
},
};

View File

@ -1,4 +1,4 @@
const frappe = require('frappejs');
const frappe = require('frappe');
module.exports = async function runPatches(patchList) {
const patchesAlreadyRun = (

View File

@ -1,15 +1,15 @@
const BaseDocument = require('frappejs/model/document');
const BaseDocument = require('frappe/model/document');
module.exports = class NumberSeries extends BaseDocument {
validate() {
if (this.current===null || this.current===undefined) {
this.current = 0;
}
validate() {
if (this.current === null || this.current === undefined) {
this.current = 0;
}
async next() {
this.validate();
this.current++;
await this.update();
return this.current;
}
}
}
async next() {
this.validate();
this.current++;
await this.update();
return this.current;
}
};

View File

@ -1,5 +1,5 @@
const { DateTime } = require('luxon');
const { _ } = require('frappejs/utils');
const { _ } = require('frappe/utils');
const {
DEFAULT_DISPLAY_PRECISION,
DEFAULT_INTERNAL_PRECISION,

View File

@ -1,4 +1,4 @@
const { BLUE, GREEN } = require('frappejs/ui/constants/indicators');
const { BLUE, GREEN } = require('frappe/ui/constants/indicators');
module.exports = {
name: 'ToDo',
@ -11,8 +11,8 @@ module.exports = {
key: 'status',
colors: {
Open: BLUE,
Closed: GREEN
}
Closed: GREEN,
},
},
fields: [
{
@ -20,7 +20,7 @@ module.exports = {
label: 'Subject',
placeholder: 'Subject',
fieldtype: 'Data',
required: 1
required: 1,
},
{
fieldname: 'status',
@ -28,13 +28,13 @@ module.exports = {
fieldtype: 'Select',
options: ['Open', 'Closed'],
default: 'Open',
required: 1
required: 1,
},
{
fieldname: 'description',
label: 'Description',
fieldtype: 'Text'
}
fieldtype: 'Text',
},
],
quickEditFields: ['status', 'description'],
@ -42,19 +42,19 @@ module.exports = {
actions: [
{
label: 'Close',
condition: doc => doc.status !== 'Closed',
action: async doc => {
condition: (doc) => doc.status !== 'Closed',
action: async (doc) => {
await doc.set('status', 'Closed');
await doc.update();
}
},
},
{
label: 'Re-Open',
condition: doc => doc.status !== 'Open',
action: async doc => {
condition: (doc) => doc.status !== 'Open',
action: async (doc) => {
await doc.set('status', 'Open');
await doc.update();
}
}
]
},
},
],
};

View File

@ -1,7 +1,7 @@
const BaseList = require('frappejs/client/view/list');
const BaseList = require('frappe/client/view/list');
module.exports = class ToDoList extends BaseList {
getFields(list) {
return ['name', 'subject', 'status'];
}
}
getFields(list) {
return ['name', 'subject', 'status'];
}
};

View File

@ -1,5 +1,5 @@
const luxon = require('luxon');
const frappe = require('frappejs');
const frappe = require('frappe');
const { DEFAULT_DISPLAY_PRECISION, DEFAULT_LOCALE } = require('./consts');
module.exports = {

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import Account from './AccountDocument';
export default {

View File

@ -1,5 +1,5 @@
import frappe from 'frappejs';
import BaseDocument from 'frappejs/model/document';
import frappe from 'frappe';
import BaseDocument from 'frappe/model/document';
export default class Account extends BaseDocument {
async validate() {
@ -11,4 +11,4 @@ export default class Account extends BaseDocument {
);
}
}
};
}

View File

@ -1,7 +1,7 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappe/utils';
export default {
doctype: 'Account',
title: _('Account'),
columns: ['name', 'parentAccount', 'rootType']
columns: ['name', 'parentAccount', 'rootType'],
};

View File

@ -1,13 +1,7 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappe/utils';
export default {
doctype: 'AccountingLedgerEntry',
title: _('Accounting Ledger Entries'),
columns: [
'account',
'party',
'debit',
'credit',
'balance'
]
}
columns: ['account', 'party', 'debit', 'credit', 'balance'],
};

View File

@ -1,72 +1,73 @@
import frappe from 'frappejs';
import frappe from 'frappe';
export default {
"name": "Email",
"doctype": "DocType",
"pageSettings": {
hideTitle: true
name: 'Email',
doctype: 'DocType',
pageSettings: {
hideTitle: true,
},
isSingle: 0,
isChild: 0,
keywordFields: ['name'],
fields: [
{
fieldname: 'name',
label: 'name',
fieldtype: 'Data',
required: 0,
hidden: 1,
disabled: 0,
},
"isSingle": 0,
"isChild": 0,
"keywordFields": ["name"],
"fields": [{
"fieldname": "name",
"label": "name",
"fieldtype": "Data",
"required": 0,
"hidden": 1,
"disabled": 0
},
{
"fieldname": "fromEmailAddress",
"label": "From",
"fieldtype": "Data",
"required": 1,
"hidden": 0,
formula: async () => {
const accountingSettings = await frappe.getDoc('AccountingSettings');
return accountingSettings.email;
},
"disabled": 1
},
{
"fieldname": "toEmailAddress",
"label": "To",
"fieldtype": "Data",
"required": 1,
"hidden": 0,
"disabled": 0
},
{
"fieldname": "date",
"label": "Date",
"fieldtype": "Datetime",
"required": 0,
"hidden": 0,
"disabled": 1
},
{
"fieldname": "subject",
"label": "Subject",
"fieldtype": "Data",
"required": 0,
"hidden": 0,
"disabled": 0
},
{
"fieldname": "bodyText",
"label": "Body",
"fieldtype": "Text",
"required": 0,
"hidden": 0,
"disabled": 0
},
{
"fieldname": "filePath",
"label": "File Path",
"fieldtype": "Text",
"required": 0,
"hidden": 1,
}
]
};
{
fieldname: 'fromEmailAddress',
label: 'From',
fieldtype: 'Data',
required: 1,
hidden: 0,
formula: async () => {
const accountingSettings = await frappe.getDoc('AccountingSettings');
return accountingSettings.email;
},
disabled: 1,
},
{
fieldname: 'toEmailAddress',
label: 'To',
fieldtype: 'Data',
required: 1,
hidden: 0,
disabled: 0,
},
{
fieldname: 'date',
label: 'Date',
fieldtype: 'Datetime',
required: 0,
hidden: 0,
disabled: 1,
},
{
fieldname: 'subject',
label: 'Subject',
fieldtype: 'Data',
required: 0,
hidden: 0,
disabled: 0,
},
{
fieldname: 'bodyText',
label: 'Body',
fieldtype: 'Text',
required: 0,
hidden: 0,
disabled: 0,
},
{
fieldname: 'filePath',
label: 'File Path',
fieldtype: 'Text',
required: 0,
hidden: 1,
},
],
};

View File

@ -1,59 +1,54 @@
import frappe from 'frappejs';
import frappe from 'frappe';
export default {
"name": "EmailAccount",
"label": "Email Account",
"doctype": "DocType",
"isSingle": true,
"isChild": false,
"keywordFields": [
"email"
],
"fields": [
{
"fieldname": "email",
"label": "Email",
"fieldtype": "Data",
"required": 1,
formula: async () => {
const accountingSettings = await frappe.getDoc('AccountingSettings');
return accountingSettings.email;
},
},
{
"fieldname": "password",
"label": "Password",
"fieldtype": "Password",
"required": 1
},
{
"fieldname": "confirmPassword",
"label": "Confirm Password",
"fieldtype": "Password",
"required": 1
},
{
"fieldname": "smtpHost",
"label": "SMTP Host",
"fieldtype": "Select",
"options": [
"smtp.gmail.com",
"smtp.mail.yahoo.com",
"smtp-mail.outlook.com",
"smtp.mail.me.com",
"smtp.aol.com"
],
"default": "smtp.gmail.com"
},
{
"fieldname": "smtpPort",
"label": "SMTP Port",
"fieldtype": "Select",
"options": [
"465",
"587"
],
"default": "465"
}
]
};
name: 'EmailAccount',
label: 'Email Account',
doctype: 'DocType',
isSingle: true,
isChild: false,
keywordFields: ['email'],
fields: [
{
fieldname: 'email',
label: 'Email',
fieldtype: 'Data',
required: 1,
formula: async () => {
const accountingSettings = await frappe.getDoc('AccountingSettings');
return accountingSettings.email;
},
},
{
fieldname: 'password',
label: 'Password',
fieldtype: 'Password',
required: 1,
},
{
fieldname: 'confirmPassword',
label: 'Confirm Password',
fieldtype: 'Password',
required: 1,
},
{
fieldname: 'smtpHost',
label: 'SMTP Host',
fieldtype: 'Select',
options: [
'smtp.gmail.com',
'smtp.mail.yahoo.com',
'smtp-mail.outlook.com',
'smtp.mail.me.com',
'smtp.aol.com',
],
default: 'smtp.gmail.com',
},
{
fieldname: 'smtpPort',
label: 'SMTP Port',
fieldtype: 'Select',
options: ['465', '587'],
default: '465',
},
],
};

View File

@ -1,8 +1,7 @@
import frappe from 'frappejs';
import BaseDocument from 'frappejs/model/document';
import BaseDocument from 'frappe/model/document';
export default class Event extends BaseDocument {
alertEvent() {
alert(this.title);
}
};
alertEvent() {
alert(this.title);
}
}

View File

@ -1,14 +1,14 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import Quotation from '../Quotation/Quotation';
export default model.extend(Quotation, {
name: "Fulfillment",
label: "Fulfillment",
settings: "FulfillmentSettings",
fields: [
{
"fieldname": "items",
"childtype": "FulfillmentItem"
}
]
name: 'Fulfillment',
label: 'Fulfillment',
settings: 'FulfillmentSettings',
fields: [
{
fieldname: 'items',
childtype: 'FulfillmentItem',
},
],
});

View File

@ -1,6 +1,6 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import QuotationItem from '../QuotationItem/QuotationItem';
export default model.extend(QuotationItem, {
name: "FulfillmentItem"
name: 'FulfillmentItem',
});

View File

@ -1,13 +1,13 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import QuotationSettings from '../QuotationSettings/QuotationSettings';
export default model.extend(QuotationSettings, {
"name": "FulfillmentSettings",
"label": "Fulfillment Settings",
"fields": [
{
"fieldname": "numberSeries",
"default": "OF"
}
]
name: 'FulfillmentSettings',
label: 'Fulfillment Settings',
fields: [
{
fieldname: 'numberSeries',
default: 'OF',
},
],
});

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import GSTR3B from './GSTR3BDocument.js';
export default {

View File

@ -1,5 +1,5 @@
import BaseDocument from 'frappejs/model/document';
import frappe from 'frappejs';
import frappe from 'frappe';
import BaseDocument from 'frappe/model/document';
import format from './GSTR3BFormat';
export default class GSTR3B extends BaseDocument {
@ -16,7 +16,7 @@ export default class GSTR3B extends BaseDocument {
'September',
'October',
'November',
'December'
'December',
].indexOf(this.month);
const month = monthIndex + 1 > 9 ? monthIndex + 1 : `0${monthIndex + 1}`;
const lastDate = new Date(this.year, monthIndex + 1, 0).getDate();
@ -25,22 +25,22 @@ export default class GSTR3B extends BaseDocument {
'>=',
`${this.year}-${month}-01`,
'<=',
`${this.year}-${month}-${lastDate}`
]
`${this.year}-${month}-${lastDate}`,
],
};
const salesInvoices = frappe.db.getAll({
doctype: 'SalesInvoice',
filters,
fields: ['*']
fields: ['*'],
});
const purchaseInvoices = frappe.db.getAll({
doctype: 'PurchaseInvoice',
filters,
fields: ['*']
fields: ['*'],
});
const [gstr1Data, gstr2Data] = await Promise.all([
salesInvoices,
purchaseInvoices
purchaseInvoices,
]);
let gstr3bData = [[], []];
@ -74,7 +74,7 @@ export default class GSTR3B extends BaseDocument {
row.rate = 0;
row.inState = true;
row.reverseCharge = !party.gstin ? 'Y' : 'N';
ledgerEntry.taxes.forEach(tax => {
ledgerEntry.taxes.forEach((tax) => {
row.rate += tax.rate;
const taxAmt = (tax.rate * ledgerEntry.netTotal) / 100;
if (tax.account === 'IGST') row.igstAmt = taxAmt;
@ -113,7 +113,7 @@ export default class GSTR3B extends BaseDocument {
jsonData['inter_sup']['unreg_details'].push({
pos: ledgerEntry.place,
txval: ledgerEntry.taxVal,
iAmt: ledgerEntry.igstAmt || 0
iAmt: ledgerEntry.igstAmt || 0,
});
}
}
@ -147,4 +147,4 @@ export default class GSTR3B extends BaseDocument {
return JSON.stringify(json, undefined, 2);
}
}
};
}

View File

@ -1,7 +1,7 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappe/utils';
export default {
doctype: 'GSTR3B',
title: _('GSTR 3B Report'),
columns: ['year', 'month']
columns: ['year', 'month'],
};

View File

@ -1,5 +1,5 @@
import frappe from 'frappejs';
import { _ } from 'frappejs/utils';
import frappe from 'frappe';
import { _ } from 'frappe/utils';
export default {
name: 'Item',

View File

@ -1,12 +1,7 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappe/utils';
export default {
doctype: 'Item',
title: _('Items'),
columns: [
'name',
'unit',
'tax',
'rate',
]
}
columns: ['name', 'unit', 'tax', 'rate'],
};

View File

@ -1,10 +1,10 @@
import { _ } from 'frappejs/utils';
import Badge from '@/components/Badge';
import { _ } from 'frappe/utils';
export default {
doctype: 'JournalEntry',
title: _('Journal Entry'),
formRoute: name => `/edit/JournalEntry/${name}`,
formRoute: (name) => `/edit/JournalEntry/${name}`,
columns: [
'date',
{
@ -35,10 +35,10 @@ export default {
fieldname: 'name',
fieldtype: 'Data',
getValue(doc) {
return doc.name
}
return doc.name;
},
},
'entryType',
'referenceNumber'
]
'referenceNumber',
],
};

View File

@ -1,4 +1,4 @@
import BaseDocument from 'frappejs/model/document';
import BaseDocument from 'frappe/model/document';
import LedgerPosting from '../../../accounting/ledgerPosting';
export default class JournalEntryServer extends BaseDocument {

View File

@ -1,6 +1,6 @@
import frappe from 'frappejs';
import { _ } from 'frappejs/utils';
import router from '@/router';
import frappe from 'frappe';
import { _ } from 'frappe/utils';
import PartyWidget from './PartyWidget.vue';
export default {
@ -8,46 +8,46 @@ export default {
label: 'Customer',
basedOn: 'Party',
filters: {
customer: 1
customer: 1,
},
actions: [
{
label: _('Create Invoice'),
condition: doc => !doc.isNew(),
action: async customer => {
condition: (doc) => !doc.isNew(),
action: async (customer) => {
let doc = await frappe.getNewDoc('SalesInvoice');
router.push({
path: `/edit/SalesInvoice/${doc.name}`,
query: {
doctype: 'SalesInvoice',
values: {
customer: customer.name
}
}
customer: customer.name,
},
},
});
}
},
},
{
label: _('View Invoices'),
condition: doc => !doc.isNew(),
action: customer => {
condition: (doc) => !doc.isNew(),
action: (customer) => {
router.push({
name: 'ListView',
params: {
doctype: 'SalesInvoice',
filters: {
customer: customer.name
}
}
customer: customer.name,
},
},
});
}
}
},
},
],
quickEditWidget: doc => ({
quickEditWidget: (doc) => ({
render(h) {
return h(PartyWidget, {
props: { doc }
props: { doc },
});
}
})
},
}),
};

View File

@ -1,7 +1,7 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappe/utils';
export default {
doctype: 'Customer',
title: _('Customers'),
columns: ['name', 'phone', 'outstandingAmount']
columns: ['name', 'phone', 'outstandingAmount'],
};

View File

@ -1,5 +1,5 @@
import frappe from 'frappejs';
import { _ } from 'frappejs/utils';
import frappe from 'frappe';
import { _ } from 'frappe/utils';
export default {
name: 'Party',

View File

@ -1,6 +1,4 @@
import { _ } from 'frappejs/utils';
export default {
doctype: 'Party',
columns: ['name', 'phone', 'outstandingAmount']
columns: ['name', 'phone', 'outstandingAmount'],
};

View File

@ -1,5 +1,5 @@
import frappe from 'frappejs';
import BaseDocument from 'frappejs/model/document';
import frappe from 'frappe';
import BaseDocument from 'frappe/model/document';
export default class PartyServer extends BaseDocument {
beforeInsert() {

View File

@ -50,7 +50,7 @@
</template>
<script>
import frappe from 'frappejs';
import frappe from 'frappe';
import { getStatusColumn } from '../Transaction/Transaction';
import { routeTo } from '@/utils';

View File

@ -1,6 +1,6 @@
import { _ } from 'frappejs/utils';
import router from '@/router';
import frappe from 'frappejs';
import frappe from 'frappe';
import { _ } from 'frappe/utils';
import PartyWidget from './PartyWidget.vue';
export default {
@ -8,46 +8,46 @@ export default {
label: 'Supplier',
basedOn: 'Party',
filters: {
supplier: 1
supplier: 1,
},
actions: [
{
label: _('Create Bill'),
condition: doc => !doc.isNew(),
action: async supplier => {
condition: (doc) => !doc.isNew(),
action: async (supplier) => {
let doc = await frappe.getNewDoc('PurchaseInvoice');
router.push({
path: `/edit/PurchaseInvoice/${doc.name}`,
query: {
doctype: 'PurchaseInvoice',
values: {
supplier: supplier.name
}
}
supplier: supplier.name,
},
},
});
}
},
},
{
label: _('View Bills'),
condition: doc => !doc.isNew(),
action: supplier => {
condition: (doc) => !doc.isNew(),
action: (supplier) => {
router.push({
name: 'ListView',
params: {
doctype: 'PurchaseInvoice',
filters: {
supplier: supplier.name
}
}
supplier: supplier.name,
},
},
});
}
}
},
},
],
quickEditWidget: doc => ({
quickEditWidget: (doc) => ({
render(h) {
return h(PartyWidget, {
props: { doc }
props: { doc },
});
}
})
},
}),
};

View File

@ -1,7 +1,7 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappe/utils';
export default {
doctype: 'Supplier',
title: _('Supplier'),
columns: ['name', 'phone', 'outstandingAmount']
columns: ['name', 'phone', 'outstandingAmount'],
};

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import utils from '../../../accounting/utils';
export default {

View File

@ -1,5 +1,5 @@
import { _ } from 'frappejs/utils';
import Badge from '@/components/Badge';
import { _ } from 'frappe/utils';
export default {
doctype: 'Payment',
@ -28,12 +28,12 @@ export default {
return {
template: `<Badge class="text-xs" color="${color}">${status}</Badge>`,
components: { Badge }
components: { Badge },
};
}
},
},
'paymentType',
'date',
'amount'
]
'amount',
],
};

View File

@ -1,5 +1,5 @@
import frappe from 'frappejs';
import BaseDocument from 'frappejs/model/document';
import frappe from 'frappe';
import BaseDocument from 'frappe/model/document';
import LedgerPosting from '../../../accounting/ledgerPosting';
export default class PaymentServer extends BaseDocument {

View File

@ -1,5 +1,5 @@
import frappe from 'frappejs';
import { _ } from 'frappejs/utils';
import frappe from 'frappe';
import { _ } from 'frappe/utils';
const referenceTypeMap = {
SalesInvoice: _('Invoice'),

View File

@ -1,16 +1,16 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappetils';
import { getStatusColumn } from '../Transaction/Transaction';
export default {
doctype: 'PurchaseInvoice',
title: _('Bills'),
formRoute: name => `/edit/PurchaseInvoice/${name}`,
formRoute: (name) => `/edit/PurchaseInvoice/${name}`,
columns: [
'supplier',
'name',
getStatusColumn('PurchaseInvoice'),
'date',
'grandTotal',
'outstandingAmount'
]
'outstandingAmount',
],
};

View File

@ -1,4 +1,4 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import PurchaseInvoice from '../PurchaseInvoice/PurchaseInvoice';
export default model.extend(
@ -10,11 +10,11 @@ export default model.extend(
fields: [
{
fieldname: 'items',
childtype: 'PurchaseOrderItem'
}
]
childtype: 'PurchaseOrderItem',
},
],
},
{
skipFields: ['account']
skipFields: ['account'],
}
);

View File

@ -1,6 +1,6 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import PurchaseInvoiceItem from '../PurchaseInvoiceItem/PurchaseInvoiceItem';
export default model.extend(PurchaseInvoiceItem, {
name: "PurchaseOrderItem"
name: 'PurchaseOrderItem',
});

View File

@ -1,13 +1,13 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import PurchaseInvoiceSettings from '../PurchaseInvoiceSettings/PurchaseInvoiceSettings';
export default model.extend(PurchaseInvoiceSettings, {
"name": "PurchaseOrderSettings",
"label": "Purchase Order Settings",
"fields": [
{
"fieldname": "numberSeries",
"default": "PO"
}
]
name: 'PurchaseOrderSettings',
label: 'Purchase Order Settings',
fields: [
{
fieldname: 'numberSeries',
default: 'PO',
},
],
});

View File

@ -1,14 +1,14 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import PurchaseOrder from '../PurchaseOrder/PurchaseOrder';
export default model.extend(PurchaseOrder, {
name: "PurchaseReceipt",
label: "Purchase Receipt",
settings: "PurchaseReceiptSettings",
fields: [
{
"fieldname": "items",
"childtype": "PurchaseReceiptItem"
}
]
name: 'PurchaseReceipt',
label: 'Purchase Receipt',
settings: 'PurchaseReceiptSettings',
fields: [
{
fieldname: 'items',
childtype: 'PurchaseReceiptItem',
},
],
});

View File

@ -1,16 +1,20 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import PurchaseOrderItem from '../PurchaseOrderItem/PurchaseOrderItem';
export default model.extend(PurchaseOrderItem, {
name: "PurchaseReceiptItem",
export default model.extend(
PurchaseOrderItem,
{
name: 'PurchaseReceiptItem',
fields: [
{
"fieldname": "acceptedQuantity",
"label": "Accepted Quantity",
"fieldtype": "Float",
"required": 1
}
]
}, {
skipFields: ['expenseAccount']
});
{
fieldname: 'acceptedQuantity',
label: 'Accepted Quantity',
fieldtype: 'Float',
required: 1,
},
],
},
{
skipFields: ['expenseAccount'],
}
);

View File

@ -1,13 +1,13 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import PurchaseOrderSettings from '../PurchaseOrderSettings/PurchaseOrderSettings';
export default model.extend(PurchaseOrderSettings, {
"name": "PurchaseReceiptSettings",
"label": "Purchase Receipt Settings",
"fields": [
{
"fieldname": "numberSeries",
"default": "PREC"
}
]
name: 'PurchaseReceiptSettings',
label: 'Purchase Receipt Settings',
fields: [
{
fieldname: 'numberSeries',
default: 'PREC',
},
],
});

View File

@ -1,4 +1,4 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import SalesInvoice from '../SalesInvoice/SalesInvoice';
const Quotation = model.extend(
@ -10,14 +10,14 @@ const Quotation = model.extend(
fields: [
{
fieldname: 'items',
childtype: 'QuotationItem'
}
childtype: 'QuotationItem',
},
],
links: []
links: [],
},
{
skipFields: ['account'],
overrideProps: ['links']
overrideProps: ['links'],
}
);

View File

@ -1,6 +1,6 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import SalesInvoiceItem from '../SalesInvoiceItem/SalesInvoiceItem';
export default model.extend(SalesInvoiceItem, {
name: "QuotationItem"
name: 'QuotationItem',
});

View File

@ -1,13 +1,13 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import SalesInvoiceSettings from '../SalesInvoiceSettings/SalesInvoiceSettings';
export default model.extend(SalesInvoiceSettings, {
"name": "QuotationSettings",
"label": "Quotation Settings",
"fields": [
{
"fieldname": "numberSeries",
"default": "QTN"
}
]
name: 'QuotationSettings',
label: 'Quotation Settings',
fields: [
{
fieldname: 'numberSeries',
default: 'QTN',
},
],
});

View File

@ -1,16 +1,16 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappe/utils';
import { getStatusColumn } from '../Transaction/Transaction';
export default {
doctype: 'SalesInvoice',
title: _('Invoices'),
formRoute: name => `/edit/SalesInvoice/${name}`,
formRoute: (name) => `/edit/SalesInvoice/${name}`,
columns: [
'customer',
'name',
getStatusColumn('SalesInvoice'),
'date',
'grandTotal',
'outstandingAmount'
]
'outstandingAmount',
],
};

View File

@ -1,5 +1,5 @@
<script>
import frappe from 'frappejs';
import frappe from 'frappe';
export default {
name: 'Base',
props: ['doc', 'printSettings'],

View File

@ -1,4 +1,4 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import Quotation from '../Quotation/Quotation';
export default model.extend(Quotation, {
@ -8,7 +8,7 @@ export default model.extend(Quotation, {
fields: [
{
fieldname: 'items',
childtype: 'SalesOrderItem'
}
]
childtype: 'SalesOrderItem',
},
],
});

View File

@ -1,6 +1,6 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import QuotationItem from '../QuotationItem/QuotationItem';
export default model.extend(QuotationItem, {
name: "SalesOrderItem"
name: 'SalesOrderItem',
});

View File

@ -1,13 +1,13 @@
import model from 'frappejs/model';
import model from 'frappe/model';
import QuotationSettings from '../QuotationSettings/QuotationSettings';
export default model.extend(QuotationSettings, {
"name": "SalesOrderSettings",
"label": "Sales Order Settings",
"fields": [
{
"fieldname": "numberSeries",
"default": "SO"
}
]
name: 'SalesOrderSettings',
label: 'Sales Order Settings',
fields: [
{
fieldname: 'numberSeries',
default: 'SO',
},
],
});

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
export default async function generateTaxes(country) {
if (country === 'India') {

View File

@ -1,7 +1,7 @@
import { _ } from 'frappejs/utils';
import { _ } from 'frappe/utils';
export default {
doctype: 'Tax',
title: _('Taxes'),
columns: ['name']
columns: ['name'],
};

View File

@ -1,6 +1,6 @@
import Badge from '@/components/Badge';
import { getInvoiceStatus, openQuickEdit, routeTo } from '@/utils';
import frappe from 'frappejs';
import frappe from 'frappe';
import utils from '../../../accounting/utils';
import { statusColor } from '../../../src/colors';

View File

@ -1,5 +1,5 @@
import frappe from 'frappejs';
import BaseDocument from 'frappejs/model/document';
import frappe from 'frappe';
import BaseDocument from 'frappe/model/document';
import { getExchangeRate } from '../../../accounting/exchangeRate';
export default class TransactionDocument extends BaseDocument {

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
export default {
async getPayments() {
@ -6,7 +6,7 @@ export default {
doctype: 'PaymentFor',
fields: ['parent'],
filters: { referenceName: this.name },
orderBy: 'name'
orderBy: 'name',
});
if (payments.length != 0) {
return payments;
@ -57,5 +57,5 @@ export default {
}
const entries = await this.getPosting();
await entries.postReverse();
}
},
};

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
async function setAugmentedModel(model, regionalInfo) {
const getAugmentedModel = (

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
export default async function execute() {
// Since sqlite has no ALTER TABLE to change column meta

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
function getTablesToConvert() {
// Do not change loops to map, doesn't work for some reason.

View File

@ -1,15 +1,15 @@
import frappe from 'frappejs';
import frappe from 'frappe';
export default class AccountsReceivablePayable {
async run(reportType, { date }) {
const rows = await getReceivablePayable({
reportType,
date
date,
});
return { rows };
}
};
}
async function getReceivablePayable({ reportType = 'Receivable', date }) {
let entries = [];
@ -34,7 +34,7 @@ async function getReceivablePayable({ reportType = 'Receivable', date }) {
if (outStandingAmount > 0.1 / 10) {
const row = {
date: entry.date,
party: entry.party
party: entry.party,
};
// due date / bill date
@ -51,7 +51,7 @@ async function getReceivablePayable({ reportType = 'Receivable', date }) {
invoicedAmount,
paidAmount,
outStandingAmount,
creditNoteAmount
creditNoteAmount,
});
// ageing
@ -69,13 +69,13 @@ async function getReceivablePayable({ reportType = 'Receivable', date }) {
doctype: referenceType,
fields: ['name', 'date'],
filters: {
submitted: 1
}
submitted: 1,
},
});
}
function getValidEntries() {
return entries.filter(entry => {
return entries.filter((entry) => {
return (
entry.date <= date &&
entry.referenceType === referenceType &&
@ -111,7 +111,7 @@ async function getReceivablePayable({ reportType = 'Receivable', date }) {
entry[reverseDebitOrCredit] -
paymentAmount -
creditNoteAmount,
creditNoteAmount
creditNoteAmount,
};
}
@ -121,7 +121,7 @@ async function getReceivablePayable({ reportType = 'Receivable', date }) {
}
function getFutureEntries() {
return entries.filter(entry => entry.date > date);
return entries.filter((entry) => entry.date > date);
}
function getReturnEntries() {
@ -139,12 +139,14 @@ async function getReceivablePayable({ reportType = 'Receivable', date }) {
}
const partyType = reportType === 'Receivable' ? 'customer' : 'supplier';
const partyList = (await frappe.db.getAll({
doctype: 'Party',
filters: {
[partyType]: 1
}
})).map(d => d.name);
const partyList = (
await frappe.db.getAll({
doctype: 'Party',
filters: {
[partyType]: 1,
},
})
).map((d) => d.name);
return await frappe.db.getAll({
doctype: 'AccountingLedgerEntry',
@ -156,13 +158,13 @@ async function getReceivablePayable({ reportType = 'Receivable', date }) {
'referenceType',
'referenceName',
'sum(debit) as debit',
'sum(credit) as credit'
'sum(credit) as credit',
],
filters: {
party: ['in', partyList]
party: ['in', partyList],
},
groupBy: ['referenceType', 'referenceName', 'party'],
orderBy: 'date'
orderBy: 'date',
});
}
}

View File

@ -1,51 +1,55 @@
import frappe from 'frappejs';
import { unique } from 'frappejs/utils';
import { unique } from 'frappe/utils';
import { getData } from '../FinancialStatements/FinancialStatements';
class BalanceSheet {
async run({ fromDate, toDate, periodicity }) {
async run({ fromDate, toDate, periodicity }) {
let asset = await getData({
rootType: 'Asset',
balanceMustBe: 'Debit',
fromDate,
toDate,
periodicity,
accumulateValues: true,
});
let asset = await getData({
rootType: 'Asset',
balanceMustBe: 'Debit',
fromDate,
toDate,
periodicity,
accumulateValues: true
});
let liability = await getData({
rootType: 'Liability',
balanceMustBe: 'Credit',
fromDate,
toDate,
periodicity,
accumulateValues: true,
});
let liability = await getData({
rootType: 'Liability',
balanceMustBe: 'Credit',
fromDate,
toDate,
periodicity,
accumulateValues: true
});
let equity = await getData({
rootType: 'Equity',
balanceMustBe: 'Credit',
fromDate,
toDate,
periodicity,
accumulateValues: true,
});
let equity = await getData({
rootType: 'Equity',
balanceMustBe: 'Credit',
fromDate,
toDate,
periodicity,
accumulateValues: true
});
const rows = [
...asset.accounts,
asset.totalRow,
[],
...liability.accounts,
liability.totalRow,
[],
...equity.accounts,
equity.totalRow,
[],
];
const rows = [
...asset.accounts, asset.totalRow, [],
...liability.accounts, liability.totalRow, [],
...equity.accounts, equity.totalRow, []
];
const columns = unique([
...asset.periodList,
...liability.periodList,
...equity.periodList,
]);
const columns = unique([
...asset.periodList,
...liability.periodList,
...equity.periodList
]);
return { rows, columns };
}
return { rows, columns };
}
}
export default BalanceSheet;

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import getCommonExportActions from '../commonExporter';
export default {

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
class BankReconciliation {
async run(params) {
@ -25,9 +25,9 @@ class BankReconciliation {
'name',
'referenceDate',
'referenceId',
'clearanceDate'
'clearanceDate',
],
filters: filters
filters: filters,
});
for (var i = 0; i < data.length; i++) {
@ -37,8 +37,8 @@ class BankReconciliation {
filters: {
referenceType: 'Payment',
account: data[i].paymentAccount,
referenceName: data[i].name
}
referenceName: data[i].name,
},
});
data[i].credit = ledger[0].credit;
data[i].debit = ledger[0].debit;

View File

@ -1,5 +1,5 @@
import csv2json from 'csvjson-csv2json';
import frappe from 'frappejs';
import frappe from 'frappe';
import ReconciliationValidation from '../../src/components/ReconciliationValidation';
export const fileImportHandler = (file, report) => {

View File

@ -1,6 +1,6 @@
import frappe from 'frappejs';
import { getPeriodList } from '../FinancialStatements/FinancialStatements';
import frappe from 'frappe';
import { DateTime } from 'luxon';
import { getPeriodList } from '../FinancialStatements/FinancialStatements';
class Cashflow {
async run({ fromDate, toDate, periodicity }) {
@ -15,10 +15,10 @@ class Cashflow {
.where('reverted', 0)
.sum({
inflow: 'debit',
outflow: 'credit'
outflow: 'credit',
})
.select({
'month-year': dateAsMonthYear
'month-year': dateAsMonthYear,
})
.where('account', 'in', cashAndBankAccounts)
.whereBetween('date', [fromDate, toDate])
@ -26,9 +26,9 @@ class Cashflow {
let periodList = getPeriodList(fromDate, toDate, periodicity);
let data = periodList.map(periodKey => {
let data = periodList.map((periodKey) => {
let monthYear = this.getMonthYear(periodKey, 'MMM yyyy');
let cashflowForPeriod = res.find(d => d['month-year'] === monthYear);
let cashflowForPeriod = res.find((d) => d['month-year'] === monthYear);
if (cashflowForPeriod) {
cashflowForPeriod.periodKey = periodKey;
return cashflowForPeriod;
@ -37,13 +37,13 @@ class Cashflow {
inflow: 0,
outflow: 0,
periodKey,
'month-year': monthYear
'month-year': monthYear,
};
});
return {
data,
periodList
periodList,
};
}

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import { DateTime } from 'luxon';
import { convertPesaValuesToFloat } from '../../src/utils';

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
class GeneralLedger {
async run(params) {

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import { stateCodeMap } from '../../accounting/gst';
import { convertPesaValuesToFloat } from '../../src/utils';

View File

@ -1,5 +1,4 @@
import frappe from 'frappejs';
import { unique } from 'frappejs/utils';
import { unique } from 'frappe/utils';
import { getData } from '../FinancialStatements/FinancialStatements';
class ProfitAndLoss {
@ -9,7 +8,7 @@ class ProfitAndLoss {
balanceMustBe: 'Credit',
fromDate,
toDate,
periodicity
periodicity,
});
let expense = await getData({
@ -17,17 +16,17 @@ class ProfitAndLoss {
balanceMustBe: 'Debit',
fromDate,
toDate,
periodicity
periodicity,
});
let incomeTotalRow = income.totalRow;
incomeTotalRow.account = {
template: `<span class="font-semibold">${income.totalRow.account}</span>`
template: `<span class="font-semibold">${income.totalRow.account}</span>`,
};
let expenseTotalRow = expense.totalRow;
expenseTotalRow.account = {
template: `<span class="font-semibold">${expense.totalRow.account}</span>`
template: `<span class="font-semibold">${expense.totalRow.account}</span>`,
};
let rows = [
@ -35,24 +34,24 @@ class ProfitAndLoss {
incomeTotalRow,
{
account: {
template: '<span>&nbsp;</span>'
template: '<span>&nbsp;</span>',
},
isGroup: 1
isGroup: 1,
},
...expense.accounts,
expenseTotalRow,
{
account: {
template: '<span>&nbsp;</span>'
template: '<span>&nbsp;</span>',
},
isGroup: 1
}
isGroup: 1,
},
];
rows = rows.map(row => {
rows = rows.map((row) => {
if (row.indent === 0) {
row.account = {
template: `<span class="font-semibold">${row.account}</span>`
template: `<span class="font-semibold">${row.account}</span>`,
};
}
return row;
@ -61,14 +60,14 @@ class ProfitAndLoss {
const columns = unique([...income.periodList, ...expense.periodList]);
let profitRow = {
account: 'Total Profit'
account: 'Total Profit',
};
for (let column of columns) {
profitRow[column] =
(income.totalRow[column] || 0.0) - (expense.totalRow[column] || 0.0);
rows.forEach(row => {
rows.forEach((row) => {
if (!row.isGroup) {
row[column] = row[column] || 0.0;
}

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import getCommonExportActions from '../commonExporter';
const title = 'Profit and Loss';
@ -52,7 +52,7 @@ export default {
label: name,
fieldname: name,
fieldtype: 'Currency',
width: 1
width: 1,
}));
columns.push(...columnDefs);

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
class PurchaseRegister {
async run({ fromDate, toDate, supplier }) {
@ -23,24 +23,24 @@ class PurchaseRegister {
fields: ['name', 'date', 'supplier', 'account', 'netTotal', 'grandTotal'],
filters,
orderBy: 'date',
order: 'desc'
order: 'desc',
});
const billNames = bills.map(d => d.name);
const billNames = bills.map((d) => d.name);
const taxes = await frappe.db.getAll({
doctype: 'TaxSummary',
fields: ['parent', 'amount'],
filters: {
parenttype: 'PurchaseInvoice',
parent: ['in', billNames]
parent: ['in', billNames],
},
orderBy: 'name'
orderBy: 'name',
});
for (let bill of bills) {
bill.totalTax = taxes
.filter(tax => tax.parent === bill.name)
.filter((tax) => tax.parent === bill.name)
.reduce((acc, tax) => {
if (tax.amount) {
acc = acc + tax.amount;

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
class SalesRegister {
async run({ fromDate, toDate, customer }) {
@ -22,24 +22,24 @@ class SalesRegister {
fields: ['name', 'date', 'customer', 'account', 'netTotal', 'grandTotal'],
filters: filters,
orderBy: 'date',
order: 'desc'
order: 'desc',
});
const invoiceNames = invoices.map(d => d.name);
const invoiceNames = invoices.map((d) => d.name);
const taxes = await frappe.db.getAll({
doctype: 'TaxSummary',
fields: ['parent', 'amount'],
filters: {
parenttype: 'Invoice',
parent: ['in', invoiceNames]
parent: ['in', invoiceNames],
},
orderBy: 'name'
orderBy: 'name',
});
for (let invoice of invoices) {
invoice.totalTax = taxes
.filter(tax => tax.parent === invoice.name)
.filter((tax) => tax.parent === invoice.name)
.reduce((acc, tax) => {
if (tax.amount) {
acc = acc + tax.amount;

View File

@ -1,4 +1,3 @@
import frappe from 'frappejs';
import { getTrialBalance } from '../FinancialStatements/FinancialStatements';
export default class TrialBalance {
@ -7,7 +6,7 @@ export default class TrialBalance {
return { rows: [] };
}
const promises = ['Asset', 'Expense', 'Income', 'Liability', 'Equity'].map(
rootType => {
(rootType) => {
return getTrialBalance({ rootType, fromDate, toDate });
}
);
@ -17,7 +16,7 @@ export default class TrialBalance {
return [...acc, ...curr];
}, []);
rows = rows.filter(r => r.debit !== 0 || r.credit !== 0);
rows = rows.filter((r) => r.debit !== 0 || r.credit !== 0);
return { rows };
}
};
}

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import getCommonExportActions from '../commonExporter';
const title = 'Trial Balance';

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import { getSavePath, saveData, showExportInFolder } from '../src/utils';
function templateToInnerText(innerHTML) {

View File

@ -1,76 +1,76 @@
import frappe from 'frappejs';
import GeneralLedger from './GeneralLedger/GeneralLedger';
import ProfitAndLoss from './ProfitAndLoss/ProfitAndLoss';
import frappe from 'frappe';
import AccountsReceivablePayable from './AccountsReceivablePayable/AccountsReceivablePayable';
import BalanceSheet from './BalanceSheet/BalanceSheet';
import TrialBalance from './TrialBalance/TrialBalance';
import SalesRegister from './SalesRegister/SalesRegister';
import PurchaseRegister from './PurchaseRegister/PurchaseRegister';
import BankReconciliation from './BankReconciliation/BankReconciliation';
import GeneralLedger from './GeneralLedger/GeneralLedger';
import GSTR1 from './GoodsAndServiceTax/GSTR1';
import GSTR2 from './GoodsAndServiceTax/GSTR2';
import AccountsReceivablePayable from './AccountsReceivablePayable/AccountsReceivablePayable';
import ProfitAndLoss from './ProfitAndLoss/ProfitAndLoss';
import PurchaseRegister from './PurchaseRegister/PurchaseRegister';
import SalesRegister from './SalesRegister/SalesRegister';
import TrialBalance from './TrialBalance/TrialBalance';
// called on server side
function registerReportMethods() {
const reports = [
{
method: 'general-ledger',
class: GeneralLedger
class: GeneralLedger,
},
{
method: 'profit-and-loss',
class: ProfitAndLoss
class: ProfitAndLoss,
},
{
method: 'balance-sheet',
class: BalanceSheet
class: BalanceSheet,
},
{
method: 'trial-balance',
class: TrialBalance
class: TrialBalance,
},
{
method: 'sales-register',
class: SalesRegister
class: SalesRegister,
},
{
method: 'purchase-register',
class: PurchaseRegister
class: PurchaseRegister,
},
{
method: 'bank-reconciliation',
class: BankReconciliation
class: BankReconciliation,
},
{
method: 'gstr-1',
class: GSTR1
class: GSTR1,
},
{
method: 'gstr-2',
class: GSTR2
}
class: GSTR2,
},
];
reports.forEach(report => {
reports.forEach((report) => {
frappe.registerMethod({
method: report.method,
handler: getReportData(report.class)
handler: getReportData(report.class),
});
});
frappe.registerMethod({
method: 'accounts-receivable',
handler: args => new AccountsReceivablePayable().run('Receivable', args)
handler: (args) => new AccountsReceivablePayable().run('Receivable', args),
});
frappe.registerMethod({
method: 'accounts-payable',
handler: args => new AccountsReceivablePayable().run('Payable', args)
handler: (args) => new AccountsReceivablePayable().run('Payable', args),
});
}
function getReportData(ReportClass) {
return args => new ReportClass().run(args);
return (args) => new ReportClass().run(args);
}
export default registerReportMethods;

View File

@ -1,19 +1,19 @@
import server from 'frappe/server';
import models from '../models';
import server from 'frappejs/server';
import postStart from './postStart';
async function start() {
await server.start({
backend: 'sqlite',
connectionParams: { dbPath: 'test.db', enableCORS: true },
models
})
await server.start({
backend: 'sqlite',
connectionParams: { dbPath: 'test.db', enableCORS: true },
models,
});
await postStart();
await postStart();
}
start();
export default {
start
};
start,
};

View File

@ -1,14 +1,13 @@
import frappe from 'frappejs';
import naming from 'frappejs/model/naming';
import frappe from 'frappe';
import naming from 'frappe/model/naming';
import GSTR3BServer from '../models/doctype/GSTR3B/GSTR3BServer.js';
import JournalEntryServer from '../models/doctype/JournalEntry/JournalEntryServer.js';
import PartyServer from '../models/doctype/Party/PartyServer.js';
import PaymentServer from '../models/doctype/Payment/PaymentServer.js';
import PurchaseInvoiceServer from '../models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js';
import SalesInvoiceServer from '../models/doctype/SalesInvoice/SalesInvoiceServer.js';
import registerServerMethods from './registerServerMethods';
import SalesInvoiceServer from '../models/doctype/SalesInvoice/SalesInvoiceServer.js'
import PaymentServer from '../models/doctype/Payment/PaymentServer.js'
import PartyServer from '../models/doctype/Party/PartyServer.js'
import PurchaseInvoiceServer from '../models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js'
import JournalEntryServer from '../models/doctype/JournalEntry/JournalEntryServer.js'
import GSTR3BServer from '../models/doctype/GSTR3B/GSTR3BServer.js'
export default async function postStart() {
// set server-side modules
frappe.models.SalesInvoice.documentClass = SalesInvoiceServer;
@ -41,15 +40,15 @@ export default async function postStart() {
frappe.currencySymbols = await getCurrencySymbols();
registerServerMethods();
};
}
function getCurrencySymbols() {
return frappe.db
.getAll({
doctype: 'Currency',
fields: ['name', 'symbol']
fields: ['name', 'symbol'],
})
.then(data => {
.then((data) => {
return data.reduce((obj, currency) => {
obj[currency.name] = currency.symbol;
return obj;

View File

@ -1,4 +1,4 @@
import frappe from 'frappejs';
import frappe from 'frappe';
import importCharts from '../accounting/importCOA';
import registerReportMethods from '../reports';
@ -9,6 +9,6 @@ export default function registerServerMethods() {
method: 'import-coa',
async handler() {
await importCharts();
}
},
});
};
}

View File

@ -26,7 +26,7 @@
<script>
import './styles/index.css';
import frappe from 'frappejs';
import frappe from 'frappe';
import Desk from './pages/Desk';
import SetupWizard from './pages/SetupWizard/SetupWizard';
import DatabaseSelector from './pages/DatabaseSelector';

View File

@ -39,7 +39,7 @@
</template>
<script>
import frappe from 'frappejs';
import frappe from 'frappe';
import { ipcRenderer } from 'electron';
import Base from './Base';
import { IPC_ACTIONS } from '@/messages'

View File

@ -28,7 +28,7 @@
</template>
<script>
import frappe from 'frappejs';
import frappe from 'frappe';
import Float from './Float';
export default {

View File

@ -16,7 +16,7 @@
</template>
<script>
import frappe from 'frappejs';
import frappe from 'frappe';
import Base from './Base';
import DatePicker from '../DatePicker/DatePicker';

View File

@ -1,5 +1,5 @@
<script>
import frappe from 'frappejs';
import frappe from 'frappe';
import AutoComplete from './AutoComplete';
import Badge from '@/components/Badge';
import { openQuickEdit } from '@/utils';

View File

@ -61,7 +61,7 @@
</template>
<script>
import frappe from 'frappejs';
import frappe from 'frappe';
import Row from '@/components/Row';
import Base from './Base';
import TableRow from './TableRow';

View File

@ -22,7 +22,7 @@
</div>
</template>
<script>
import FormLayout from 'frappejs/ui/components/Form/FormLayout';
import FormLayout from 'frappe/ui/components/Form/FormLayout';
import { Sketch } from 'vue-color';
export default {

View File

@ -6,7 +6,7 @@
</template>
<script>
import indicators from 'frappejs/ui/constants/indicators';
import indicators from 'frappe/ui/constants/indicators';
export default {
name: 'MessageDialog',
data() {

Some files were not shown because too many files have changed in this diff Show More