Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Show changed files | Directory listing | RSS feed

Filtering Options

Rev Age Author Path Log message Diff
36427 7 d 2 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/inventory/ rejectReturn: simplify to cancel-the-request semantics

After the receive/refund refactor, applyReceipt — and therefore every
warehouse-side effect (SALE_RET scans, WarehouseInventoryItem.addQuantity,
InventoryItem.returnTimestamp, ReturnOrderInfo, Order.status flip,
lineItem.returnQty) — only runs from refundOrder (or its inline
auto-approve sibling in submitReceiptForApproval). Both paths set
pro.refundTimestamp in the same transaction, all-or-nothing under
@Transactional(rollbackFor=Exception.class).

The refund_timestamp guard at the top of rejectReturn blocks rejection
once any of that has fired, which means rejectReturn is now ONLY
callable on a pending PRO — a state where applyReceipt has never run
and there is nothing on the warehouse side to undo.

The pre-existing reversal pipeline (warehouse-scan -1 reversal scans,
ReturnOrderInfo update/create-with-REJECTED, Order.status flip back to
DELIVERY_SUCCESS, lineItem.returnQty decrement) was therefore operating
against state that doesn't exist:
- lastScanType is SALE (from original sale), not SALE_RET, so
addQuantity(-1) gate correctly skipped — but the unconditional
persist of WarehouseScan(qty=-1, type=SALE_RET) was creating
fake reversal rows for receipts that never happened.
- selectByOrderId for ReturnOrderInfo always returned empty
(refundOrder is the only writer), and the no-rows branch was
fabricating REJECTED ROI rows for returns that were never received.
- Order.status was never flipped to COMPLETE_RETURN, so the
DELIVERY_SUCCESS reversal block correctly skipped — pure dead
branch.

Strip all of it. rejectReturn is now: guards (refund/reject timestamps),
stamp PRO with reject_timestamp/remark/updatedBy, restoreReturnedItems
to undo the partner-side effects from generateDebitNote(), mark items
REJECTED so a fresh re-request is possible.

This also undoes the previous fix #5 (extending the warehouse-scan
reversal to non-serialized) — that fix was making things worse by
creating fake reversal rows for both serialized and non-serialized
items instead of just serialized. The right answer was to delete the
whole block, not extend it.
 
36426 7 d 3 h amit /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/v2/controller/fofo/ V2 /return/invoice GET: parity with FOFO controller's date filter

Was using selectRecentByWarehouseIds(..., 20) — no date filter, hard cap
at 20. FOFO controller (PurchaseReturnController:596) accepts fromDate /
toDate query params, defaults to last 30 days, calls
selectByWarehouseIdsAndDateRange(..., 200). API consumers should see the
same data shape and range as the dashboard. Mirroring.
 
36425 7 d 3 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/inventory/ Sale-return reversal: idempotency guards + CN failure rolls back + non-serialized reject reversal

