u
This commit is contained in:
@@ -70,11 +70,21 @@ export async function getCustomerCount(params) {
|
||||
return store.posterminal.getCustomerCount(params);
|
||||
}
|
||||
|
||||
export async function getCustomerList(params) {
|
||||
const store = await getStore();
|
||||
return store.posterminal.getCustomerList(params);
|
||||
}
|
||||
|
||||
export async function getCustomerGroupCount(params) {
|
||||
const store = await getStore();
|
||||
return store.posterminal.getCustomerGroupCount(params);
|
||||
}
|
||||
|
||||
export async function getCustomerGroupList(params) {
|
||||
const store = await getStore();
|
||||
return store.posterminal.getCustomerGroupList(params);
|
||||
}
|
||||
|
||||
export async function getCompositeProductCount(params) {
|
||||
const store = await getStore();
|
||||
return store.posterminal.getCompositeProductCount(params);
|
||||
|
||||
@@ -3,6 +3,8 @@ import { posAuthMiddleware } from './middleware/posAuth.js';
|
||||
import { handleClient } from './routes/client.js';
|
||||
import { handleInit } from './routes/init.js';
|
||||
import { handleCategory } from './routes/category.js';
|
||||
import { handleCustomerGroup } from './routes/customergroup.js';
|
||||
import { handleCustomer } from './routes/customer.js';
|
||||
import { handleProduct } from './routes/product.js';
|
||||
import { handlePimage } from './routes/pimage.js';
|
||||
|
||||
@@ -16,6 +18,8 @@ router.get('/init', posAuthMiddleware, handleInit);
|
||||
|
||||
// POS master data synchronization
|
||||
router.get('/category', posAuthMiddleware, handleCategory);
|
||||
router.get('/customergroup', posAuthMiddleware, handleCustomerGroup);
|
||||
router.get('/customer', posAuthMiddleware, handleCustomer);
|
||||
router.get('/product', posAuthMiddleware, handleProduct);
|
||||
|
||||
// POS image delivery
|
||||
|
||||
96
src/v1/routes/customer.js
Normal file
96
src/v1/routes/customer.js
Normal file
@@ -0,0 +1,96 @@
|
||||
import { getCustomerList } from '../../db/posterminal.js';
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /v1/customer:
|
||||
* get:
|
||||
* summary: JTL-POS customer catalog synchronization
|
||||
* description: Returns customer list modified after lastChangedCustomer cursor for the authenticated POS register.
|
||||
* tags:
|
||||
* - POS Sync
|
||||
* security:
|
||||
* - BearerAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: lastChangedCustomer
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Unix timestamp cursor of last customer sync
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 20
|
||||
* description: Maximum number of customers to return
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Array of customer objects for JTL-POS
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: string
|
||||
* customerNumber:
|
||||
* type: string
|
||||
* firstname:
|
||||
* type: string
|
||||
* lastname:
|
||||
* type: string
|
||||
* title:
|
||||
* type: string
|
||||
* company:
|
||||
* type: string
|
||||
* address:
|
||||
* type: string
|
||||
* addressSupplement:
|
||||
* type: string
|
||||
* city:
|
||||
* type: string
|
||||
* postalCode:
|
||||
* type: string
|
||||
* state:
|
||||
* type: string
|
||||
* country:
|
||||
* type: string
|
||||
* phone:
|
||||
* type: string
|
||||
* email:
|
||||
* type: string
|
||||
* customerGroupId:
|
||||
* type: string
|
||||
* salutation:
|
||||
* type: string
|
||||
* birthday:
|
||||
* type: string
|
||||
* discount:
|
||||
* type: string
|
||||
* taxIdNumber:
|
||||
* type: string
|
||||
* lastChanged:
|
||||
* type: string
|
||||
* debtorNumber:
|
||||
* type: string
|
||||
* 401:
|
||||
* description: Unauthorized
|
||||
*/
|
||||
export async function handleCustomer(req, res, next) {
|
||||
try {
|
||||
const posterminal = req.posterminal;
|
||||
const cursor = Number(req.query.lastChangedCustomer) || 0;
|
||||
const limit = Number(req.query.limit) || 20;
|
||||
|
||||
const customers = await getCustomerList({
|
||||
posterminalId: posterminal.id,
|
||||
cursor,
|
||||
limit,
|
||||
});
|
||||
|
||||
res.json(customers);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
69
src/v1/routes/customergroup.js
Normal file
69
src/v1/routes/customergroup.js
Normal file
@@ -0,0 +1,69 @@
|
||||
import { getCustomerGroupList } from '../../db/posterminal.js';
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /v1/customergroup:
|
||||
* get:
|
||||
* summary: JTL-POS customer group synchronization
|
||||
* description: Returns customer groups modified after lastChangedCustomerGroup cursor for the authenticated POS register, excluding 'Lieferanten'.
|
||||
* tags:
|
||||
* - POS Sync
|
||||
* security:
|
||||
* - BearerAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: lastChangedCustomerGroup
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Unix timestamp cursor of last customer group sync
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 50
|
||||
* description: Maximum number of customer groups to return
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Array of customer group objects for JTL-POS
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* customerGroupId:
|
||||
* type: string
|
||||
* example: "1"
|
||||
* name:
|
||||
* type: string
|
||||
* example: "Endkunden"
|
||||
* standard:
|
||||
* type: string
|
||||
* example: "1"
|
||||
* discountPercent:
|
||||
* type: string
|
||||
* example: "0.000000"
|
||||
* lastChanged:
|
||||
* type: string
|
||||
* example: "1721000000"
|
||||
* 401:
|
||||
* description: Unauthorized
|
||||
*/
|
||||
export async function handleCustomerGroup(req, res, next) {
|
||||
try {
|
||||
const posterminal = req.posterminal;
|
||||
const cursor = Number(req.query.lastChangedCustomerGroup) || 0;
|
||||
const limit = Number(req.query.limit) || 50;
|
||||
|
||||
const customerGroups = await getCustomerGroupList({
|
||||
posterminalId: posterminal.id,
|
||||
cursor,
|
||||
limit,
|
||||
});
|
||||
|
||||
res.json(customerGroups);
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user