mirror of
https://github.com/frappe/books.git
synced 2024-12-24 20:00:29 +00:00
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
const numberFormat = require('./numberFormat');
|
|
// const markdown = new (require('showdown').Converter)();
|
|
const luxon = require('luxon');
|
|
const frappe = require('frappejs');
|
|
|
|
module.exports = {
|
|
format(value, field) {
|
|
if (typeof field === 'string') {
|
|
field = { fieldtype: field };
|
|
}
|
|
|
|
if (field.fieldtype === 'Currency') {
|
|
value = numberFormat.formatNumber(value);
|
|
|
|
} else if (field.fieldtype === 'Text') {
|
|
// value = markdown.makeHtml(value || '');
|
|
|
|
} else if (field.fieldtype === 'Date') {
|
|
let dateFormat;
|
|
if (!frappe.SystemSettings) {
|
|
dateFormat = 'yyyy-MM-dd';
|
|
} else {
|
|
dateFormat = frappe.SystemSettings.dateFormat;
|
|
}
|
|
|
|
value = luxon.DateTime.fromISO(value).toFormat(dateFormat);
|
|
|
|
} else {
|
|
if (value === null || value === undefined) {
|
|
value = '';
|
|
} else {
|
|
value = value + '';
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
}
|