2
0
mirror of https://github.com/frappe/books.git synced 2024-09-19 19:19:02 +00:00

print format wip

This commit is contained in:
Rushabh Mehta 2018-02-20 22:41:16 +05:30
parent 598682160c
commit 6b26f5acc8
10 changed files with 12627 additions and 143 deletions

323
dist/css/style.css vendored
View File

@ -6811,6 +6811,324 @@ span.flatpickr-day.today, span.flatpickr-day.prevMonthDay.today, span.flatpickr-
margin: -1px 0 0 -1px; }
.hasWeeks .flatpickr-days {
border-right: 0; }
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
direction: ltr; }
/* PADDING */
.CodeMirror-lines {
padding: 4px 0;
/* Vertical padding around content */ }
.CodeMirror pre {
padding: 0 4px;
/* Horizontal padding of content */ }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white;
/* The little square between H and V scrollbars */ }
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap; }
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap; }
.CodeMirror-guttermarker {
color: black; }
.CodeMirror-guttermarker-subtle {
color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0; }
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver; }
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7; }
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1; }
.cm-fat-cursor-mark {
background-color: rgba(20, 255, 20, 0.5);
-webkit-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite; }
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
background-color: #7e7; }
@-webkit-keyframes blink {
0% { }
50% {
background-color: transparent; }
100% { } }
@keyframes blink {
0% { }
50% {
background-color: transparent; }
100% { } }
/* Can style cursor different in overwrite (non-insert) mode */
.cm-tab {
display: inline-block;
text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0;
right: 0;
top: -50px;
bottom: -20px;
overflow: hidden; }
.CodeMirror-ruler {
border-left: 1px solid #ccc;
top: 0;
bottom: 0;
position: absolute; }
/* DEFAULT THEME */
.cm-s-default .cm-header {
color: blue; }
.cm-s-default .cm-quote {
color: #090; }
.cm-negative {
color: #d44; }
.cm-positive {
color: #292; }
.cm-header, .cm-strong {
font-weight: bold; }
.cm-em {
font-style: italic; }
.cm-link {
text-decoration: underline; }
.cm-strikethrough {
text-decoration: line-through; }
.cm-s-default .cm-keyword {
color: #708; }
.cm-s-default .cm-atom {
color: #219; }
.cm-s-default .cm-number {
color: #164; }
.cm-s-default .cm-def {
color: #00f; }
.cm-s-default .cm-variable-2 {
color: #05a; }
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {
color: #085; }
.cm-s-default .cm-comment {
color: #a50; }
.cm-s-default .cm-string {
color: #a11; }
.cm-s-default .cm-string-2 {
color: #f50; }
.cm-s-default .cm-meta {
color: #555; }
.cm-s-default .cm-qualifier {
color: #555; }
.cm-s-default .cm-builtin {
color: #30a; }
.cm-s-default .cm-bracket {
color: #997; }
.cm-s-default .cm-tag {
color: #170; }
.cm-s-default .cm-attribute {
color: #00c; }
.cm-s-default .cm-hr {
color: #999; }
.cm-s-default .cm-link {
color: #00c; }
.cm-s-default .cm-error {
color: #f00; }
.cm-invalidchar {
color: #f00; }
.CodeMirror-composing {
border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {
color: #0b0; }
div.CodeMirror span.CodeMirror-nonmatchingbracket {
color: #a22; }
.CodeMirror-matchingtag {
background: rgba(255, 150, 0, 0.3); }
.CodeMirror-activeline-background {
background: #e8f2ff; }
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white; }
.CodeMirror-scroll {
overflow: scroll !important;
/* Things will break if this is overridden */
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px;
margin-right: -30px;
padding-bottom: 30px;
height: 100%;
outline: none;
/* Prevent dragging from highlighting the element */
position: relative; }
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent; }
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none; }
.CodeMirror-vscrollbar {
right: 0;
top: 0;
overflow-x: hidden;
overflow-y: scroll; }
.CodeMirror-hscrollbar {
bottom: 0;
left: 0;
overflow-y: hidden;
overflow-x: scroll; }
.CodeMirror-scrollbar-filler {
right: 0;
bottom: 0; }
.CodeMirror-gutter-filler {
left: 0;
bottom: 0; }
.CodeMirror-gutters {
position: absolute;
left: 0;
top: 0;
min-height: 100%;
z-index: 3; }
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -30px; }
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important; }
.CodeMirror-gutter-background {
position: absolute;
top: 0;
bottom: 0;
z-index: 4; }
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4; }
.CodeMirror-gutter-wrapper ::-moz-selection {
background-color: transparent; }
.CodeMirror-gutter-wrapper ::selection {
background-color: transparent; }
.CodeMirror-gutter-wrapper ::-moz-selection {
background-color: transparent; }
.CodeMirror-lines {
cursor: text;
min-height: 1px;
/* prevents collapsing before first draw */ }
.CodeMirror pre {
/* Reset some styles that the rest of the page might have set */
border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual; }
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal; }
.CodeMirror-linebackground {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 0; }
.CodeMirror-linewidget {
position: relative;
z-index: 2;
padding: 0.1px;
/* Force widget margins to stay inside of the container */ }
.CodeMirror-rtl pre {
direction: rtl; }
.CodeMirror-code {
outline: none; }
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll, .CodeMirror-sizer, .CodeMirror-gutter, .CodeMirror-gutters, .CodeMirror-linenumber {
-webkit-box-sizing: content-box;
box-sizing: content-box; }
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden; }
.CodeMirror-cursor {
position: absolute;
pointer-events: none; }
.CodeMirror-measure pre {
position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3; }
div.CodeMirror-dragcursors {
visibility: visible; }
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible; }
.CodeMirror-selected {
background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected {
background: #d7d4f0; }
.CodeMirror-crosshair {
cursor: crosshair; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection {
background: #d7d4f0; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection {
background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection {
background: #d7d4f0; }
.cm-searching {
background-color: #ffa;
background-color: rgba(255, 255, 0, 0.4); }
/* Used to force a border model for a node */
.cm-force-border {
padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden; } }
/* See issue #2901 */
.cm-tab-wrap-hack:after {
content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext {
background: none; }
html {
font-size: 12px; }
.desk-body {
@ -6859,6 +7177,11 @@ html {
background-color: #e9ecef; }
.dropdown-item {
padding: 0.5rem 1rem; }
.CodeMirror {
font-family: "SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;
border: 1px solid #dee2e6;
border-radius: 0.25rem;
padding: 0.5rem; }
.awesomplete {
display: block; }
.awesomplete > ul > li {

12338
dist/js/bundle.js vendored

File diff suppressed because it is too large Load Diff

6
fixtures/invoice.html Normal file
View File

@ -0,0 +1,6 @@
<h1>{{ _("Invoice") }}</h1>
<div>
<p><b>Customer</b></p>
<p>{{ doc.customer }}</p>
</div>

6
fixtures/invoicePrint.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
doctype: "PrintFormat",
name: "Standard Invoice Format",
for: "Invoice",
template: require('./invoice.html')
}

View File

@ -4,6 +4,7 @@ module.exports = {
"name": "Invoice",
"doctype": "DocType",
"documentClass": require("./InvoiceDocument.js"),
"defaultPrintFormat": "Standard Invoice Format",
"isSingle": 0,
"istable": 0,
"keywordFields": ["name", "customer"],

View File

@ -23,7 +23,7 @@ module.exports = class Invoice extends BaseDocument {
if (!this.taxes) this.taxes = [];
// reset tax amount
this.taxes.map(d => d.amount = 0);
this.taxes.map(d => { d.amount = 0; d.rate = 0; });
// calculate taxes
for (let row of this.items) {
@ -35,6 +35,7 @@ module.exports = class Invoice extends BaseDocument {
// check if added in summary
for (let taxDetail of this.taxes) {
if (taxDetail.account === rowTaxDetail.account) {
taxDetail.rate = rowTaxDetail.rate;
taxDetail.amount += rowTaxDetail.amount;
found = true;
}

View File

@ -36,7 +36,8 @@ module.exports = {
"fieldname": "tax",
"label": "Tax",
"fieldtype": "Link",
"target": "Tax"
"target": "Tax",
formula: (row, doc) => doc.getFrom('Item', row.item, 'tax')
},
{
"fieldname": "amount",

View File

@ -13,11 +13,12 @@
"bootstrap": "^4.0.0",
"bufferutil": "^3.0.3",
"clusterize.js": "^0.18.0",
"debug": "^3.1.0",
"codemirror": "^5.35.0",
"express": "^4.16.2",
"flatpickr": "^4.3.2",
"jquery": "^3.3.1",
"node-fetch": "^1.7.3",
"nunjucks": "^3.1.0",
"popper.js": "^1.12.9",
"rollup-plugin-ignore": "^1.0.3",
"socket.io": "^2.0.4",
@ -41,6 +42,7 @@
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-postcss": "^1.2.7",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-sass": "^0.5.3"
}
}

View File

@ -1,8 +1,11 @@
const server = require('frappejs/server');
const frappe = require('frappejs');
server.start({
backend: 'sqlite',
connectionParams: {dbPath: 'test.db'},
static: './',
models: require('./models')
}).then(() => {
frappe.syncDoc(require('./fixtures/invoicePrint'));
});

View File

@ -2,6 +2,10 @@
# yarn lockfile v1
a-sync-waterfall@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/a-sync-waterfall/-/a-sync-waterfall-1.0.0.tgz#38e8319d79379e24628845b53b96722b29e0e47c"
abbrev@1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
@ -97,6 +101,13 @@ ansi-styles@^3.1.0:
dependencies:
color-convert "^1.9.0"
anymatch@^1.3.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a"
dependencies:
micromatch "^2.1.5"
normalize-path "^2.0.0"
anymatch@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb"
@ -173,6 +184,10 @@ arrify@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
asap@^2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
asn1.js@^4.0.0:
version "4.9.2"
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.2.tgz#8117ef4f7ed87cd8f89044b5bff97ac243a16c9a"
@ -575,7 +590,7 @@ camelcase-keys@^2.0.0:
camelcase "^2.0.0"
map-obj "^1.0.0"
camelcase@^2.0.0:
camelcase@^2.0.0, camelcase@^2.0.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f"
@ -638,6 +653,21 @@ chardet@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
chokidar@^1.6.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
dependencies:
anymatch "^1.3.0"
async-each "^1.0.0"
glob-parent "^2.0.0"
inherits "^2.0.1"
is-binary-path "^1.0.0"
is-glob "^2.0.0"
path-is-absolute "^1.0.0"
readdirp "^2.0.0"
optionalDependencies:
fsevents "^1.0.0"
chokidar@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.0.tgz#6686313c541d3274b2a5c01233342037948c911b"
@ -699,7 +729,7 @@ cli-width@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
cliui@^3.2.0:
cliui@^3.0.3, cliui@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d"
dependencies:
@ -733,6 +763,10 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
codemirror@^5.35.0:
version "5.35.0"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.35.0.tgz#280653d495455bc66aa87e6284292b02775ba878"
collection-visit@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0"
@ -2817,7 +2851,7 @@ methods@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
micromatch@^2.3.11:
micromatch@^2.1.5, micromatch@^2.3.11:
version "2.3.11"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565"
dependencies:
@ -3085,7 +3119,7 @@ normalize-package-data@^2.3.2, normalize-package-data@^2.3.4:
semver "2 || 3 || 4 || 5"
validate-npm-package-license "^3.0.1"
normalize-path@^2.0.1, normalize-path@^2.1.1:
normalize-path@^2.0.0, normalize-path@^2.0.1, normalize-path@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9"
dependencies:
@ -3127,6 +3161,17 @@ number-is-nan@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
nunjucks@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/nunjucks/-/nunjucks-3.1.0.tgz#6c384eaafada1eb734d9a78126f3279c87d45d5e"
dependencies:
a-sync-waterfall "^1.0.0"
asap "^2.0.3"
postinstall-build "^5.0.1"
yargs "^3.32.0"
optionalDependencies:
chokidar "^1.6.0"
oauth-sign@~0.8.1, oauth-sign@~0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"
@ -3796,6 +3841,10 @@ postcss@^6.0.1, postcss@^6.0.11, postcss@^6.0.13, postcss@^6.0.14, postcss@^6.0.
source-map "^0.6.1"
supports-color "^5.1.0"
postinstall-build@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/postinstall-build/-/postinstall-build-5.0.1.tgz#b917a9079b26178d9a24af5a5cd8cb4a991d11b9"
prebuild-install@~2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.3.0.tgz#19481247df728b854ab57b187ce234211311b485"
@ -4361,6 +4410,14 @@ rollup-plugin-postcss@^1.2.7:
rollup-pluginutils "^2.0.1"
style-inject "^0.2.0"
rollup-plugin-replace@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-2.0.0.tgz#19074089c8ed57184b8cc64e967a03d095119277"
dependencies:
magic-string "^0.22.4"
minimatch "^3.0.2"
rollup-pluginutils "^2.0.1"
rollup-plugin-sass@^0.5.3:
version "0.5.3"
resolved "https://registry.yarnpkg.com/rollup-plugin-sass/-/rollup-plugin-sass-0.5.3.tgz#f275ee19d40f4f915287dbf7fef92b9cd03c6181"
@ -5216,6 +5273,10 @@ widest-line@^2.0.0:
dependencies:
string-width "^2.1.1"
window-size@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876"
wordwrap@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
@ -5286,7 +5347,7 @@ xtend@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-3.0.0.tgz#5cce7407baf642cba7becda568111c493f59665a"
y18n@^3.2.1:
y18n@^3.2.0, y18n@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41"
@ -5300,6 +5361,18 @@ yargs-parser@^5.0.0:
dependencies:
camelcase "^3.0.0"
yargs@^3.32.0:
version "3.32.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995"
dependencies:
camelcase "^2.0.1"
cliui "^3.0.3"
decamelize "^1.1.1"
os-locale "^1.4.0"
string-width "^1.0.1"
window-size "^0.1.4"
y18n "^3.2.0"
yargs@^7.0.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-7.1.0.tgz#6ba318eb16961727f5d284f8ea003e8d6154d0c8"