Carry the branch on every offline-sales row instead of picking a store
The upload modal made the admin choose a branch, then generated and validated the workbook against that choice. A merchant with several outlets had to repeat the whole cycle per branch, and the picker defaulted to the first outlet, so an admin who never opened it credited the wrong store — the file and the selection agreed, so nothing flagged it. The sheet now carries tenantid, locationid and the store name as locked columns on every row, and the row's own locationid routes its sale. One file covers the whole business: fill in qtysold wherever something sold, across as many branches as needed, and upload once. The picker is gone from the admin surface entirely, and the store user's page keeps passing its locationId, which pins the upload to that branch and rejects rows for any other before they are even sent. Bills are keyed on branch first and bill number second. Counter books at different outlets restart numbering from 1, so a shared number is two sales rather than a duplicate, and keying on the number alone would have dropped the second one. Because a single upload can now move stock at six outlets, one total is no longer enough to check before committing: the preview gains a store count, a per-store table of lines, units, amount and problems, and a Store column on every row, and results name the branch on each bill. Rows are ordered store then product with an Excel autofilter, so a branch can isolate its own rows in a file spanning the business. Verified end to end against a two-branch tenant sharing a product id across both outlets: one upload deducted each branch independently, a pinned upload refused the other branch's rows, and re-uploading deducted nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1107,14 +1107,14 @@ export default function InventoryView({
|
||||
})()}
|
||||
</SlideDrawer>
|
||||
|
||||
{/* Offline (counter) sales import. `locations` is passed so an admin picks
|
||||
the branch the bills belong to — this view otherwise operates on the
|
||||
tenant's first outlet, which would silently credit the wrong store. */}
|
||||
{/* Offline (counter) sales import. No locationId is passed: the admin gets
|
||||
one workbook covering every branch, and each row's own locationid
|
||||
routes its sale to the right store. This view operates on the tenant's
|
||||
first outlet elsewhere, which would have been the wrong store to
|
||||
credit for most of these sales. */}
|
||||
{showOfflineSales && (
|
||||
<OfflineSalesUpload
|
||||
tenantId={tenantId}
|
||||
locationId={primaryLocationId}
|
||||
locations={locations.map(({ locationid, locationname }) => ({ locationid, locationname }))}
|
||||
onClose={() => setShowOfflineSales(false)}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user