Private
Project *AFC Artificial Intillegence » Algo Trade Automation » Algo Trade Manual » Bulk mail Automation with web interface » Bulk Mail Service For Bench Sales » Code Generation Tool » Cold Emailing Automation (AI-Driven) » Invoice Inventory Automation » invoice to inventory for evergreen » Test Automation » What's app Bulk messaging with AI agents » Zelle Payment for evergreenCharan Technologies _ DevelopmentEver green Farms USA (static website)Evergreen farms (pos)Evergreen React ApplicationHackthonIT HappENSLucky BraidsMy Produce StandOffice Requirments » Daily Tasks For Madhu » Employees requirements » Recruitment senior mern stack developer » Red MIne Speed » Senior Mern Stack DeveloperQA TestersRare FruitsRegal SolarRegal Solar DMRegal Solar Energy_ ReactReliance Home Builders_ reactRemit2AnyRestaurant POSRSVPRV_ EngraverSri Farms _ DMSri_FarmsTech FourceTechnical RequirementsTechy_DevelopmentTravel Mate
Tracker *Bug Feature Support
Subject *
Description Edit 1. Single Responsibility Principle This controller is handling too many responsibilities: Input validation Loading DB models Fetching & updating quotation Handling action history Creating invoice Sending emails Generating JWT Building API response Each of these should be broken into separate service functions. 2. Move Validation Logic to Middleware / Utility Current code validates status, signature, etc. inline. Better: have a validation middleware so your controller stays clean. validateAcceptQuotation(req, res, next) { // Validate status and signature rules here } 3.Error Handling Many try/catch blocks inline → clutter. Use a global error handler middleware (like we discussed earlier with CustomError). Instead of returning inline 400/500, just throw new CustomError(...) and let middleware handle the response. 4.Split Business Logic Into Services ->Create QuotationService for: findByToken(token) updateQuotationStatus(quotation, status, signature, haveAquestion) addActionHistory(quotation, changes, performedBy) ->Create InvoiceService for: createInvoiceFromQuotation(quotation) sendInvoiceEmail(invoice, client) ->Create EmailService for: sendQuotationStatusEmail(quotation, status, invoice) In controller we can use above like this const quotation = await QuotationService.findByToken(token); QuotationService.updateStatus(quotation, status, signature, haveAquestion); if (status === "accepted") { const invoice = await InvoiceService.createInvoiceFromQuotation(quotation); await InvoiceService.sendInvoiceEmail(invoice, quotation.client); } await QuotationService.save(quotation); await EmailService.sendQuotationStatusEmail(quotation, status, invoice); 5. Avoid Deep Nesting Right now you have deeply nested if/else + try/catch. Early return on errors (✅ you already do this a bit). But some blocks like invoice creation could be moved into a helper. 6. Template/Email Duplication Email template rendering code (ejs.renderFile(...), attachments, options) is repeated. Extract into EmailService utility:EmailService.sendTemplate(to, subject, templateName, data, attachments); 7. Magic Strings → Constants "accepted", "inProgress", "completed", "drafted" should be constants or enums. Prevents typos and makes it reusable. 8. Token/Invoice Handling JWT generation inline makes the controller noisy. Move to AuthService.generateQuotationToken(payload). 9. Response Building Right now, building res.status(200).json({...}) is verbose. Extract into a helper function Response.success(res, data, message). Benefits to apply above cases in your current code style Controller is now ~50 lines, not 300. Easier to read & test. Business logic reusable in other places (e.g., CRON jobs, API v2). Errors are centralized. Email sending is abstracted.
Status New
Priority *Low Normal High Immediate
Assignee Ajit AChandra SekharDivya Inapakurthighazala shamimJohn PatchalaKalyan RavulaKarthik PalakondaMadhu BabuMani KantaPavan Kumar MuralaRamu KodaliRavi Shankar PalleRavindra AtthotaRubanraj cSai MahanandaSai Priyatham SadineniSai Teja PopuriSravani RangannapalemSreenivas PisupatiTeja Sriram SanganiThirupathirao Uppuvinay palakondaYalavarthi Thriveni
Target version Sprint (product subscription & deliverable pre- orders) Backlog Sprint2
Parent task
Start date
Due date
Estimated time Hours
% Done0 % 10 % 20 % 30 % 40 % 50 % 60 % 70 % 80 % 90 % 100 %
Tested Date *
Raised by Tester *--- Please select ---Mahananda Sai Manikanta Sravani Phanindra
Page/ Module (POS) *--- Please select ---Dashboard POS Customers Requests Quotes Invoices Jobs Users Partners Labor Field Staff Events Warehouse Featured Items Help Guide Services – Categories Services – Services Products – Categories Products – Sub Categories Products – Products Assets – Categories Assets – Assets Assets – Usage Sales Sales Return Purchases – Vendors Admin – View Orders Admin – Offers Admin – PreOrders Admin – Coupons Maintenance – Products Maintenance – Assets Subscriptions – Plans Subscriptions – Subscribers Login Product Subscription E commerce