-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from imkarimkarim/print-sum-cars
- Loading branch information
Showing
11 changed files
with
507 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
# DOCS | ||
|
||
<i> ⚠️ dev docs is still under development... </i> | ||
<i> ⚠️ dev docs is still in beta... </i> | ||
|
||
## core concept | ||
|
||
app has few main concepts: | ||
product, factor, customer, productOwner, car | ||
checkout the relationship between this entities [here](concept.png) | ||
|
||
## how to works | ||
## data transfer system | ||
|
||
component -> ipcRendered -> db(docs) | ||
component <- ipcRendered <- db(docs) | ||
|
||
... | ||
|
||
|
||
## electron | ||
|
||
for now goje relying on old version of packages(like electron 11) | ||
but it will upgrade to new versions soon... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react"; | ||
import { cleanTime, oneDay } from "../../utils"; | ||
import { DatePicker } from "jalali-react-datepicker"; | ||
|
||
export default function CustomeDatePicker({ search, setSearch }) { | ||
return ( | ||
<div className="searchbox-datePicker"> | ||
از تاریخ: | ||
<DatePicker | ||
timePicker={false} | ||
value={search.fromm} | ||
onClickSubmitButton={({ value }) => { | ||
setSearch({ | ||
...search, | ||
fromm: cleanTime(value._d.getTime()), | ||
}); | ||
}} | ||
/> | ||
تا تاریخ: | ||
<DatePicker | ||
timePicker={false} | ||
value={search.till} | ||
onClickSubmitButton={({ value }) => { | ||
setSearch({ | ||
...search, | ||
till: cleanTime(value._d.getTime()) + oneDay, | ||
}); | ||
}} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
src/App/Pages/Reports/PrintSumProductOwnerSelectedCars.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
const { ipcRenderer } = require("electron"); | ||
import React, { useRef, useEffect, useContext } from "react"; | ||
import { Redirect, useParams } from "react-router-dom"; | ||
import Header from "../../Components/Header.jsx"; | ||
import Footer from "../../Components/Footer.jsx"; | ||
import { NotifContext } from "../../Contexts/NotifContext.jsx"; | ||
import Expense from "../../Components/Expense.jsx"; | ||
import { Grid } from "@material-ui/core"; | ||
import html2pdf from "html2pdf.js"; | ||
import JDate from "jalali-date"; | ||
import { useState } from "react"; | ||
import Loading from "../../Components/Loading.jsx"; | ||
import ShowDate from "../../Components/ShowDate.jsx"; | ||
|
||
function SaleSection({ cars, ownerName }) { | ||
const [goBack, setGoBack] = useState(false); | ||
|
||
let fullSum = 0; | ||
for (let car of cars) { | ||
fullSum += car.ownerEarnings; | ||
} | ||
|
||
useEffect(() => { | ||
if (!goBack) { | ||
const jdate = new JDate(); | ||
const fileName = `صورتحساب های ${ownerName} - ${jdate.format( | ||
"DD MMMM YYYY" | ||
)}.pdf`; | ||
const options = { | ||
jsPDF: { format: "a5" }, | ||
filename: fileName, | ||
html2canvas: { scale: 1 }, | ||
}; | ||
html2pdf() | ||
.set(options) | ||
.from(document.body) | ||
.save() | ||
.then(() => { | ||
setGoBack(true); | ||
}); | ||
} | ||
}); | ||
|
||
return ( | ||
<div> | ||
{goBack ? ( | ||
<Redirect to="/welcome" /> | ||
) : ( | ||
<div className="sale"> | ||
<Grid container spacing={1}> | ||
<Grid className="saleInfo-table" item xs={9}> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>تاریخ ورود</th> | ||
<th>پلاک</th> | ||
<th>کد ماشین</th> | ||
<th>صافی</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{cars.map((car, index) => { | ||
return ( | ||
<tr key={index}> | ||
<td>{<ShowDate timestamp={car.arrivalDate} />}</td> | ||
<td>{car.plaque}</td> | ||
<td>{car.customeId}</td> | ||
<td>{<Expense num={car.ownerEarnings} />}</td> | ||
</tr> | ||
); | ||
})} | ||
</tbody> | ||
</table> | ||
</Grid> | ||
</Grid> | ||
<div className="owner-earning-car"> | ||
<h3> | ||
<span>مجموع صافی ها</span> | ||
<span> :</span> | ||
<span> | ||
<Expense num={fullSum} /> | ||
</span> | ||
</h3> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default function PrintSumProductOwnerSelectedCars() { | ||
const { clearNotifs } = useContext(NotifContext); | ||
let { ownerName, selectedCars } = useParams(); | ||
selectedCars = selectedCars.split(","); | ||
const init = useRef(true); | ||
|
||
const [cars, setCars] = useState(); | ||
|
||
const sumProductOwnerSelectedCars = (carIds) => { | ||
ipcRenderer.send("sumProductOwnerSelectedCars", carIds); | ||
}; | ||
|
||
useEffect(() => { | ||
if (init.current) { | ||
clearNotifs(); | ||
sumProductOwnerSelectedCars(selectedCars); | ||
init.current = false; | ||
} | ||
|
||
ipcRenderer.on("sumProductOwnerSelectedCars", (event, cars) => { | ||
setCars(cars.reverse()); | ||
}); | ||
|
||
// clean up | ||
return () => { | ||
ipcRenderer.removeAllListeners("sumProductOwnerSelectedCars"); | ||
}; | ||
}); | ||
const currentDate = new Date(new JDate()._d).getTime(); | ||
|
||
return cars && cars.length >= 2 ? ( | ||
<div> | ||
<div className="printCar"> | ||
<Header /> | ||
|
||
<div className="info"> | ||
<p className="safiTitle"> | ||
<span>صورتحساب</span> | ||
<span> </span> | ||
<span> | ||
<h3>{ownerName}</h3> | ||
</span> | ||
</p> | ||
</div> | ||
<div> | ||
<span>تاریخ گزارش</span> | ||
<span> :</span> | ||
<span> | ||
<ShowDate timestamp={currentDate} /> | ||
</span> | ||
</div> | ||
|
||
<br /> | ||
<SaleSection cars={cars} ownerName={ownerName} /> | ||
<Footer /> | ||
</div> | ||
</div> | ||
) : ( | ||
<Loading /> | ||
); | ||
} |
Oops, something went wrong.