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

added fetch

This commit is contained in:
Rushabh Mehta 2018-02-09 18:26:10 +05:30
parent 85693672cc
commit cf5f029ea0
9 changed files with 297 additions and 200 deletions

10
dist/css/style.css vendored
View File

@ -5735,9 +5735,13 @@ a.text-dark:hover, a.text-dark:focus {
background: #3d6b00; background: #3d6b00;
color: inherit; } color: inherit; }
html { html {
font-size: 16px; } font-size: 14px; }
.main { .main {
border-left: 1px solid #dee2e6; } border-left: 1px solid #dee2e6; }
.sidebar .list-group-item {
padding: 0.5rem 1rem; }
.sidebar .list-group-flush {
margin: -1rem; }
.hide { .hide {
display: none !important; } display: none !important; }
.page-head { .page-head {
@ -5780,8 +5784,8 @@ mark {
color: inherit; color: inherit;
padding: 0px; } padding: 0px; }
.table-wrapper { .table-wrapper {
margin-top: 1rem; margin-top: 2rem;
margin-bottom: 1rem; } margin-bottom: 2rem; }
.table-toolbar { .table-toolbar {
margin-top: 0.5rem; } margin-top: 0.5rem; }
.data-table-col .edit-cell { .data-table-col .edit-cell {

441
dist/js/bundle.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
"fieldname": "name", "fieldname": "name",
"label": "Account Name", "label": "Account Name",
"fieldtype": "Data", "fieldtype": "Data",
"reqd": 1 "required": 1
}, },
{ {
"fieldname": "parent_account", "fieldname": "parent_account",

View File

@ -11,7 +11,7 @@
"fieldname": "name", "fieldname": "name",
"label": "Name", "label": "Name",
"fieldtype": "Data", "fieldtype": "Data",
"reqd": 1 "required": 1
} }
] ]
} }

View File

@ -8,9 +8,6 @@ class InvoiceMeta extends BaseMeta {
} }
class Invoice extends BaseDocument { class Invoice extends BaseDocument {
get_total() {
return this.items.map(d => (d.amount || 0)).reduce((a, b) => a + b, 0);
}
} }
module.exports = { module.exports = {

View File

@ -10,21 +10,22 @@
"label": "Customer", "label": "Customer",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Customer", "target": "Customer",
"reqd": 1 "required": 1
}, },
{ {
"fieldname": "items", "fieldname": "items",
"label": "Items", "label": "Items",
"fieldtype": "Table", "fieldtype": "Table",
"childtype": "Invoice Item", "childtype": "Invoice Item",
"reqd": 1 "required": true
}, },
{ {
"fieldname": "total", "fieldname": "total",
"label": "Total", "label": "Total",
"fieldtype": "Currency", "fieldtype": "Currency",
"formula": "doc.get_total()", "formula": "doc.getSum('items', 'amount')",
"reqd": 1 "required": true,
"disabled": true
} }
] ]
} }

View File

@ -10,33 +10,33 @@
"label": "Item", "label": "Item",
"fieldtype": "Link", "fieldtype": "Link",
"target": "Item", "target": "Item",
"reqd": 1 "required": 1
}, },
{ {
"fieldname": "description", "fieldname": "description",
"label": "Description", "label": "Description",
"fieldtype": "Text", "fieldtype": "Text",
"fetch": {"from": "item", "value": "description"}, "formula": "doc.getFrom('Item', row.item, 'description')",
"reqd": 1 "required": 1
}, },
{ {
"fieldname": "quantity", "fieldname": "quantity",
"label": "Quantity", "label": "Quantity",
"fieldtype": "Float", "fieldtype": "Float",
"reqd": 1 "required": 1
}, },
{ {
"fieldname": "rate", "fieldname": "rate",
"label": "Rate", "label": "Rate",
"fieldtype": "Currency", "fieldtype": "Currency",
"reqd": 1 "required": 1
}, },
{ {
"fieldname": "amount", "fieldname": "amount",
"label": "Amount", "label": "Amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"read_only": 1, "disabled": 1,
"formula": "doc.quantity * doc.rate" "formula": "row.quantity * row.rate"
} }
] ]
} }

View File

@ -11,7 +11,7 @@
"fieldname": "name", "fieldname": "name",
"label": "Item Name", "label": "Item Name",
"fieldtype": "Data", "fieldtype": "Data",
"reqd": 1 "required": 1
}, },
{ {
"fieldname": "description", "fieldname": "description",

View File

@ -17,11 +17,11 @@ client.start({
frappe.modules.todo_client = require('frappejs/models/doctype/todo/todo_client.js'); frappe.modules.todo_client = require('frappejs/models/doctype/todo/todo_client.js');
frappe.modules.account_client = require('../models/doctype/account/account_client.js'); frappe.modules.account_client = require('../models/doctype/account/account_client.js');
frappe.desk.add_sidebar_item('ToDo', '#list/todo'); frappe.desk.addSidebarItem('ToDo', '#list/todo');
frappe.desk.add_sidebar_item('Accounts', '#list/account'); frappe.desk.addSidebarItem('Accounts', '#list/account');
frappe.desk.add_sidebar_item('Items', '#list/item'); frappe.desk.addSidebarItem('Items', '#list/item');
frappe.desk.add_sidebar_item('Customers', '#list/customer'); frappe.desk.addSidebarItem('Customers', '#list/customer');
frappe.desk.add_sidebar_item('Invoice', '#list/invoice'); frappe.desk.addSidebarItem('Invoice', '#list/invoice');
frappe.router.default = '#list/todo'; frappe.router.default = '#list/todo';