mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
added invoice models
This commit is contained in:
parent
cd5461722e
commit
76f3f669d3
1
dist/js/bundle.js
vendored
1
dist/js/bundle.js
vendored
@ -2741,6 +2741,7 @@ var account_client = {
|
|||||||
List: AccountList
|
List: AccountList
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// start server
|
||||||
client.start({
|
client.start({
|
||||||
server: 'localhost:8000',
|
server: 'localhost:8000',
|
||||||
container: document.querySelector('.wrapper'),
|
container: document.querySelector('.wrapper'),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Account",
|
"name": "Account",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"issingle": 0,
|
"is_single": 0,
|
||||||
"keyword_fields": [
|
"keyword_fields": [
|
||||||
"name",
|
"name",
|
||||||
"account_type"
|
"account_type"
|
||||||
@ -17,7 +17,7 @@
|
|||||||
"fieldname": "parent_account",
|
"fieldname": "parent_account",
|
||||||
"label": "Parent Account",
|
"label": "Parent Account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"options": "Account"
|
"target": "Account"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "account_type",
|
"fieldname": "account_type",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Customer",
|
"name": "Customer",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"issingle": 0,
|
"is_single": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"keyword_fields": [
|
"keyword_fields": [
|
||||||
"name"
|
"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",
|
"name": "Item",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"issingle": 0,
|
"is_single": 0,
|
||||||
"keyword_fields": [
|
"keyword_fields": [
|
||||||
"name",
|
"name",
|
||||||
"description"
|
"description"
|
||||||
|
Loading…
Reference in New Issue
Block a user