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

@@ -7,7 +7,7 @@ export default function BillRequestValidator(
) {
const vendor: string = (req.body.vendor || "").trim();
const invoice_number: string = (req.body.invoice_number || "").trim();
const ro_number: string = (req.body.ro_number || "").trim();
const jobid: string = (req.body.jobid || "").trim();
// if (vendor === "") {
// res.status(400).json({ error: "No vendor name has been specified." });
@@ -17,7 +17,7 @@ export default function BillRequestValidator(
// res.status(400).json({ error: "No invoice number has been specified." });
// return;
// }
if (ro_number === "") {
if (jobid === "") {
res.status(400).json({ error: "No RO Number has been specified." });
return;
} else {

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,
]),

View File

@@ -21,8 +21,8 @@ dotenv.config({
export const BillsMediaUploadMulter = multer({
storage: multer.diskStorage({
destination: function (req, file, cb) {
const ro_number: string = (req.body.ro_number || "").trim();
const DestinationFolder: string = PathToRoBillsFolder(ro_number);
const jobid: string = (req.body.jobid || "").trim();
const DestinationFolder: string = PathToRoBillsFolder(jobid);
fs.ensureDirSync(DestinationFolder);
cb(null, DestinationFolder);
},