_.each(items, function(item, i) { summary.total += item.total || 0; summary.totalRequest += item.totalRequested || 0; tableRow({ number: i + 1 + '', vendor: formatString(item.vendor), category: formatString(item.category), total: formatAmount(item.total) + formatAmountParens(item.totalRequested), date: formatDate(item.date), type: morph.toTitle(formatString(item.type)), location: formatString(_.reject([item.city, item.state], _.isEmpty).join(', ')), payment: formatString(item.paymentType) }, 'Helvetica', 'black', i % 2 ? '#eee' : 'white', '#ccc'); });
_.each(entries, function(entry) { var firstColumn = col % 4 === 0; var lastColumn = col % 4 === 3; var keepDataWithImage = lastColumn && options.items && entry.type === 'image' && entry.page === 0; if (firstColumn || keepDataWithImage) { doc.addPage(); x = doc.page.margins.left; y = doc.page.margins.top; col = 0; } if (entry.type === 'image') { doc.font('Helvetica-Bold').fontSize(14); if (!entry.first) { doc.text('Page ' + entry.page, x, y, { width: colWidth, lineBreak: false, ellipsis: true }); } else if (entry.first !== entry.last) { doc.text('Items ' + entry.first + '-' + entry.last, x, y, { width: colWidth, lineBreak: false, ellipsis: true }); } else { doc.text('Item ' + entry.first, x, y, { width: colWidth, lineBreak: false, ellipsis: true }); } doc.image(ctx.images[entry.image], x, y + doc.currentLineHeight() * 1.6, { fit: [colWidth, colHeight - doc.currentLineHeight()] }); doc.fontSize(10); } if (entry.type === 'item') { doc.font('Helvetica-Bold').fontSize(14); doc.text('Item ' + entry.number, x, y, { height: doc.currentLineHeight(), width: colWidth, lineBreak: false, ellipsis: true }); y += doc.currentLineHeight(true) * 1.6; doc.fontSize(10); _.each([ { label: 'Name', value: formatString(entry.item.name) }, { label: 'Vendor', value: formatString(entry.item.vendor) }, { label: 'Total', value: formatAmount(entry.item.total) + formatAmountParens(entry.item.totalRequested) }, { label: 'Date', value: formatDate(entry.item.date) }, { label: 'Type', value: morph.toTitle(formatString(entry.item.type)) }, { label: 'Payment', value: formatString(entry.item.paymentType) }, { label: 'City', value: formatString(entry.item.city) }, { label: 'State', value: formatString(entry.item.state) }, { label: 'Tax', value: formatAmount(entry.item.tax) }, { label: 'Tax 2', value: formatAmount(entry.item.additionalTax) }, { label: 'Tip', value: formatAmount(entry.item.tip) }, { label: 'Category', value: formatString(entry.item.category) }, { label: 'Billable', value: formatYesNo(entry.item.billable) }, { label: 'Reimbursable', value: formatYesNo(entry.item.reimbursable) }, ], function(line) { doc.font('Helvetica-Bold').text(line.label, x, y, { width: colWidth }); var labelWidth = doc.widthOfString(line.label); doc.font('Helvetica').text(line.value, x + labelWidth, y, { height: doc.currentLineHeight(), width: colWidth - labelWidth, align: 'right', ellipsis: true }); y += doc.currentLineHeight(true) * 1.6; }); doc.font('Helvetica-Bold').text('Notes', x, y); y += doc.currentLineHeight(true) * 1.6; doc.font('Helvetica').text(formatString(entry.item.comments), x, y, { width: colWidth, height: colHeight - y + doc.page.margins.top, ellipsis: true }); } col++; x += colWidth + colPadding; y = doc.page.margins.top; });
get: function() { return this.name || morph.toTitle(this.type); }
$scope.displayType = function(item) { return item.type === 'expense' ? 'Itemized' : morph.toTitle(item.type); };
_sanitizeName(string) { return morph.toTitle(string) }
/** * The display name for the model to use in the Admin UI * @return {string} Defaults to `<model>` */ displayName() { return this.opts.displayName || morph.toTitle(this.model()) }