mirror of
https://github.com/frappe/books.git
synced 2026-08-24 10:04:45 -05:00
Merge pull request #1236 from suhailanzar/status-colors
fix: updated invoice status and colors
This commit is contained in:
+16
-4
@@ -367,16 +367,17 @@ export const statusColor: Record<
|
|||||||
Opportunity: 'yellow',
|
Opportunity: 'yellow',
|
||||||
Unpaid: 'orange',
|
Unpaid: 'orange',
|
||||||
Paid: 'green',
|
Paid: 'green',
|
||||||
|
PartlyPaid: 'yellow',
|
||||||
Interested: 'yellow',
|
Interested: 'yellow',
|
||||||
Converted: 'green',
|
Converted: 'green',
|
||||||
Quotation: 'green',
|
Quotation: 'green',
|
||||||
Saved: 'gray',
|
Saved: 'blue',
|
||||||
NotSaved: 'gray',
|
NotSaved: 'gray',
|
||||||
Submitted: 'green',
|
Submitted: 'green',
|
||||||
Cancelled: 'red',
|
Cancelled: 'red',
|
||||||
DonotContact: 'red',
|
DonotContact: 'red',
|
||||||
Return: 'green',
|
Return: 'lime',
|
||||||
ReturnIssued: 'green',
|
ReturnIssued: 'lime',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getStatusText(status: DocStatus | InvoiceStatus): string {
|
export function getStatusText(status: DocStatus | InvoiceStatus): string {
|
||||||
@@ -395,6 +396,8 @@ export function getStatusText(status: DocStatus | InvoiceStatus): string {
|
|||||||
return t`Paid`;
|
return t`Paid`;
|
||||||
case 'Unpaid':
|
case 'Unpaid':
|
||||||
return t`Unpaid`;
|
return t`Unpaid`;
|
||||||
|
case 'PartlyPaid':
|
||||||
|
return t`Partly Paid`;
|
||||||
case 'Return':
|
case 'Return':
|
||||||
return t`Return`;
|
return t`Return`;
|
||||||
case 'ReturnIssued':
|
case 'ReturnIssued':
|
||||||
@@ -511,7 +514,7 @@ export function getInvoiceStatus(doc: RenderData | Doc): InvoiceStatus {
|
|||||||
if (
|
if (
|
||||||
doc.submitted &&
|
doc.submitted &&
|
||||||
!doc.cancelled &&
|
!doc.cancelled &&
|
||||||
(doc.outstandingAmount as Money).isPositive()
|
(doc.outstandingAmount as Money).eq(doc.grandTotal as Money)
|
||||||
) {
|
) {
|
||||||
return 'Unpaid';
|
return 'Unpaid';
|
||||||
}
|
}
|
||||||
@@ -520,6 +523,15 @@ export function getInvoiceStatus(doc: RenderData | Doc): InvoiceStatus {
|
|||||||
return 'Cancelled';
|
return 'Cancelled';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
doc.submitted &&
|
||||||
|
!doc.isCancelled &&
|
||||||
|
(doc.outstandingAmount as Money).isPositive() &&
|
||||||
|
(doc.outstandingAmount as Money).neq(doc.grandTotal as Money)
|
||||||
|
) {
|
||||||
|
return 'PartlyPaid';
|
||||||
|
}
|
||||||
|
|
||||||
return 'Saved';
|
return 'Saved';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -5,7 +5,9 @@ export type InvoiceStatus =
|
|||||||
| 'Cancelled'
|
| 'Cancelled'
|
||||||
| 'Paid'
|
| 'Paid'
|
||||||
| 'Return'
|
| 'Return'
|
||||||
| 'ReturnIssued';
|
| 'ReturnIssued'
|
||||||
|
| 'Unpaid'
|
||||||
|
| 'PartlyPaid';
|
||||||
|
|
||||||
export enum ModelNameEnum {
|
export enum ModelNameEnum {
|
||||||
Account = 'Account',
|
Account = 'Account',
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import { Doc } from 'fyo/model/doc';
|
|||||||
import { isPesa } from 'fyo/utils';
|
import { isPesa } from 'fyo/utils';
|
||||||
import { Invoice } from 'models/baseModels/Invoice/Invoice';
|
import { Invoice } from 'models/baseModels/Invoice/Invoice';
|
||||||
import { Party } from 'models/baseModels/Party/Party';
|
import { Party } from 'models/baseModels/Party/Party';
|
||||||
|
import { Money } from 'pesa';
|
||||||
import { getBgTextColorClass } from 'src/utils/colors';
|
import { getBgTextColorClass } from 'src/utils/colors';
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
|
|
||||||
type Status = ReturnType<typeof getStatus>;
|
type Status = ReturnType<typeof getStatus>;
|
||||||
type UIColors = 'gray' | 'orange' | 'red' | 'green' | 'blue';
|
type UIColors = 'gray' | 'orange' | 'red' | 'green' | 'blue' | 'yellow';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
props: { doc: { type: Doc, required: true } },
|
props: { doc: { type: Doc, required: true } },
|
||||||
@@ -23,14 +24,20 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
text() {
|
text() {
|
||||||
const hasOutstanding = isPesa(this.doc.outstandingAmount);
|
const hasOutstanding = isPesa(this.doc.outstandingAmount);
|
||||||
if (hasOutstanding && this.status === 'Outstanding') {
|
|
||||||
|
if (hasOutstanding && this.status === 'Unpaid') {
|
||||||
const amt = this.fyo.format(this.doc.outstandingAmount, 'Currency');
|
const amt = this.fyo.format(this.doc.outstandingAmount, 'Currency');
|
||||||
return this.t`Unpaid ${amt}`;
|
return this.t`Unpaid ${amt}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.doc instanceof Invoice && this.status === 'NotTransferred') {
|
if (hasOutstanding && this.status === 'PartlyPaid') {
|
||||||
const amt = this.fyo.format(this.doc.stockNotTransferred, 'Float');
|
const outstandingPayment = this.fyo.format(
|
||||||
return this.t`Pending Qty. ${amt}`;
|
(this.doc.grandTotal as Money).sub(
|
||||||
|
this.doc.outstandingAmount as Money
|
||||||
|
),
|
||||||
|
'Currency'
|
||||||
|
);
|
||||||
|
return this.t`Partly Paid ${outstandingPayment}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -45,6 +52,8 @@ export default defineComponent({
|
|||||||
Submitted: this.t`Submitted`,
|
Submitted: this.t`Submitted`,
|
||||||
Return: this.t`Return`,
|
Return: this.t`Return`,
|
||||||
ReturnIssued: this.t`Return Issued`,
|
ReturnIssued: this.t`Return Issued`,
|
||||||
|
Unpaid: this.t`Unpaid`,
|
||||||
|
PartlyPaid: this.t`Partly Paid`,
|
||||||
}[this.status];
|
}[this.status];
|
||||||
},
|
},
|
||||||
color(): UIColors {
|
color(): UIColors {
|
||||||
@@ -63,8 +72,10 @@ const statusColorMap: Record<Status, UIColors> = {
|
|||||||
Paid: 'green',
|
Paid: 'green',
|
||||||
Saved: 'blue',
|
Saved: 'blue',
|
||||||
Submitted: 'blue',
|
Submitted: 'blue',
|
||||||
Return: 'green',
|
Return: 'gray',
|
||||||
ReturnIssued: 'green',
|
ReturnIssued: 'gray',
|
||||||
|
Unpaid: 'red',
|
||||||
|
PartlyPaid: 'yellow',
|
||||||
};
|
};
|
||||||
|
|
||||||
function getStatus(doc: Doc) {
|
function getStatus(doc: Doc) {
|
||||||
@@ -101,13 +112,6 @@ function getSubmittableStatus(doc: Doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isInvoice = doc instanceof Invoice;
|
const isInvoice = doc instanceof Invoice;
|
||||||
if (
|
|
||||||
doc.isSubmitted &&
|
|
||||||
isInvoice &&
|
|
||||||
doc.outstandingAmount?.isZero() !== true
|
|
||||||
) {
|
|
||||||
return 'Outstanding';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doc.isSubmitted && isInvoice && (doc.stockNotTransferred ?? 0) > 0) {
|
if (doc.isSubmitted && isInvoice && (doc.stockNotTransferred ?? 0) > 0) {
|
||||||
return 'NotTransferred';
|
return 'NotTransferred';
|
||||||
@@ -121,6 +125,33 @@ function getSubmittableStatus(doc: Doc) {
|
|||||||
return 'Paid';
|
return 'Paid';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
doc.isSubmitted &&
|
||||||
|
isInvoice &&
|
||||||
|
!doc.isCancelled &&
|
||||||
|
(doc.outstandingAmount as Money)?.isPositive() &&
|
||||||
|
(doc.outstandingAmount as Money)?.neq(doc.grandTotal as Money)
|
||||||
|
) {
|
||||||
|
return 'PartlyPaid';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
doc.isSubmitted &&
|
||||||
|
isInvoice &&
|
||||||
|
!doc.isCancelled &&
|
||||||
|
(doc.outstandingAmount as Money)?.eq(doc.grandTotal as Money)
|
||||||
|
) {
|
||||||
|
return 'Unpaid';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
doc.isSubmitted &&
|
||||||
|
isInvoice &&
|
||||||
|
doc.outstandingAmount?.isZero() !== true
|
||||||
|
) {
|
||||||
|
return 'Outstanding';
|
||||||
|
}
|
||||||
|
|
||||||
if (doc.isSubmitted) {
|
if (doc.isSubmitted) {
|
||||||
return 'Submitted';
|
return 'Submitted';
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ const getValidColor = (color: string) => {
|
|||||||
|
|
||||||
export function getBgColorClass(color: string) {
|
export function getBgColorClass(color: string) {
|
||||||
const vcolor = getValidColor(color);
|
const vcolor = getValidColor(color);
|
||||||
return `bg-${vcolor}-200 dark:bg-${vcolor}-700`;
|
return `bg-${vcolor}-200 dark:bg-${vcolor}-800`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getColorClass(
|
export function getColorClass(
|
||||||
|
|||||||
Reference in New Issue
Block a user