mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
fix: Graph fetch relations with sales & purchases models.
feat: Inventory tracker algorithm lots with FIFO or LIFO cost method.
This commit is contained in:
62
server/src/http/controllers/Ping.ts
Normal file
62
server/src/http/controllers/Ping.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { Router, Request, Response } from 'express';
|
||||
import InventoryService from '@/services/Inventory/Inventory';
|
||||
|
||||
export default class Ping {
|
||||
|
||||
/**
|
||||
* Router constur
|
||||
*/
|
||||
static router() {
|
||||
const router = Router();
|
||||
|
||||
router.get(
|
||||
'/',
|
||||
this.ping,
|
||||
);
|
||||
return router;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
*/
|
||||
static async ping(req: Request, res: Response) {
|
||||
|
||||
const result = await InventoryService.trackingInventoryLotsCost([
|
||||
{
|
||||
id: 1,
|
||||
date: '2020-02-02',
|
||||
direction: 'IN',
|
||||
itemId: 1,
|
||||
quantity: 100,
|
||||
rate: 10,
|
||||
transactionType: 'Bill',
|
||||
transactionId: 1,
|
||||
remaining: 100,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
date: '2020-02-02',
|
||||
direction: 'OUT',
|
||||
itemId: 1,
|
||||
quantity: 80,
|
||||
rate: 10,
|
||||
transactionType: 'SaleInvoice',
|
||||
transactionId: 1,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
date: '2020-02-02',
|
||||
direction: 'OUT',
|
||||
itemId: 2,
|
||||
quantity: 500,
|
||||
rate: 10,
|
||||
transactionType: 'SaleInvoice',
|
||||
transactionId: 2,
|
||||
},
|
||||
]);
|
||||
|
||||
return res.status(200).send({ id: 1231231 });
|
||||
}
|
||||
}
|
||||
@@ -415,6 +415,9 @@ export default class PaymentReceivesController extends BaseController {
|
||||
return res.status(400).send({ errors: errorReasons });
|
||||
}
|
||||
const paymentReceives = await PaymentReceive.query().onBuild((builder) => {
|
||||
builder.withGraphFetched('customer');
|
||||
builder.withGraphFetched('depositAccount');
|
||||
|
||||
dynamicListing.buildQuery()(builder);
|
||||
return builder;
|
||||
}).pagination(filter.page - 1, filter.page_size);
|
||||
|
||||
@@ -326,6 +326,7 @@ export default class SalesEstimatesController extends BaseController {
|
||||
|
||||
const salesEstimates = await SaleEstimate.query().onBuild((builder) => {
|
||||
dynamicListing.buildQuery()(builder);
|
||||
builder.withGraphFetched('customer');
|
||||
return builder;
|
||||
}).pagination(filter.page - 1, filter.page_size);
|
||||
|
||||
|
||||
@@ -262,6 +262,9 @@ export default class SaleInvoicesController {
|
||||
const storedSaleInvoice = await SaleInvoiceService.createSaleInvoice(
|
||||
saleInvoice
|
||||
);
|
||||
|
||||
// InventoryService.trackingInventoryLotsCost();
|
||||
|
||||
return res.status(200).send({ id: storedSaleInvoice.id });
|
||||
}
|
||||
|
||||
|
||||
@@ -313,6 +313,8 @@ export default class SalesReceiptsController {
|
||||
errorReasons.push(...errors);
|
||||
}
|
||||
const salesReceipts = await SaleReceipt.query().onBuild((builder) => {
|
||||
builder.withGraphFetched('customer');
|
||||
builder.withGraphFetched('depositAccount');
|
||||
builder.withGraphFetched('entries');
|
||||
dynamicListing.buildQuery()(builder);
|
||||
}).pagination(filter.page - 1, filter.page_size);
|
||||
|
||||
Reference in New Issue
Block a user