84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
'use strict';
|
|
// 回收/换货单、回收修改审批、客户来料。
|
|
const PrintStatus = require('../../print-status');
|
|
const { reviewRoutes } = require('./review');
|
|
|
|
const RECOVERY = '/api/recoveries/:id(uuid)';
|
|
|
|
module.exports = [
|
|
{
|
|
method: 'GET',
|
|
path: '/api/customer-materials',
|
|
handler: ({ ledger, query, actor }) => ledger.customerMaterials(query, actor),
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: '/api/customer-materials',
|
|
write: true,
|
|
handler: ({ ledger, body, actor }) => ledger.createCustomerMaterial(body, actor),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: '/api/recoveries',
|
|
handler: ({ ledger, query, actor }) => {
|
|
const result = ledger.recoveries(query, actor);
|
|
return {
|
|
...result,
|
|
rows: result.rows.map(row => ({ ...row, printStatus: PrintStatus.projection(ledger, 'recovery', row.id) })),
|
|
};
|
|
},
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: '/api/recoveries',
|
|
write: true,
|
|
handler: ({ ledger, body, actor }) => ledger.createRecovery(body, actor),
|
|
},
|
|
{
|
|
// 试算:读请求体、复核会话后直接返回,不进入事务。
|
|
method: 'POST',
|
|
path: '/api/recoveries/quote',
|
|
handler: ({ ledger, body, actor }) => ledger.recoveryQuote(body, actor),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: RECOVERY,
|
|
handler: ({ ledger, params: { id }, actor }) => ({
|
|
...ledger.recovery(id, actor),
|
|
printStatus: PrintStatus.projection(ledger, 'recovery', id),
|
|
}),
|
|
},
|
|
{
|
|
method: 'GET',
|
|
path: RECOVERY + '/edit',
|
|
handler: ({ ledger, params: { id }, actor }) => {
|
|
const result = ledger.recoveryEdit(id, actor);
|
|
return { ...result, record: { ...result.record, printStatus: PrintStatus.projection(ledger, 'recovery', id) } };
|
|
},
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: RECOVERY + '/update',
|
|
write: true,
|
|
handler: ({ ledger, params: { id }, body, actor }) => ledger.updateRecovery(id, body, actor),
|
|
},
|
|
{
|
|
method: 'POST',
|
|
path: RECOVERY + '/cancel',
|
|
write: true,
|
|
handler: ({ ledger, params: { id }, body, actor }) => ledger.cancelRecovery(id, body, actor),
|
|
},
|
|
{
|
|
// 试算:不进入事务。
|
|
method: 'POST',
|
|
path: RECOVERY + '/quote',
|
|
handler: ({ ledger, params: { id }, body, actor }) => ledger.recoveryEditQuote(id, body, actor),
|
|
},
|
|
...reviewRoutes('/api/recovery-changes', {
|
|
list: 'recoveryChanges',
|
|
one: 'recoveryChange',
|
|
approve: 'approveRecoveryChange',
|
|
reject: 'rejectRecoveryChange',
|
|
}),
|
|
];
|