Mobile Borrow And Customer Management
This page documents the current mobile behavior for borrow-item editing and customer-management edit fields.
Customer list search
CustomerListusesCustomerManagementListHeaderfor the search box.- When the user submits search from the keyboard, the header passes the
TextInputsubmit event text to the screen. CustomerListuses that submitted text as the effectivesearchvalue forgetCustomerSapListimmediately, then syncs the local search state/ref.- This prevents Thai IME timing issues where typing a word such as
ขายand pressing search could send only the first committed character, such asข, to the customer API. - The search still preserves the existing filters for shipping type and route code.
Customer address forms on iOS
CustomerDetailno longer opens the "add address" form as a nested modal.- Pressing
เพิ่มที่อยู่ใหม่switches the screen from the customer detail view to a full-screen address form view inside the same screen. - The detail header back action and the form
กลับaction close the address form and return to the customer detail view. CustomerManagementEdituses the same full-screen address editor pattern for adding and editing draft addresses.- While the address editor is open, the customer main form is hidden so only one scroll owner is active.
- Address search, route selection, and map picking are still modal/picker flows, but they are opened from the screen-level address form instead of from another modal.
- Modal visibility is guarded by the active view:
- customer-detail address search/map/route modals only open while the customer-detail address form is active.
- customer-management address search/map/route modals only open while the address editor is active.
- customer-management main-form selectors such as customer type, know-us, branch, day, and month are hidden while the address editor is active.
- This avoids iOS modal-over-modal and scroll gesture conflicts while keeping the save behavior, address payload, auto-create ShipTo option, and draft reload behavior unchanged.
Borrow detail item editing
BorrowDetailallows item editing only when the document is stillNEWand the current user is the borrow owner.- Owner comparison now trims both
user.userCodeanddetail.userCodebefore matching. - Tapping an existing borrow item opens a dedicated edit modal.
- The edit modal uses the same visual style as the add-product modal, but it does not show the product list or product search.
- The edit flow loads the current product by
productCode. If the item is missing from the in-memory inventory snapshot, the screen fetches it from inventory before opening the edit modal. - Permission enforcement for editing is checked again when the user presses save.
Borrow detail item save and delete behavior
- Editing an existing borrow item now updates by
itemId, and falls back toidwhenitemIdis missing in the item payload. - This prevents the edit flow from accidentally calling create-item APIs and triggering duplicate-item errors such as "item already exists in the list".
- Borrow-item deletion also falls back to
item.idwhenitem.itemIdis missing. - If no usable item identifier exists, the screen now shows a direct error instead of failing silently.
Customer management edit fields
CustomerManagementEditkeepscustomerType/customerTypeCodeandknowus/knowusCodeas separate fields.CustomerManagementEditincludes an optionaltaxIDtext field directly underฉายา.taxIDis not required for saving and is carried in the customer draft payload when present.CustomerManagementDetailandCustomerDetaildisplaytaxIDin the customer information section, falling back to-when the value is empty or missing.- The option lists now load from the correct source collections:
customerTypespopulate theประเภทลูกค้าselector.knowUspopulate theรู้จักเราจากselector.
- This fixes the previous behavior where the two selectors were swapped in the edit screen.
Customer draft create, replace, and pending child records
- Creating a new customer from
CustomerManagementEditcreates the customer draft first. - After the draft is created, the screen attempts to create draft addresses and draft branches under that draft id.
- If some addresses or branches fail to save, the screen still keeps the created
customerDraftIdand navigates withreplaceinto the same draft edit screen. - The screen passes unsaved child records as pending route params and merges them back into the refreshed screen state after reloading draft detail, addresses, and branches from the server.
- This means unsaved addresses or branches remain visible to the user after the screen reloads, even when those records are not yet stored on the server.
- A later save updates the existing draft instead of creating a new draft again.
SAP B1 approval recovery
- When immediate approval of a newly created individual customer fails, Mobile shows the B1 approval error and replaces the edit screen with the created draft detail.
- The draft detail reloads after an approval failure.
DRAFTexposes approve/reject;SAP_PARTIALexposes only retry approval submission throughPOST /customer-draft/:id/retry.