Change RO number to jobid.

This commit is contained in:
Patrick Fic
2022-05-04 18:13:21 -07:00
parent 05a8c90f03
commit 7754dc4653
10 changed files with 40 additions and 36 deletions

View File

@@ -9,15 +9,15 @@ import { FolderPaths } from "../util/serverInit";
/** @description Bills will use the hierarchy of PDFs stored under the Job first, and then the Bills folder. */
export async function BillsListMedia(req: Request, res: Response) {
const ro_number: string = (req.body.ro_number || "").trim();
const jobid: string = (req.body.jobid || "").trim();
const vendor: string = (req.body.vendor || "").trim();
const invoice_number: string = (req.body.invoice_number || "").trim();
//Ensure all directories exist.
await fs.ensureDir(PathToRoBillsFolder(ro_number));
await fs.ensureDir(PathToRoBillsFolder(jobid));
const filesList: fs.Dirent[] = (
await fs.readdir(PathToRoBillsFolder(ro_number), {
await fs.readdir(PathToRoBillsFolder(jobid), {
withFileTypes: true,
})
).filter((f) => f.isFile() && !/(^|\/)\.[^\/\.]/g.test(f.name));
@@ -25,20 +25,20 @@ export async function BillsListMedia(req: Request, res: Response) {
const ret: MediaFile[] = await Promise.all(
filesList.map(async (file) => {
const relativeThumbPath: string = await GenerateThumbnail(
path.join(PathToRoBillsFolder(ro_number), file.name)
path.join(PathToRoBillsFolder(jobid), file.name)
);
return {
src: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
ro_number,
jobid,
FolderPaths.BillsSubDir,
file.name,
]),
thumbnail: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
ro_number,
jobid,
FolderPaths.BillsSubDir,
relativeThumbPath,
]),