diff --git a/models/doctype/Transaction/Transaction.js b/models/doctype/Transaction/Transaction.js index e567ec71..f6d43c06 100644 --- a/models/doctype/Transaction/Transaction.js +++ b/models/doctype/Transaction/Transaction.js @@ -1,6 +1,6 @@ import frappe from 'frappejs'; import utils from '../../../accounting/utils'; -import { openQuickEdit } from '@/utils'; +import { openQuickEdit, getStatusAndColor } from '@/utils'; import Badge from '@/components/Badge'; export function getStatusColumn() { @@ -9,16 +9,7 @@ export function getStatusColumn() { fieldname: 'status', fieldtype: 'Select', render(doc) { - let status = 'Unpaid'; - let color = 'orange'; - if (!doc.submitted) { - status = 'Draft'; - color = 'gray'; - } - if (doc.submitted === 1 && doc.outstandingAmount === 0.0) { - status = 'Paid'; - color = 'green'; - } + const { status, color } = getStatusAndColor(doc); return { template: `${status}`, components: { Badge }, @@ -81,6 +72,6 @@ export function getActions(doctype) { } export default { - getStatusColumn, - getActions -} \ No newline at end of file + getStatusColumn, + getActions, +}; diff --git a/src/pages/InvoiceForm.vue b/src/pages/InvoiceForm.vue index e0e4ae94..3f8b6796 100644 --- a/src/pages/InvoiceForm.vue +++ b/src/pages/InvoiceForm.vue @@ -3,6 +3,9 @@ diff --git a/src/utils.js b/src/utils.js index 4a166eb1..c27f4e49 100644 --- a/src/utils.js +++ b/src/utils.js @@ -264,4 +264,18 @@ export async function runWindowAction(name) { break; } return name; -} \ No newline at end of file +} + +export function getStatusAndColor(doc) { + let status = 'Unpaid'; + let color = 'orange'; + if (!doc.submitted) { + status = 'Draft'; + color = 'gray'; + } + if (doc.submitted === 1 && doc.outstandingAmount === 0.0) { + status = 'Paid'; + color = 'green'; + } + return { status, color }; +}