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
36444 4 d 17 h ranu /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/knowlarity/ uday sing maill added in po approval  
36443 4 d 20 h amit /trunk/profitmandi-dao/src/main/resources/sql/ Add ALTER TABLE migration to rename monitor_type normal to base  
36442 4 d 22 h amit /trunk/profitmandi-fofo/src/ Rename monitor type 'normal' to 'base' in controller, validator, UI, and tests  
36441 4 d 22 h amit /trunk/profitmandi-dao/src/main/ Rename monitor type 'normal' to 'base' in enum and SQL schema  
36440 5 d 0 h amit /trunk/profitmandi-web/src/main/java/com/spice/profitmandi/web/controller/ Set outlet_name from retailerAddress on FofoStore creation in RetailerController  
36439 5 d 0 h amit /trunk/profitmandi-dao/src/main/ Add outlet_name field to FofoStore entity, set from address.name on store creation

Adds outlet_name (VARCHAR 255) to FofoStore entity so the store's display
name is persisted directly on fofo_store instead of requiring a join through
retailer_registered_address -> address every time it is needed.

Sets fofoStore.setOutletName(retailerAddress.getName()) in both creation
paths: RetailerServiceImpl.createFofoStoreCodeByRetailerId (primary) and
RetailerController.createFofoStore (secondary).

Includes migration SQL script (migration_outlet_name_to_fofo_store.sql) to
ALTER TABLE and backfill existing rows from address.name. Must be run during
low-traffic window - fofo_store is heavily queried and ALTER takes a metadata
lock that blocks all concurrent SELECTs.
 
36438 5 d 0 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/ Fix SD Credit over-utilization: use live loan SUM + row lock + sanction guard

- blockLoan: use SELECT FOR UPDATE to prevent concurrent orders from both passing credit check
- processLoanRequest: replace stored utilized_limit counter with live SUM(pending_amount) from loan table
- processLoanRequest + getAvailableAmount: only add sanction amount if not already used today
- Prevents credit limit from going negative due to counter drift or race conditions
 
36437 5 d 1 h aman /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/dao/repository/dtr/ Fix  
36436 5 d 18 h ranu /trunk/ without vendor catalog pricing po will not create  
36435 5 d 23 h aman /trunk/profitmandi-fofo/src/main/java/com/spice/profitmandi/web/controller/ Fix:Mark Inauguration Timestamp & Create Store Timeline Entry on Training Completion  
36434 6 d 13 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/transaction/ Fix: wrap PDF file save in try-catch for test reissue method (path may not exist locally)  
36433 6 d 13 h amit /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/ Fix: move testReissueOneCN and reissueMarginsCN CLI triggers out of morning block so they can run standalone  
36432 6 d 13 h amit /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/ Add testReissueOneCN and reissueMarginsCN CLI triggers for credit note reissue  
36431 6 d 13 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/ Add reissueMarginsCN: reissue MARGINS credit notes with /A suffix, March 31 book date, Delhi GST skip, consolidated partner emails  
36430 6 d 14 h amit /trunk/profitmandi-cron/src/main/java/com/smartdukaan/cron/scheduled/ Add fixStuckLimitBlocks remediation for stuck limit_block=1 loans (Apr 27-29). Calls createLoanForBilling per invoice for each stuck limit block, creating actual loans and settling blocked limits. Validated locally: 59 fixes, 0 failures, all wallets net to zero.  
36429 6 d 17 h amit /trunk/profitmandi-dao/src/main/java/com/spice/profitmandi/service/ Fix credit limit settlement not happening on billing and post-billing cancellation

createLoanForBilling has REQUIRES_NEW (added for lock isolation against
order row locks held by the billing method). Inside that new transaction it
queried orders to find which were just billed — but the billing timestamps
set in the suspended outer transaction are invisible, so the condition
always evaluates FALSE when all orders are billed in one call. The limit
block is never converted to a loan and never released.

Fix: remove the order query. The caller already passes invoiceAmount (sum
of walletAmount for the billed orders). Use it directly with Math.min to
cap at pendingAmount. REQUIRES_NEW kept for lock isolation.

Also: cancelInvoiceFully and applyInvoiceReturnViaCreditNote (post-billing
invoice cancellation/return paths) credit the partner wallet but never
settle the non-limit loan created during billing. Added settleLoan call
after wallet credit in both paths, guarded by settledOn == null check.

Data defect: 95 stuck limit blocks totaling Rs 56.95 lakh across partners.
Most have no actual loan created. Needs one-time remediation via
fixBlockedCredit() in ScheduledTasks.
 
36428 6 d 20 h aman /trunk/ Fix:Partner Stock Api  
36427 6 d 22 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 6 d 22 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 6 d 22 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.
 

Show All