mirror of
https://github.com/frappe/books.git
synced 2024-11-08 14:50:56 +00:00
added invoice models
This commit is contained in:
parent
cd5461722e
commit
76f3f669d3
11
dist/js/bundle.js
vendored
11
dist/js/bundle.js
vendored
@ -1240,14 +1240,14 @@ var router = class Router {
|
||||
};
|
||||
|
||||
var observable = class Observable {
|
||||
constructor() {
|
||||
this._handlers = {};
|
||||
}
|
||||
constructor() {
|
||||
this._handlers = {};
|
||||
}
|
||||
|
||||
on(event, fn) {
|
||||
if (!this._handlers[event]) {
|
||||
this._handlers[event] = [];
|
||||
}
|
||||
this._handlers[event] = [];
|
||||
}
|
||||
this._handlers[event].push(fn);
|
||||
}
|
||||
|
||||
@ -2741,6 +2741,7 @@ var account_client = {
|
||||
List: AccountList
|
||||
};
|
||||
|
||||
// start server
|
||||
client.start({
|
||||
server: 'localhost:8000',
|
||||
container: document.querySelector('.wrapper'),
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Account",
|
||||
"doctype": "DocType",
|
||||
"issingle": 0,
|
||||
"is_single": 0,
|
||||
"keyword_fields": [
|
||||
"name",
|
||||
"account_type"
|
||||
@ -17,7 +17,7 @@
|
||||
"fieldname": "parent_account",
|
||||
"label": "Parent Account",
|
||||
"fieldtype": "Link",
|
||||
"options": "Account"
|
||||
"target": "Account"
|
||||
},
|
||||
{
|
||||
"fieldname": "account_type",
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Customer",
|
||||
"doctype": "DocType",
|
||||
"issingle": 0,
|
||||
"is_single": 0,
|
||||
"istable": 0,
|
||||
"keyword_fields": [
|
||||
"name"
|
||||
|
27
models/doctype/invoice/invoice.js
Normal file
27
models/doctype/invoice/invoice.js
Normal file
@ -0,0 +1,27 @@
|
||||
const BaseMeta = require('frappejs/model/meta');
|
||||
const BaseDocument = require('frappejs/model/document');
|
||||
|
||||
class InvoiceMeta extends BaseMeta {
|
||||
setup_meta() {
|
||||
Object.assign(this, require('./invoice.json'));
|
||||
}
|
||||
}
|
||||
|
||||
class Invoice extends BaseDocument {
|
||||
setup() {
|
||||
this.add_handler('validate');
|
||||
}
|
||||
|
||||
validate() {
|
||||
this.total = this.get_total();
|
||||
}
|
||||
|
||||
get_total() {
|
||||
return this.items.map(d => d.amount).reduce((a, b) => a + b, 0);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Document: Invoice,
|
||||
Meta: InvoiceMeta
|
||||
};
|
30
models/doctype/invoice/invoice.json
Normal file
30
models/doctype/invoice/invoice.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "Invoice",
|
||||
"doctype": "DocType",
|
||||
"is_single": 0,
|
||||
"istable": 0,
|
||||
"keyword_fields": [],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "customer",
|
||||
"label": "Customer",
|
||||
"fieldtype": "Link",
|
||||
"target": "Customer",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "items",
|
||||
"label": "Items",
|
||||
"fieldtype": "Table",
|
||||
"childtype": "Invoice Item",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "total",
|
||||
"label": "Total",
|
||||
"fieldtype": "Currency",
|
||||
"formula": "doc.get_total()",
|
||||
"reqd": 1
|
||||
}
|
||||
]
|
||||
}
|
16
models/doctype/invoice_item/invoice_item.js
Normal file
16
models/doctype/invoice_item/invoice_item.js
Normal file
@ -0,0 +1,16 @@
|
||||
const BaseMeta = require('frappejs/model/meta');
|
||||
const BaseDocument = require('frappejs/model/document');
|
||||
|
||||
class InvoiceItemMeta extends BaseMeta {
|
||||
setup_meta() {
|
||||
Object.assign(this, require('./invoice_item.json'));
|
||||
}
|
||||
}
|
||||
|
||||
class InvoiceItem extends BaseDocument {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Document: InvoiceItem,
|
||||
Meta: InvoiceItemMeta
|
||||
};
|
42
models/doctype/invoice_item/invoice_item.json
Normal file
42
models/doctype/invoice_item/invoice_item.json
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "Invoice Item",
|
||||
"doctype": "DocType",
|
||||
"is_single": 0,
|
||||
"is_child": 1,
|
||||
"keyword_fields": [],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "item",
|
||||
"label": "Item",
|
||||
"fieldtype": "Link",
|
||||
"options": "Item",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"label": "Description",
|
||||
"fieldtype": "Text",
|
||||
"fetch": "item.description",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "quantity",
|
||||
"label": "Quantity",
|
||||
"fieldtype": "Float",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "rate",
|
||||
"label": "Rate",
|
||||
"fieldtype": "Currency",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "amount",
|
||||
"label": "Amount",
|
||||
"fieldtype": "Currency",
|
||||
"readonly": 1,
|
||||
"formula": "doc.quantity * doc.rate"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "Item",
|
||||
"doctype": "DocType",
|
||||
"issingle": 0,
|
||||
"is_single": 0,
|
||||
"keyword_fields": [
|
||||
"name",
|
||||
"description"
|
||||
|
Loading…
Reference in New Issue
Block a user