Skip to content

Commit

Permalink
Merge branch 'release/0.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilgkrishnan committed Sep 15, 2022
2 parents baac751 + d128192 commit ba75758
Show file tree
Hide file tree
Showing 71 changed files with 404 additions and 335 deletions.
5 changes: 2 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Application Configurations
APP_BASE_URL="<Replace with app url>"

# Postgres Database config variables
DATABASE_URL="postgres://root:password@localhost/miru_web?encoding=utf8&pool=5&timeout=5000"
# You can change app base url according to your requirement
APP_BASE_URL="localhost:3000"

# Mailer Configuration
EMAIL_DELIVERY_METHOD='letter_opener'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
yarn-debug.log*
.yarn-integrity

# Rails specific ignores
/vendor/bundle

.env

# Ignore the test folder since the app is using RSpec
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ brew services start elasticsearch-full
brew install redis
```

8. Install gem
8. Install gems

```
bundle install
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/internal_api/v1/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def create
def show
authorize client
project_details = client.project_details(params[:time_frame])
client_details = { id: client.id, name: client.name, email: client.email, address: client.address }
client_details = {
id: client.id, name: client.name, email: client.email, address: client.address,
phone: client.phone
}
total_minutes = (project_details.map { |project| project[:minutes_spent] }).sum
overdue_outstanding_amount = client.client_overdue_and_outstanding_calculation
render json: { client_details:, project_details:, total_minutes:, overdue_outstanding_amount: }, status: :ok
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/common/CustomDatePicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const CustomDatePicker = ({ handleChange, dueDate }) => {
wrapperClassName="datePicker absolute"
inline
calendarClassName="miru-calendar"
selected={dueDate}
selected={Date.parse(dueDate)}
renderCustomHeader={({
date,
changeYear,
Expand Down
16 changes: 7 additions & 9 deletions app/javascript/src/components/Clients/Details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import AddEditProject from "components/Projects/Modals/AddEditProject";
import DeleteProject from "components/Projects/Modals/DeleteProject";
import { cashFormatter } from "helpers/cashFormater";
import { currencySymbol } from "helpers/currencySymbol";
import { minutesToHHMM } from "helpers/hhmm-parser";
import { sendGAPageView } from "utils/googleAnalytics";

import Header from "./Header";
Expand All @@ -22,15 +23,12 @@ import { unmapClientDetails } from "../../../mapper/client.mapper";

const getTableData = (clients) => {
if (clients) {
return clients.map((client) => {
const hours = (client.minutes/60).toFixed(2);
return {
col1: <div className="text-base text-miru-dark-purple-1000">{client.name}</div>,
col2: <div className="text-base text-miru-dark-purple-1000">{client.team.map(member => <span>{member},&nbsp;</span>)}</div>,
col3: <div className="text-base text-miru-dark-purple-1000 text-right">{hours}</div>,
rowId: client.id
};
});
return clients.map((client) => ({
col1: <div className="text-base text-miru-dark-purple-1000">{client.name}</div>,
col2: <div className="text-base text-miru-dark-purple-1000">{client.team.map(member => <span>{member},&nbsp;</span>)}</div>,
col3: <div className="text-base text-miru-dark-purple-1000 text-right">{minutesToHHMM(client.minutes)}</div>,
rowId: client.id
}));
}
return [{}];
};
Expand Down
16 changes: 7 additions & 9 deletions app/javascript/src/components/Clients/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ChartBar from "common/ChartBar";
import Table from "common/Table";
import { cashFormatter } from "helpers/cashFormater";
import { currencySymbol } from "helpers/currencySymbol";
import { minutesToHHMM } from "helpers/hhmm-parser";
import { sendGAPageView } from "utils/googleAnalytics";

import Header from "./Header";
Expand All @@ -23,15 +24,12 @@ import NewClient from "../Modals/NewClient";

const getTableData = (clients) => {
if (clients) {
return clients.map((client) => {
const hours = (client.minutes / 60).toFixed(2);
return {
col1: <div className="text-base text-miru-dark-purple-1000">{client.name}</div>,
col2: <div className="text-base text-miru-dark-purple-1000 text-right">{client.email}</div>,
col3: <div className="text-base text-miru-dark-purple-1000 text-right">{hours}</div>,
rowId: client.id
};
});
return clients.map((client) => ({
col1: <div className="text-base text-miru-dark-purple-1000">{client.name}</div>,
col2: <div className="text-base text-miru-dark-purple-1000 text-right">{client.email}</div>,
col3: <div className="text-base text-miru-dark-purple-1000 text-right">{minutesToHHMM(client.minutes)}</div>,
rowId: client.id
}));
}
return [{}];
};
Expand Down
10 changes: 5 additions & 5 deletions app/javascript/src/components/Clients/Modals/EditClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import clientApi from "apis/clients";
const newClientSchema = Yup.object().shape({
name: Yup.string().required("Name cannot be blank"),
email: Yup.string().email("Invalid email ID").required("Email ID cannot be blank"),
phoneNo: Yup.number().typeError("Invalid phone number"),
phone: Yup.number().typeError("Invalid phone number"),
address: Yup.string().required("Address cannot be blank")
});

Expand All @@ -29,7 +29,7 @@ export interface IEditClient {
interface FormValues {
name: string;
email: string;
phoneNo: string;
phone: string;
address: string;
}

Expand Down Expand Up @@ -110,13 +110,13 @@ const EditClient = ({ setShowEditDialog, client }: IEditClient) => {
<div className="field_with_errors">
<label className="form__label">Phone number</label>
<div className="tracking-wider block text-xs text-red-600">
{errors.phoneNo && touched.phoneNo &&
<div>{errors.phoneNo}</div>
{errors.phone && touched.phone &&
<div>{errors.phone}</div>
}
</div>
</div>
<div className="mt-1">
<Field className={`form__input ${errors.phoneNo && touched.phoneNo && "border-red-600 focus:ring-red-600 focus:border-red-600"} `} name="phoneNo" />
<Field className={`form__input ${errors.phone && touched.phone && "border-red-600 focus:ring-red-600 focus:border-red-600"} `} name="phone" />
</div>
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions app/javascript/src/components/Clients/Modals/NewClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import Toastr from "common/Toastr";
const newClientSchema = Yup.object().shape({
name: Yup.string().required("Name cannot be blank"),
email: Yup.string().email("Invalid email ID").required("Email ID cannot be blank"),
phoneNo: Yup.number().typeError("Invalid phone number"),
phone: Yup.number().typeError("Invalid phone number"),
address: Yup.string().required("Address cannot be blank")
});

const initialValues = {
name: "",
email: "",
phoneNo: "",
phone: "",
address: ""
};

interface FormValues {
name: string;
email: string;
phoneNo: string;
phone: string;
address: string;
}

Expand Down Expand Up @@ -98,13 +98,13 @@ const EditClient = ({ setnewClient, clientData, setClientData }) => {
<div className="field_with_errors">
<label className="form__label">Phone number</label>
<div className="tracking-wider block text-xs text-red-600">
{errors.phoneNo && touched.phoneNo &&
<div>{errors.phoneNo}</div>
{errors.phone && touched.phone &&
<div>{errors.phone}</div>
}
</div>
</div>
<div className="mt-1">
<Field className={`form__input ${errors.phoneNo && touched.phoneNo && "border-red-600 focus:ring-red-600 focus:border-red-600"} `} name="phoneNo" />
<Field className={`form__input ${errors.phone && touched.phone && "border-red-600 focus:ring-red-600 focus:border-red-600"} `} name="phone" />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ const InvoiceTotalSummary = ({ invoice, company, lineItems }) => {
Sub total
</td>
<td className="font-bold text-base text-miru-dark-purple-1000 text-right ">
{parseFloat(subTotal).toFixed(2)}
{currencyFormat({ baseCurrency: company.base_currency, amount: parseFloat(subTotal).toFixed(2) })}
</td>
</tr>
<tr
className="pb-5 border-b-2 miru-gray-400 ">
<td className="py-2 pr-10 font-normal text-base text-miru-dark-purple-1000 text-right pr-10">
Discount
</td>
<td className="font-bold text-base text-miru-dark-purple-1000 text-right ">{parseFloat(discount).toFixed(2)}</td>
<td className="font-bold text-base text-miru-dark-purple-1000 text-right ">
{currencyFormat({ baseCurrency: company.base_currency, amount: parseFloat(discount).toFixed(2) })}
</td>
</tr>
<tr>
<td className="pt-4 font-normal text-base text-miru-dark-purple-1000 text-right pr-10">
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/components/Invoices/Edit/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Header = ({ invoiceNumber, id, updateInvoice }) => (
<button
type="button"
className="header__button bg-miru-han-purple-1000 text-white w-1/3 p-0 hover:text-white"
onClick={() => { updateInvoice();}}
onClick={updateInvoice}
data-cy='save-invoice-edit'
>
<FloppyDisk size={18} color="white" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const NewLineItemTable = ({
}) => {

const selectRowId = (item) => {
const option = { ...item, lineTotal: (Number(item.qty)/60 * Number(item.rate)) };
const option = { ...item, lineTotal: (Number(item.quantity)/60 * Number(item.rate)).toFixed(2) };
const newLineItems = [...lineItems];
newLineItems.splice(item.key, 1);

Expand Down
5 changes: 3 additions & 2 deletions app/javascript/src/components/Invoices/Edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const EditInvoice = () => {
const [dueDate, setDueDate] = useState();

const addKeyToLineItems = items => (
items.map((item, index) => {
items?.map((item, index) => {
item["key"] = index;
return item;
})
Expand All @@ -50,6 +50,7 @@ const EditInvoice = () => {
setSelectedLineItems(unmapLineItems(res.data.invoiceLineItems));
setLineItems(addKeyToLineItems(res.data.lineItems));
setAmount(res.data.amount);
setInvoiceNumber(res.data.invoiceNumber);
setDiscount(res.data.discount);
setSelectedClient(res.data.client);
setAmountDue(res.data.amountDue);
Expand Down Expand Up @@ -125,7 +126,7 @@ const EditInvoice = () => {
setDueDate={setDueDate}
issueDate={issueDate || invoiceDetails.issueDate}
setIssueDate={setIssueDate}
invoiceNumber={invoiceNumber || invoiceDetails.invoiceNumber}
invoiceNumber={invoiceNumber}
setInvoiceNumber={setInvoiceNumber}
reference={reference}
optionSelected={true}
Expand Down
18 changes: 9 additions & 9 deletions app/javascript/src/components/Invoices/Generate/ManualEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ManualEntry = ({
const [date, setDate] = useState<string>("");
const [description, setDescription] = useState<string>("");
const [rate, setRate] = useState<any>("");
const [qty, setQty] = useState<any>("");
const [quantity, setQuantity] = useState<any>("");
const [lineTotal, setLineTotal] = useState<any>(entry.lineTotal ? entry.lineTotal : 0);
const [lineItem, setLineItem] = useState<any>({});
const ref = useRef();
Expand All @@ -25,11 +25,11 @@ const ManualEntry = ({
date,
description,
rate,
qty: qty,
lineTotal: (Number(qty) * Number(rate)).toFixed(2)
quantity,
lineTotal: (Number(quantity) * Number(rate)).toFixed(2)
});
}
}, [name, date, description, rate, qty, lineTotal]);
}, [name, date, description, rate, quantity, lineTotal]);

useEffect(() => {
const newManualEntryArr = manualEntryArr.map((option) => {
Expand Down Expand Up @@ -95,19 +95,19 @@ const ManualEntry = ({
value={entry.rate}
onChange={e => {
setRate(e.target.value);
setLineTotal(Number(e.target.value) * Number(qty));
setLineTotal(Number(e.target.value) * Number(quantity));
}}
/>
</td>
<td className="p-1 w-full">
<input
type="text"
placeholder="Qty"
placeholder="quantity"
className=" p-1 px-2 bg-white rounded w-full font-medium text-sm text-miru-dark-purple-1000 text-right focus:outline-none focus:border-miru-gray-1000 focus:ring-1 focus:ring-miru-gray-1000"
defaultValue={entry.qty}
value={entry.qty}
defaultValue={entry.quantity}
value={entry.quantity}
onChange={e => {
setQty(e.target.value);
setQuantity(e.target.value);
setLineTotal(Number(rate) * Number(e.target.value));
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React from "react";
import dayjs from "dayjs";
import InfiniteScroll from "react-infinite-scroll-component";

import { minutesToHHMM } from "helpers/hhmm-parser";

import { DropdownHeader } from "./CustomComponents";

import { getMaxIdx } from "../common/utils";
Expand All @@ -24,7 +26,7 @@ const NewLineItemTable = ({

const hasMoreItems = lineItems.length === totalLineItems;
const selectRowId = (items) => {
const option = { ...items, lineTotal: (Number(items.qty) / 60 * Number(items.rate)) };
const option = { ...items, lineTotal: (Number(items.quantity) / 60 * Number(items.rate)).toFixed(2) };
setAddNew(false);
setSelectedOption([...selectedOption, option]);
setLineItems([]);
Expand Down Expand Up @@ -60,14 +62,14 @@ const NewLineItemTable = ({
}
>
{lineItems.map((item, index) => {
const hoursLogged = (item.qty / 60).toFixed(2);
const hoursLogged = minutesToHHMM(item.quantity);
const date = dayjs(item.date).format("DD.MM.YYYY");
return (
<div key={index} onClick={() => { selectRowId(item); }} className="py-2 px-3 flex justify-between cursor-pointer hover:bg-miru-gray-100" data-cy="entries-list">
<span className="font-medium w-1/4 text-base text-miru-dark-purple-1000 text-left">
{item.first_name} {item.last_name}
</span>
<span className="font-medium w-2/4 text-xs text-miru-dark-purple-600 text-left w-1/2">
<span className="font-medium text-xs text-miru-dark-purple-600 text-left w-1/2">
{item.description}
</span>
<span className="font-medium text-xs text-miru-dark-purple-1000 text-center">
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/src/components/Invoices/Invoice/LineItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";
import dayjs from "dayjs";

import { currencyFormat } from "helpers/currency";
import { minutesToHHMM } from "helpers/hhmm-parser";

const LineItem = ({ currency, item }) => {
const date = dayjs(item.date).format("DD-MM-YYYY");
Expand All @@ -22,7 +23,7 @@ const LineItem = ({ currency, item }) => {
{currencyFormat({ baseCurrency: currency, amount: item.rate })}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-right ">
{(item.quantity / 60).toFixed(2)}
{minutesToHHMM(item.quantity)}
</td>
<td className="border-b-2 border-miru-gray-200 px-1 py-3 font-normal text-base text-miru-dark-purple-1000 text-right ">
{currencyFormat({ baseCurrency: currency, amount: ((item.quantity / 60) * item.rate).toFixed(2) })}
Expand Down
6 changes: 2 additions & 4 deletions app/javascript/src/components/Invoices/List/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as React from "react";
import { ApiStatus as InvoiceStatus } from "constants/index";

import {
Funnel,
MagnifyingGlass,
Plus,
Trash,
Expand All @@ -18,7 +17,6 @@ import useDebounce from "helpers/debounce";
import SearchDropdown from "./InvoiceSearch/SearchDropdown";

const Header = ({
setFilterVisibilty,
isInvoiceSelected,
selectedInvoiceCount,
clearCheckboxes,
Expand Down Expand Up @@ -95,9 +93,9 @@ const Header = ({
</div>
</div>

<button className="ml-7" onClick={() => setFilterVisibilty(true)}>
{/* <button className="ml-7" onClick={() => setFilterVisibilty(true)}>
<Funnel size={16} />
</button>
</button> */}
</div>

<div className="flex">
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/components/Invoices/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const Invoices: React.FC = () => {
<Header
params={params}
setParams={setParams}
setFilterVisibilty={setFilterVisibilty}
// setFilterVisibilty={setFilterVisibilty}
clearCheckboxes={() =>
deselectInvoices(invoices.map((invoice) => invoice.id))
}
Expand Down
Loading

0 comments on commit ba75758

Please sign in to comment.