mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
add server to monorepo.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { IWarehouse } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class BillActivateWarehouses {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Updates all credit note transactions with the primary warehouse.
|
||||
* @param {number} tenantId
|
||||
* @param {number} primaryWarehouse
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public updateBillsWithWarehouse = async (
|
||||
tenantId: number,
|
||||
primaryWarehouse: IWarehouse
|
||||
): Promise<void> => {
|
||||
const { Bill, ItemEntry } = this.tenancy.models(tenantId);
|
||||
|
||||
// Updates the sale estimates with primary warehouse.
|
||||
await Bill.query().update({ warehouseId: primaryWarehouse.id });
|
||||
|
||||
// Update the sale estimates entries with primary warehouse.
|
||||
await ItemEntry.query().where('referenceType', 'Bill').update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { IWarehouse } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class CreditNotesActivateWarehouses {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Updates all credit note transactions with the primary warehouse.
|
||||
* @param {number} tenantId
|
||||
* @param {number} primaryWarehouse
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public updateCreditsWithWarehouse = async (
|
||||
tenantId: number,
|
||||
primaryWarehouse: IWarehouse
|
||||
): Promise<void> => {
|
||||
const { CreditNote, ItemEntry } = this.tenancy.models(tenantId);
|
||||
|
||||
// Updates the sale estimates with primary warehouse.
|
||||
await CreditNote.query().update({ warehouseId: primaryWarehouse.id });
|
||||
|
||||
// Update the sale estimates entries with primary warehouse.
|
||||
await ItemEntry.query().where('referenceType', 'CreditNote').update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { IWarehouse } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class EstimatesActivateWarehouses {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Updates all inventory transactions with the primary warehouse.
|
||||
* @param {number} tenantId
|
||||
* @param {number} primaryWarehouse
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public updateEstimatesWithWarehouse = async (
|
||||
tenantId: number,
|
||||
primaryWarehouse: IWarehouse
|
||||
): Promise<void> => {
|
||||
const { SaleEstimate, ItemEntry } = this.tenancy.models(tenantId);
|
||||
|
||||
// Updates the sale estimates with primary warehouse.
|
||||
await SaleEstimate.query().update({ warehouseId: primaryWarehouse.id });
|
||||
|
||||
// Update the sale estimates entries with primary warehouse.
|
||||
await ItemEntry.query().where('referenceType', 'SaleEstimate').update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { IWarehouse } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class InventoryActivateWarehouses {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Updates all inventory transactions with the primary warehouse.
|
||||
* @param {number} tenantId
|
||||
* @param {number} primaryWarehouse
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public updateInventoryTransactionsWithWarehouse = async (
|
||||
tenantId: number,
|
||||
primaryWarehouse: IWarehouse
|
||||
): Promise<void> => {
|
||||
const { InventoryTransaction, InventoryCostLotTracker } =
|
||||
this.tenancy.models(tenantId);
|
||||
|
||||
// Updates the inventory transactions with primary warehouse.
|
||||
await InventoryTransaction.query().update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
await InventoryCostLotTracker.query().update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { IWarehouse } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class InvoicesActivateWarehouses {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Updates all inventory transactions with the primary warehouse.
|
||||
* @param {number} tenantId
|
||||
* @param {number} primaryWarehouse
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public updateInvoicesWithWarehouse = async (
|
||||
tenantId: number,
|
||||
primaryWarehouse: IWarehouse
|
||||
): Promise<void> => {
|
||||
const { SaleInvoice, ItemEntry } = this.tenancy.models(tenantId);
|
||||
|
||||
// Updates the sale invoices with primary warehouse.
|
||||
await SaleInvoice.query().update({ warehouseId: primaryWarehouse.id });
|
||||
|
||||
// Update the sale invoices entries with primary warehouse.
|
||||
await ItemEntry.query().where('referenceType', 'SaleInvoice').update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { IWarehouse } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class ReceiptActivateWarehouses {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Updates all sale receipts transactions with the primary warehouse.
|
||||
* @param {number} tenantId
|
||||
* @param {number} primaryWarehouse
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public updateReceiptsWithWarehouse = async (
|
||||
tenantId: number,
|
||||
primaryWarehouse: IWarehouse
|
||||
): Promise<void> => {
|
||||
const { SaleReceipt, ItemEntry } = this.tenancy.models(tenantId);
|
||||
|
||||
// Updates the vendor credits transactions with primary warehouse.
|
||||
await SaleReceipt.query().update({ warehouseId: primaryWarehouse.id });
|
||||
|
||||
// Update the sale invoices entries with primary warehouse.
|
||||
await ItemEntry.query().where('referenceType', 'SaleReceipt').update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import { IWarehouse } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
export class VendorCreditActivateWarehouses {
|
||||
@Inject()
|
||||
tenancy: HasTenancyService;
|
||||
|
||||
/**
|
||||
* Updates all vendor credits transactions with the primary warehouse.
|
||||
* @param {number} tenantId
|
||||
* @param {number} primaryWarehouse
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
public updateCreditsWithWarehouse = async (
|
||||
tenantId: number,
|
||||
primaryWarehouse: IWarehouse
|
||||
): Promise<void> => {
|
||||
const { VendorCredit, ItemEntry } = this.tenancy.models(tenantId);
|
||||
|
||||
// Updates the vendor credits transactions with primary warehouse.
|
||||
await VendorCredit.query().update({ warehouseId: primaryWarehouse.id });
|
||||
|
||||
// Update the sale invoices entries with primary warehouse.
|
||||
await ItemEntry.query().where('referenceType', 'VendorCredit').update({
|
||||
warehouseId: primaryWarehouse.id,
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user