Private
Project *AFC ai genetic for bench sales APPFORSOLARArrow LogisticsArtificial 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 evergreenAsk RideBowls&blendsCharan Technologies _ DevelopmentEver green Farms USA (static website)Evergreen farms (pos)Evergreen React ApplicationFinwareHackthonLucky BraidsMy Produce StandNexPumpNexZen Printer AgentNoxa_JewelleryOffice Requirments » Daily Tasks For Madhu » Employees requirements » Recruitment senior mern stack developer » Red MIne Speed » Senior Mern Stack DeveloperOPT - (USA) UpdatesQA TestersRare FruitsRegal SolarRegal Solar DMRegal Solar Energy_ ReactReliance Home Builders_ reactRemit2AnyRestaurant POSRSVPRushi GardensRV_ EngraverSoloar AppSri Farms _ DMSri_FarmsSuthra OneSuthra QNova LabsTech FourceTechnical RequirementsTechy_DevelopmentTechy_POS Travel Matex
Tracker *Bug Feature Support Testing
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 ABindu DandaChandra SekharDivya InapakurthiKarthik PalakondaPavan Kumar MuralaRavi Shankar PalleRavindra AtthotaSai MahanandaSai Priyatham SadineniSowjanya atthotaSravani RangannapalemTeja Sriram SanganiYalavarthi Thriveni
Target version Sprint (10/05/2026- 10/09/2026) sprint (10/12/2026 - 10/31/2026) Backlog
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 Mahananda Sai Manikanta Sravani Phanindra
Page/ Module (POS) *--- Please select ---E2E 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 purchases - vendor invoices Admin – View Orders Admin – Offers Admin – PreOrders Admin – Coupons Admin - Delivery Configuration Maintenance – Products Maintenance – Assets Subscriptions – service Plans Subscriptions – Subscribers Subscriptions – Buy Plan Subscriptions – Share Plans Login Product Subscription E commerce Product Qoutations post job flow Expenses