mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
|
||||
import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
||||
import { Warehouse } from '../models/Warehouse.model';
|
||||
import { SaleReceipt } from '@/modules/SaleReceipts/models/SaleReceipt';
|
||||
|
||||
@Injectable()
|
||||
export class ReceiptActivateWarehouses {
|
||||
constructor(
|
||||
@Inject(SaleReceipt.name)
|
||||
private readonly saleReceiptModel: TenantModelProxy<typeof SaleReceipt>,
|
||||
|
||||
@Inject(ItemEntry.name)
|
||||
private readonly itemEntryModel: TenantModelProxy<typeof ItemEntry>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Updates all sale receipts transactions with the primary warehouse.
|
||||
* @param {Warehouse} primaryWarehouse
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public updateReceiptsWithWarehouse = async (
|
||||
primaryWarehouse: Warehouse,
|
||||
): Promise<void> => {
|
||||
// Updates the vendor credits transactions with primary warehouse.
|
||||
await this.saleReceiptModel().query().update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
// Update the sale invoices entries with primary warehouse.
|
||||
await this.itemEntryModel()
|
||||
.query()
|
||||
.where('referenceType', 'SaleReceipt')
|
||||
.update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user