invoice.js
911 Bytes
'use strict';
const ordersService = require('../models/orders-service');
const invoiceModel = require('../models/invoice');
const index = (req, res, next) => {
let page = parseInt(req.query.page, 10) || 1;
let limit = parseInt(req.query.limit, 10) || 10;
return req.ctx(ordersService).index(req.user.uid, page, limit, 8).then(result => {
res.render('invoice', {
// meOrdersPage: true,
meOrders: result
});
}).catch(next);
};
const detail = (req, res, next) => {
return req.ctx(invoiceModel).getInvoiceDetail(req.query.orderCode, req.user.uid).then(result => {
res.send(result);
}).catch(next);
};
const supply = (req, res, next) => {
return req.ctx(invoiceModel).submitInvoiceSupply(req.body, req.user.uid).then(result => {
res.send(result);
}).catch(next);
};
module.exports = {
index,
detail,
supply
};