rejectReturn (#1): add refundTimestamp / rejectTimestamp guards. Without
them a stale-tab click or retry could re-run the full reversal pipeline
on an already-refunded DN — reversing scans twice, re-running
restoreReturnedItems (re-credits scheme amounts to wallet on top of the
refund that already paid out), and stamping rejectTimestamp on top of
refundTimestamp. Mirrors refundOrder's existing guard pair.

refundOrder CN block (#2): replace the swallow-and-log with a re-throw
on IRN failure. With class-level @Transactional(rollbackFor=Exception),
the prior catch caused commits of an advanced sellerWarehouse sequence
+ orphan CreditNote / CreditNoteLine rows whenever the NIC IRN call
failed. Restructured as straight-through; IRN failure now rolls the
whole refundOrder transaction back so finance retries cleanly. Matches
the symmetric path in applyInvoiceReturnViaCreditNote.

applyInvoiceReturnViaCreditNote (#3): stamp pro.refundTimestamp /
refundedBy / refundAmount unconditionally rather than gated on
totalRefundAmount > 0. Defensive idempotency on the state machine: a
0-amount approve (corner case where the invoice's line items are already
fully returned via a sibling DN flow) used to leave the PRO in pending
state, allowing a second Approve click to issue a duplicate CN at NIC.

rejectReturn non-serialized reversal (#5): the reversal loop was gated
on inventoryItem.serialNumber being non-blank, leaving non-serialized
GOOD items' SALE_RET +1 increments un-reversed on rejection — phantom
warehouse stock. Now mirrors applyReceipt's nonSerialWhItemMap pattern
(orderId|itemId) and reverses both serialized and non-serialized.
Conservative addQuantity(-1) gate retained: only fires when lastScanType
== SALE_RET, matching the prior serialized behaviour.
 
36424 7 d 6 h amit /trunk/profitmandi-fofo/src/test/java/com/spice/profitmandi/web/util/ Fix MonitorType enum references: use lowercase values to match DB ENUM definition  
36423 7 d 6 h amit /trunk/profitmandi-dao/src/main/resources/sql/ Fix catalog_monitor_type table charset to utf8 for consistency  
36422 7 d 23 h amit /trunk/profitmandi-fofo/src/test/java/com/spice/profitmandi/web/controller/ Fix:MonitorType enum casing — FOCUSED/NORMAL to focused/normal in PlacementPlan test  
36421 7 d 23 h amit /trunk/profitmandi-fofo/src/main/webapp/ Feat:Scheme item date window — per-item start/end dates with inline editing, category→brand→model cascade in add-item modal, duplicate detection, full-width layout  
36420 7 d 23 h amit /trunk/profitmandi-cron/ OkHttp→RestClient migration for IMEI activation services (Itel, Tecno, Vivo). Added test deps. Updated RunOnceTasks, ScheduledTasks, OrderTrackingService.  
36419 7 d 23 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/digify/ OkHttp→HttpClientFactory migration for Digify controller  
36418 7 d 23 h amit /trunk/profitmandi-web/ OkHttp→Apache HttpClient migration. HyperTrackController/TrackingController now use RestClient, DB reads extracted to HyperTrackService to release connections before external HTTP calls. V2FofoDigifyController uses HttpClientFactory.  
36417 7 d 23 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/warehouse/ Fix:PO item swap — update/delete old PURCHASE scan record when reducing quantity on swapped inventory item  
36416 7 d 23 h amit /trunk/profitmandi-common/ Drop OkHttp, standardise on Apache HttpClient via HttpClientFactory. RestClient pool raised to 20/8, all construction routed through factory. Lint guard added to block direct OkHttp/createDefault usage.  
36415 8 d 0 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/integrations/gstpro/ GstProService: cancel EWB before IRN in within-24h cancellation

NIC rejects IRN cancellation with 'This IRN cannot be cancelled because
e-way bill has been generated' when an EWB is still active against the
invoice. Existing within-24h branch went straight to cancelIrn and hit
this rejection on every cancellation that had a generated EWB.

Mirror the DC branch's EWB-cancel pattern: when eInvoiceDetails.ewbNo is
non-null, resolve sellerGstin (prod gstin / sandbox), parse ewbNo, call
cancelEwb first, then proceed to cancelIrn. EWB-cancel is wrapped in
try/catch + WARN — already-cancelled EWBs (transient or manual) don't
block the IRN cancel that follows; a genuinely-active EWB still surfaces
via the IRN cancel error.
 
36414 8 d 0 h ranu /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/warehouse/ without vendor catalog pricing po will not create  
36413 8 d 4 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/catalog/ Added Rising Star/NEW  
36412 8 d 4 h amit /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ Added Rising Star/NEW  
36411 8 d 4 h amit /trunk/ Fix lock contention: REQUIRES_NEW for wallet lock in createLoanForBilling, handle HDFC payment deadlock as duplicate  
36410 8 d 5 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/entity/catalog/ Added Rising Star/NEW  
36409 8 d 21 h amit /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/v2/controller/fofo/ V2 REST: mirror INV reject endpoint + restore !isShipped guard

/return/invoice/reject/{proId} — REST sibling of the fofo controller's
new endpoint. Finance-role-gated, requires non-blank rejectRemark.

/return/invoice/process — autoApprove now isIrnCancellable && !isShipped,
matching the fofo controller. Shipped goods route through manual approval
even within 24h.
 
36408 8 d 21 h amit /trunk/profitmandi-fofo/src/main/ Sale-return reversal: controller wiring + UI for cancellability gate + INV reject + date filter

PurchaseReturnController:
/return/invoice/process — autoApprove now isIrnCancellable && !isShipped.
!isShipped guard restored: shipped goods route through manual approval
even within 24h, so the physical return goes through CN flow.
/return/invoice/reject/{proId} — new endpoint for finance to reject a
pending INV PRO (sale stands, no inventory/wallet/GST action).
/return/invoice — date filter (fromDate/toDate query params, default
last 30 days) backed by selectByWarehouseIdsAndDateRange. Limit
bumped to 200 to accommodate longer ranges.
receive-debit-note view — passes $requiresFinanceApproval so the
template can render the finance-approval banner when DN's IRN is
past the 24h window.

invoice-return.vm:
Added From/To date inputs + Apply button.
Added Reject button next to Approve & Refund for pending INV PROs.

receive-debit-note.vm:
Added one informational banner (#if $requiresFinanceApproval) above
the receipt form. No layout / JS / submit-URL change.

return.js:
#invoice-return-date-apply handler — POSTs the selected range to
/return/invoice and refreshes the table.
.reject-invoice-return handler — prompts for reason, calls the new
reject endpoint.

dev/staging/prod.properties: feature flag finance.receipt.approval.email.enabled
(default false, flip per env when mail infra is ready).
 

Show All