refactor: banking services to Nestjs

This commit is contained in:
Ahmed Bouhuolia
2025-01-05 16:26:23 +02:00
parent b72f85b394
commit 1869ba216f
150 changed files with 9698 additions and 163 deletions

View File

@@ -470,125 +470,129 @@ export class Bill extends BaseModel {
/**
* Relationship mapping.
*/
// static get relationMappings() {
// const Vendor = require('models/Vendor');
// const ItemEntry = require('models/ItemEntry');
// const BillLandedCost = require('models/BillLandedCost');
// const Branch = require('models/Branch');
// const Warehouse = require('models/Warehouse');
// const TaxRateTransaction = require('models/TaxRateTransaction');
// const Document = require('models/Document');
// const { MatchedBankTransaction } = require('models/MatchedBankTransaction');
static get relationMappings() {
const { Vendor } = require('../../Vendors/models/Vendor');
const {
ItemEntry,
} = require('../../TransactionItemEntry/models/ItemEntry');
const {
BillLandedCost,
} = require('../../BillLandedCosts/models/BillLandedCost');
const { Branch } = require('../../Branches/models/Branch.model');
const { Warehouse } = require('../../Warehouses/models/Warehouse.model');
const { TaxRateModel } = require('../../TaxRates/models/TaxRate.model');
const { Document } = require('../../ChromiumlyTenancy/models/Document');
// const { MatchedBankTransaction } = require('models/MatchedBankTransaction');
// return {
// vendor: {
// relation: Model.BelongsToOneRelation,
// modelClass: Vendor.default,
// join: {
// from: 'bills.vendorId',
// to: 'contacts.id',
// },
// filter(query) {
// query.where('contact_service', 'vendor');
// },
// },
return {
vendor: {
relation: Model.BelongsToOneRelation,
modelClass: Vendor,
join: {
from: 'bills.vendorId',
to: 'contacts.id',
},
filter(query) {
query.where('contact_service', 'vendor');
},
},
// entries: {
// relation: Model.HasManyRelation,
// modelClass: ItemEntry.default,
// join: {
// from: 'bills.id',
// to: 'items_entries.referenceId',
// },
// filter(builder) {
// builder.where('reference_type', 'Bill');
// builder.orderBy('index', 'ASC');
// },
// },
entries: {
relation: Model.HasManyRelation,
modelClass: ItemEntry,
join: {
from: 'bills.id',
to: 'items_entries.referenceId',
},
filter(builder) {
builder.where('reference_type', 'Bill');
builder.orderBy('index', 'ASC');
},
},
// locatedLandedCosts: {
// relation: Model.HasManyRelation,
// modelClass: BillLandedCost.default,
// join: {
// from: 'bills.id',
// to: 'bill_located_costs.billId',
// },
// },
locatedLandedCosts: {
relation: Model.HasManyRelation,
modelClass: BillLandedCost,
join: {
from: 'bills.id',
to: 'bill_located_costs.billId',
},
},
// /**
// * Bill may belongs to associated branch.
// */
// branch: {
// relation: Model.BelongsToOneRelation,
// modelClass: Branch.default,
// join: {
// from: 'bills.branchId',
// to: 'branches.id',
// },
// },
/**
* Bill may belongs to associated branch.
*/
branch: {
relation: Model.BelongsToOneRelation,
modelClass: Branch,
join: {
from: 'bills.branchId',
to: 'branches.id',
},
},
// /**
// * Bill may has associated warehouse.
// */
// warehouse: {
// relation: Model.BelongsToOneRelation,
// modelClass: Warehouse.default,
// join: {
// from: 'bills.warehouseId',
// to: 'warehouses.id',
// },
// },
/**
* Bill may has associated warehouse.
*/
warehouse: {
relation: Model.BelongsToOneRelation,
modelClass: Warehouse,
join: {
from: 'bills.warehouseId',
to: 'warehouses.id',
},
},
// /**
// * Bill may has associated tax rate transactions.
// */
// taxes: {
// relation: Model.HasManyRelation,
// modelClass: TaxRateTransaction.default,
// join: {
// from: 'bills.id',
// to: 'tax_rate_transactions.referenceId',
// },
// filter(builder) {
// builder.where('reference_type', 'Bill');
// },
// },
/**
* Bill may has associated tax rate transactions.
*/
taxes: {
relation: Model.HasManyRelation,
modelClass: TaxRateModel,
join: {
from: 'bills.id',
to: 'tax_rate_transactions.referenceId',
},
filter(builder) {
builder.where('reference_type', 'Bill');
},
},
// /**
// * Bill may has many attached attachments.
// */
// attachments: {
// relation: Model.ManyToManyRelation,
// modelClass: Document.default,
// join: {
// from: 'bills.id',
// through: {
// from: 'document_links.modelId',
// to: 'document_links.documentId',
// },
// to: 'documents.id',
// },
// filter(query) {
// query.where('model_ref', 'Bill');
// },
// },
/**
* Bill may has many attached attachments.
*/
attachments: {
relation: Model.ManyToManyRelation,
modelClass: Document,
join: {
from: 'bills.id',
through: {
from: 'document_links.modelId',
to: 'document_links.documentId',
},
to: 'documents.id',
},
filter(query) {
query.where('model_ref', 'Bill');
},
},
// /**
// * Bill may belongs to matched bank transaction.
// */
// matchedBankTransaction: {
// relation: Model.HasManyRelation,
// modelClass: MatchedBankTransaction,
// join: {
// from: 'bills.id',
// to: 'matched_bank_transactions.referenceId',
// },
// filter(query) {
// query.where('reference_type', 'Bill');
// },
// },
// };
// }
/**
* Bill may belongs to matched bank transaction.
*/
// matchedBankTransaction: {
// relation: Model.HasManyRelation,
// modelClass: MatchedBankTransaction,
// join: {
// from: 'bills.id',
// to: 'matched_bank_transactions.referenceId',
// },
// filter(query) {
// query.where('reference_type', 'Bill');
// },
// },
};
}
/**
* Retrieve the not found bills ids as array that associated to the given vendor.