Skip to content

Commit

Permalink
Change partly received to partially received
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush-goyal committed Jul 23, 2020
1 parent 8f33493 commit eb3d9ef
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
18 changes: 18 additions & 0 deletions expenses/migrations/0027_auto_20200720_1213.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.7 on 2020-07-20 16:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('expenses', '0026_auto_20200715_2306'),
]

operations = [
migrations.AlterField(
model_name='requisition',
name='status',
field=models.CharField(choices=[('Draft', 'Draft'), ('Submitted', 'Submitted'), ('Pending Changes', 'Pending Changes'), ('Ready to Order', 'Ready to Order'), ('Ordered', 'Ordered'), ('Partially Received', 'Partially Received'), ('Received', 'Received'), ('Closed', 'Closed'), ('Cancelled', 'Cancelled')], default='Draft', max_length=50),
),
]
4 changes: 2 additions & 2 deletions expenses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RequisitionStatus(models.Model):
PENDING_CHANGES = "Pending Changes"
READY_TO_ORDER = "Ready to Order"
ORDERED = "Ordered"
PARTLY_RECEIVED = "Partly Received"
PARTIALLY_RECEIVED = "Partially Received"
RECEIVED = "Received"
CLOSED = "Closed"
CANCELLED = "Cancelled"
Expand All @@ -34,7 +34,7 @@ class RequisitionStatus(models.Model):
(PENDING_CHANGES, PENDING_CHANGES),
(READY_TO_ORDER, READY_TO_ORDER),
(ORDERED, ORDERED),
(PARTLY_RECEIVED, PARTLY_RECEIVED),
(PARTIALLY_RECEIVED, PARTIALLY_RECEIVED),
(RECEIVED, RECEIVED),
(CLOSED, CLOSED),
(CANCELLED, CANCELLED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ type RequisitionItemRow = RequisitionItem & { isNotesRow: boolean }

const ItemsTableSection: React.FC<RequisitionSectionProps> = (props) => {
const { data, loading } = props;

// Boolean determines whether to show green highlights and table footer
const showReceived = data.status === "PARTIALLY_RECEIVED";
const greenColor = "#f6ffed";

const columns = [
{
Expand All @@ -21,7 +25,7 @@ const ItemsTableSection: React.FC<RequisitionSectionProps> = (props) => {
children: <Text>{record.notes}</Text>,
props: {
colSpan: 3,
style: { background: record.received && data.status === "PARTLY_RECEIVED" ? "#f6ffed" : "" }
style: { background: record.received && showReceived ? greenColor : "" }
}
};
}
Expand All @@ -31,7 +35,7 @@ const ItemsTableSection: React.FC<RequisitionSectionProps> = (props) => {
return {
children: <Link href={record.link} target="_blank">{record.name}</Link>,
props: {
style: { background: record.received && data.status === "PARTLY_RECEIVED" ? "#f6ffed" : "" }
style: { background: record.received && showReceived ? greenColor : "" }
}
};
}
Expand All @@ -52,7 +56,7 @@ const ItemsTableSection: React.FC<RequisitionSectionProps> = (props) => {
return {
children: `${record.quantity} @ ${formatPrice(record.unitPrice)}`,
props: {
style: { background: record.received && data.status === "PARTLY_RECEIVED" ? "#f6ffed" : "" }
style: { background: record.received && showReceived ? greenColor : "" }
}
};
}
Expand All @@ -70,7 +74,7 @@ const ItemsTableSection: React.FC<RequisitionSectionProps> = (props) => {
return {
children: formatPrice(record.quantity * record.unitPrice),
props: {
style: { background: record.received && data.status === "PARTLY_RECEIVED" ? "#f6ffed" : "" }
style: { background: record.received && showReceived ? greenColor : "" }
}
};
}
Expand All @@ -94,7 +98,7 @@ const ItemsTableSection: React.FC<RequisitionSectionProps> = (props) => {
size="small"
bordered
scroll={{ x: true }}
footer={data.status === "PARTLY_RECEIVED" ? () => <em>* Items in green have been received</em> : undefined}
footer={showReceived ? () => <em>* Items in green have been received</em> : undefined}
summary={() => (loading ? null
: (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ManageStatusSection: React.FC<RequisitionSectionProps> = (props) => {
case "READY_TO_ORDER":
return <ReadyToOrderExpense requisition={data} />;
case "ORDERED":
case "PARTLY_RECEIVED":
case "PARTIALLY_RECEIVED":
return <OrderedExpense requisition={data} />;
case "RECEIVED":
return <ReceivedExpense requisition={data} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const OrderedExpense: React.FC<RequisitionExpenseSectionProps> = (props) => {
} else if (numReceived === Object.keys(values).length) {
status = "RECEIVED";
} else {
status = "PARTLY_RECEIVED";
status = "PARTIALLY_RECEIVED";
}

const mutationData = {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types/Requisition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type RequisitionStatus =
"PENDING_CHANGES" |
"READY_TO_ORDER" |
"ORDERED" |
"PARTLY_RECEIVED" |
"PARTIALLY_RECEIVED" |
"RECEIVED" |
"CLOSED" |
"CANCELLED";
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const StatusToColor = (status: RequisitionStatus): PresetColorType | unde
case "PENDING_CHANGES": return "orange";
case "READY_TO_ORDER": return "green";
case "ORDERED": return "blue";
case "PARTLY_RECEIVED": return "purple";
case "PARTIALLY_RECEIVED": return "purple";
case "RECEIVED": return "purple";
case "CLOSED": return undefined;
case "CANCELLED": return "red";
Expand All @@ -26,7 +26,7 @@ export const StatusToString = (status: RequisitionStatus) => {
case "PENDING_CHANGES": return "Pending Changes";
case "READY_TO_ORDER": return "Ready to Order";
case "ORDERED": return "Ordered";
case "PARTLY_RECEIVED": return "Partly Received";
case "PARTIALLY_RECEIVED": return "Partially Received";
case "RECEIVED": return "Received";
case "CLOSED": return "Closed";
case "CANCELLED": return "Cancelled";
Expand All @@ -41,7 +41,7 @@ export const StatusToStep = (status: RequisitionStatus) => {
case "PENDING_CHANGES": return 0;
case "READY_TO_ORDER": return 2;
case "ORDERED": return 3;
case "PARTLY_RECEIVED": return 3;
case "PARTIALLY_RECEIVED": return 3;
case "RECEIVED": return 4;
case "CLOSED": return 5;
case "CANCELLED": return -1;
Expand Down

0 comments on commit eb3d9ef

Please sign in to comment.