mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: models default views
This commit is contained in:
@@ -34,7 +34,7 @@ export const DEFAULT_VIEW_COLUMNS = [
|
||||
export const MAX_ACCOUNTS_CHART_DEPTH = 5;
|
||||
|
||||
// Accounts default views.
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const AccountDefaultViews = [
|
||||
{
|
||||
name: 'Assets',
|
||||
slug: 'assets',
|
||||
|
||||
@@ -14,10 +14,13 @@ import { ExportableModel } from '../../Export/decorators/ExportableModel.decorat
|
||||
import { AccountMeta } from './Account.meta';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { AccountDefaultViews } from '../constants';
|
||||
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(AccountMeta)
|
||||
@InjectModelDefaultViews(AccountDefaultViews)
|
||||
export class Account extends TenantBaseModel {
|
||||
public name!: string;
|
||||
public slug!: string;
|
||||
@@ -227,7 +230,7 @@ export class Account extends TenantBaseModel {
|
||||
to: 'accounts_transactions.accountId',
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Account may has many items as cost account.
|
||||
*/
|
||||
@@ -422,20 +425,6 @@ export class Account extends TenantBaseModel {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Model settings.
|
||||
*/
|
||||
// static get meta() {
|
||||
// return AccountSettings;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieve the default custom views, roles and columns.
|
||||
*/
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search roles.
|
||||
*/
|
||||
|
||||
@@ -109,24 +109,10 @@ export class BankAccount extends TenantBaseModel {
|
||||
isParentType(parentType) {
|
||||
return AccountTypesUtils.isParentTypeEqualsKey(
|
||||
this.accountType,
|
||||
parentType
|
||||
parentType,
|
||||
);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Model settings.
|
||||
// */
|
||||
// static get meta() {
|
||||
// return CashflowAccountSettings;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieve the default custom views, roles and columns.
|
||||
// */
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search roles.
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,7 @@ export const ERRORS = {
|
||||
WITHDRAWAL_ACCOUNT_CURRENCY_INVALID: 'WITHDRAWAL_ACCOUNT_CURRENCY_INVALID',
|
||||
};
|
||||
|
||||
export const DEFAULT_VIEWS = [];
|
||||
export const BillPaymentDefaultViews = [];
|
||||
|
||||
export const BillsPaymentsSampleData = [
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Model } from 'objection';
|
||||
import { BillPaymentEntry } from './BillPaymentEntry';
|
||||
import { Vendor } from '@/modules/Vendors/models/Vendor';
|
||||
import { Document } from '@/modules/ChromiumlyTenancy/models/Document';
|
||||
@@ -6,11 +7,13 @@ import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.dec
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { BillPaymentMeta } from './BillPayment.meta';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
import { Model } from 'objection';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { BillPaymentDefaultViews } from '../constants';
|
||||
|
||||
@ImportableModel()
|
||||
@ExportableModel()
|
||||
@InjectModelMeta(BillPaymentMeta)
|
||||
@InjectModelDefaultViews(BillPaymentDefaultViews)
|
||||
export class BillPayment extends TenantBaseModel {
|
||||
vendorId: number;
|
||||
amount: number;
|
||||
@@ -61,7 +64,7 @@ export class BillPayment extends TenantBaseModel {
|
||||
get localAmount() {
|
||||
return this.amount * this.exchangeRate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
@@ -154,13 +157,6 @@ export class BillPayment extends TenantBaseModel {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the default custom views, roles and columns.
|
||||
*/
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ export const ERRORS = {
|
||||
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const BillDefaultViews = [
|
||||
{
|
||||
name: 'Draft',
|
||||
slug: 'draft',
|
||||
|
||||
@@ -11,9 +11,12 @@ import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { BillMeta } from './Bill.meta';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { BillDefaultViews } from '../Bills.constants';
|
||||
|
||||
@ExportableModel()
|
||||
@InjectModelMeta(BillMeta)
|
||||
@InjectModelDefaultViews(BillDefaultViews)
|
||||
export class Bill extends TenantBaseModel {
|
||||
public amount: number;
|
||||
public paymentAmount: number;
|
||||
@@ -486,7 +489,9 @@ export class Bill extends TenantBaseModel {
|
||||
TaxRateTransaction,
|
||||
} = require('../../TaxRates/models/TaxRateTransaction.model');
|
||||
const { Document } = require('../../ChromiumlyTenancy/models/Document');
|
||||
const { MatchedBankTransaction } = require('../../BankingMatching/models/MatchedBankTransaction');
|
||||
const {
|
||||
MatchedBankTransaction,
|
||||
} = require('../../BankingMatching/models/MatchedBankTransaction');
|
||||
|
||||
return {
|
||||
vendor: {
|
||||
@@ -631,13 +636,6 @@ export class Bill extends TenantBaseModel {
|
||||
[changeMethod]('payment_amount', Math.abs(amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the default custom views, roles and columns.
|
||||
*/
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@ export const ERRORS = {
|
||||
};
|
||||
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const CreditNoteDefaultViews = [
|
||||
{
|
||||
name: 'credit_note.view.draft',
|
||||
slug: 'draft',
|
||||
@@ -71,7 +71,7 @@ export const defaultCreditNoteBrandingAttributes = {
|
||||
// # Colors
|
||||
primaryColor: '',
|
||||
secondaryColor: '',
|
||||
|
||||
|
||||
// # Company logo
|
||||
showCompanyLogo: true,
|
||||
companyLogoKey: '',
|
||||
|
||||
@@ -10,10 +10,13 @@ import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
||||
import { Warehouse } from '@/modules/Warehouses/models/Warehouse.model';
|
||||
import { mixin, Model, raw } from 'objection';
|
||||
import { CreditNoteMeta } from './CreditNote.meta';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { CreditNoteDefaultViews } from '../constants';
|
||||
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(CreditNoteMeta)
|
||||
@InjectModelDefaultViews(CreditNoteDefaultViews)
|
||||
export class CreditNote extends TenantBaseModel {
|
||||
public amount: number;
|
||||
public exchangeRate: number;
|
||||
@@ -402,20 +405,6 @@ export class CreditNote extends TenantBaseModel {
|
||||
};
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Sale invoice meta.
|
||||
// */
|
||||
// static get meta() {
|
||||
// return CreditNoteMeta;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieve the default custom views, roles and columns.
|
||||
// */
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model searchable.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const CustomerDefaultViews = [
|
||||
{
|
||||
name: 'Overdue',
|
||||
slug: 'overdue',
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { CustomerMeta } from './Customer.meta';
|
||||
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { CustomerDefaultViews } from '../constants';
|
||||
|
||||
@InjectModelMeta(CustomerMeta)
|
||||
export class Customer extends TenantBaseModel{
|
||||
@InjectModelDefaultViews(CustomerDefaultViews)
|
||||
export class Customer extends TenantBaseModel {
|
||||
contactService: string;
|
||||
contactType: string;
|
||||
|
||||
@@ -49,7 +51,6 @@ export class Customer extends TenantBaseModel{
|
||||
note: string;
|
||||
active: boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Query builder.
|
||||
*/
|
||||
@@ -110,7 +111,7 @@ export class Customer extends TenantBaseModel{
|
||||
{
|
||||
mail: this.email,
|
||||
label: this.displayName,
|
||||
primary: true
|
||||
primary: true,
|
||||
},
|
||||
].filter((c) => c.mail);
|
||||
}
|
||||
@@ -147,7 +148,7 @@ export class Customer extends TenantBaseModel{
|
||||
'*',
|
||||
Customer.relatedQuery('overDueInvoices', query.knex())
|
||||
.count()
|
||||
.as('countOverdue')
|
||||
.as('countOverdue'),
|
||||
);
|
||||
query.having('countOverdue', '>', 0);
|
||||
},
|
||||
@@ -190,17 +191,6 @@ export class Customer extends TenantBaseModel{
|
||||
// };
|
||||
// }
|
||||
|
||||
// static get meta() {
|
||||
// return CustomerSettings;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieve the default custom views, roles and columns.
|
||||
// */
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ACCOUNT_TYPE } from "@/constants/accounts";
|
||||
import { ACCOUNT_TYPE } from '@/constants/accounts';
|
||||
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const ExpenseDefaultViews = [
|
||||
{
|
||||
name: 'Draft',
|
||||
slug: 'draft',
|
||||
|
||||
@@ -7,10 +7,13 @@ import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.dec
|
||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { ExpenseMeta } from './Expense.meta';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { ExpenseDefaultViews } from '../constants';
|
||||
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(ExpenseMeta)
|
||||
@InjectModelDefaultViews(ExpenseDefaultViews)
|
||||
export class Expense extends TenantBaseModel {
|
||||
totalAmount!: number;
|
||||
currencyCode!: string;
|
||||
@@ -202,7 +205,9 @@ export class Expense extends TenantBaseModel {
|
||||
const { ExpenseCategory } = require('./ExpenseCategory.model');
|
||||
const { Document } = require('../../ChromiumlyTenancy/models/Document');
|
||||
const { Branch } = require('../../Branches/models/Branch.model');
|
||||
const { MatchedBankTransaction } = require('../../BankingMatching/models/MatchedBankTransaction');
|
||||
const {
|
||||
MatchedBankTransaction,
|
||||
} = require('../../BankingMatching/models/MatchedBankTransaction');
|
||||
|
||||
return {
|
||||
/**
|
||||
@@ -280,17 +285,6 @@ export class Expense extends TenantBaseModel {
|
||||
};
|
||||
}
|
||||
|
||||
// static get meta() {
|
||||
// return ExpenseSettings;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieve the default custom views, roles and columns.
|
||||
// */
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,7 @@ export const ERRORS = {
|
||||
};
|
||||
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const ItemDefaultViews = [
|
||||
{
|
||||
name: 'Services',
|
||||
slug: 'services',
|
||||
|
||||
@@ -6,11 +6,14 @@ import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/Inje
|
||||
import { ItemMeta } from './Item.meta';
|
||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { PreventMutateBaseCurrency } from '@/common/decorators/LockMutateBaseCurrency.decorator';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { ItemDefaultViews } from '../Items.constants';
|
||||
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(ItemMeta)
|
||||
@PreventMutateBaseCurrency()
|
||||
@InjectModelMeta(ItemMeta)
|
||||
@InjectModelDefaultViews(ItemDefaultViews)
|
||||
export class Item extends TenantBaseModel {
|
||||
public readonly quantityOnHand: number;
|
||||
public readonly name: string;
|
||||
|
||||
@@ -28,7 +28,7 @@ export const CONTACTS_CONFIG = [
|
||||
},
|
||||
];
|
||||
|
||||
export const DEFAULT_VIEWS = [];
|
||||
export const ManualJournalDefaultViews = [];
|
||||
|
||||
export const ManualJournalsSampleData = [
|
||||
{
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
import { Model, mixin } from 'objection';
|
||||
// import TenantModel from 'models/TenantModel';
|
||||
// import { formatNumber } from 'utils';
|
||||
// import ModelSetting from './ModelSetting';
|
||||
// import ManualJournalSettings from './ManualJournal.Settings';
|
||||
// import CustomViewBaseModel from './CustomViewBaseModel';
|
||||
// import { DEFAULT_VIEWS } from '@/services/ManualJournals/constants';
|
||||
// import ModelSearchable from './ModelSearchable';
|
||||
import { ManualJournalEntry } from './ManualJournalEntry';
|
||||
import { Document } from '@/modules/ChromiumlyTenancy/models/Document';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
@@ -13,10 +6,13 @@ import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.dec
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { ManualJournalMeta } from './ManualJournal.meta';
|
||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { ManualJournalDefaultViews } from '../constants';
|
||||
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(ManualJournalMeta)
|
||||
@InjectModelDefaultViews(ManualJournalDefaultViews)
|
||||
export class ManualJournal extends TenantBaseModel {
|
||||
date: Date;
|
||||
journalNumber: string;
|
||||
@@ -120,10 +116,14 @@ export class ManualJournal extends TenantBaseModel {
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const { AccountTransaction } = require('../../Accounts/models/AccountTransaction.model');
|
||||
const {
|
||||
AccountTransaction,
|
||||
} = require('../../Accounts/models/AccountTransaction.model');
|
||||
const { ManualJournalEntry } = require('./ManualJournalEntry');
|
||||
const { Document } = require('../../ChromiumlyTenancy/models/Document');
|
||||
const { MatchedBankTransaction } = require('../../BankingMatching/models/MatchedBankTransaction');
|
||||
const {
|
||||
MatchedBankTransaction,
|
||||
} = require('../../BankingMatching/models/MatchedBankTransaction');
|
||||
|
||||
return {
|
||||
entries: {
|
||||
@@ -185,17 +185,6 @@ export class ManualJournal extends TenantBaseModel {
|
||||
};
|
||||
}
|
||||
|
||||
// static get meta() {
|
||||
// return ManualJournalSettings;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieve the default custom views, roles and columns.
|
||||
// */
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ export const ERRORS = {
|
||||
NO_INVOICE_CUSTOMER_EMAIL_ADDR: 'NO_INVOICE_CUSTOMER_EMAIL_ADDR',
|
||||
};
|
||||
|
||||
export const DEFAULT_VIEWS = [];
|
||||
export const PaymentReceivedDefaultViews = [];
|
||||
|
||||
export const PaymentsReceiveSampleData = [
|
||||
{
|
||||
|
||||
@@ -5,10 +5,13 @@ import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.dec
|
||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { PaymentReceivedMeta } from './PaymentReceived.meta';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { PaymentReceivedDefaultViews } from '../constants';
|
||||
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(PaymentReceivedMeta)
|
||||
@InjectModelDefaultViews(PaymentReceivedDefaultViews)
|
||||
export class PaymentReceived extends TenantBaseModel {
|
||||
customerId: number;
|
||||
paymentDate: string;
|
||||
@@ -79,7 +82,9 @@ export class PaymentReceived extends TenantBaseModel {
|
||||
const {
|
||||
DocumentModel,
|
||||
} = require('../../Attachments/models/Document.model');
|
||||
const { PdfTemplateModel } = require('../../PdfTemplate/models/PdfTemplate');
|
||||
const {
|
||||
PdfTemplateModel,
|
||||
} = require('../../PdfTemplate/models/PdfTemplate');
|
||||
|
||||
return {
|
||||
customer: {
|
||||
@@ -172,20 +177,6 @@ export class PaymentReceived extends TenantBaseModel {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// static get meta() {
|
||||
// return PaymentReceiveSettings;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieve the default custom views, roles and columns.
|
||||
// */
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,7 @@ export const ERRORS = {
|
||||
};
|
||||
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const SaleEstimateDefaultViews = [
|
||||
{
|
||||
name: 'Draft',
|
||||
slug: 'draft',
|
||||
|
||||
@@ -10,10 +10,13 @@ import { ItemEntry } from '@/modules/TransactionItemEntry/models/ItemEntry';
|
||||
import { Document } from '@/modules/ChromiumlyTenancy/models/Document';
|
||||
import { Customer } from '@/modules/Customers/models/Customer';
|
||||
import { DiscountType } from '@/common/types/Discount';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { SaleEstimateDefaultViews } from '../constants';
|
||||
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(SaleEstimateMeta)
|
||||
@InjectModelDefaultViews(SaleEstimateDefaultViews)
|
||||
export class SaleEstimate extends TenantBaseModel {
|
||||
exchangeRate!: number;
|
||||
amount!: number;
|
||||
@@ -87,59 +90,57 @@ export class SaleEstimate extends TenantBaseModel {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Estimate subtotal.
|
||||
* @returns {number}
|
||||
*/
|
||||
get subtotal() {
|
||||
return this.amount;;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate subtotal in local currency.
|
||||
* @returns {number}
|
||||
*/
|
||||
get subtotalLocal() {
|
||||
return this.localAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discount amount.
|
||||
* @returns {number}
|
||||
*/
|
||||
get discountAmount() {
|
||||
return this.discountType === DiscountType.Amount
|
||||
? this.discount
|
||||
: this.subtotal * (this.discount / 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Discount percentage.
|
||||
* @returns {number | null}
|
||||
*/
|
||||
get discountPercentage(): number | null {
|
||||
return this.discountType === DiscountType.Percentage
|
||||
? this.discount
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate total.
|
||||
* @returns {number}
|
||||
*/
|
||||
get total() {
|
||||
const adjustmentAmount = defaultTo(this.adjustment, 0);
|
||||
|
||||
return this.subtotal - this.discountAmount - adjustmentAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate total in local currency.
|
||||
* @returns {number}
|
||||
*/
|
||||
get totalLocal() {
|
||||
return this.total * this.exchangeRate;
|
||||
}
|
||||
get subtotal() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate subtotal in local currency.
|
||||
* @returns {number}
|
||||
*/
|
||||
get subtotalLocal() {
|
||||
return this.localAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discount amount.
|
||||
* @returns {number}
|
||||
*/
|
||||
get discountAmount() {
|
||||
return this.discountType === DiscountType.Amount
|
||||
? this.discount
|
||||
: this.subtotal * (this.discount / 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Discount percentage.
|
||||
* @returns {number | null}
|
||||
*/
|
||||
get discountPercentage(): number | null {
|
||||
return this.discountType === DiscountType.Percentage ? this.discount : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate total.
|
||||
* @returns {number}
|
||||
*/
|
||||
get total() {
|
||||
const adjustmentAmount = defaultTo(this.adjustment, 0);
|
||||
|
||||
return this.subtotal - this.discountAmount - adjustmentAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate total in local currency.
|
||||
* @returns {number}
|
||||
*/
|
||||
get totalLocal() {
|
||||
return this.total * this.exchangeRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Estimate amount in local currency.
|
||||
@@ -374,13 +375,6 @@ export class SaleEstimate extends TenantBaseModel {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the default custom views, roles and columns.
|
||||
*/
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search roles.
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,7 @@ export const ERRORS = {
|
||||
};
|
||||
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const SaleInvoiceDefaultViews = [
|
||||
{
|
||||
name: 'Draft',
|
||||
slug: 'draft',
|
||||
|
||||
@@ -16,11 +16,14 @@ import { InjectAttachable } from '@/modules/Attachments/decorators/InjectAttacha
|
||||
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { SaleInvoiceMeta } from './SaleInvoice.meta';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { SaleInvoiceDefaultViews } from '../constants';
|
||||
|
||||
@InjectAttachable()
|
||||
@ExportableModel()
|
||||
@InjectModelMeta(SaleInvoiceMeta)
|
||||
export class SaleInvoice extends TenantBaseModel{
|
||||
@InjectModelDefaultViews(SaleInvoiceDefaultViews)
|
||||
export class SaleInvoice extends TenantBaseModel {
|
||||
public taxAmountWithheld: number;
|
||||
public balance: number;
|
||||
public paymentAmount: number;
|
||||
@@ -512,7 +515,9 @@ export class SaleInvoice extends TenantBaseModel{
|
||||
TaxRateTransaction,
|
||||
} = require('../../TaxRates/models/TaxRateTransaction.model');
|
||||
const { Document } = require('../../ChromiumlyTenancy/models/Document');
|
||||
const { MatchedBankTransaction } = require('../../BankingMatching/models/MatchedBankTransaction');
|
||||
const {
|
||||
MatchedBankTransaction,
|
||||
} = require('../../BankingMatching/models/MatchedBankTransaction');
|
||||
const {
|
||||
TransactionPaymentServiceEntry,
|
||||
} = require('../../PaymentServices/models/TransactionPaymentServiceEntry.model');
|
||||
@@ -724,24 +729,10 @@ export class SaleInvoice extends TenantBaseModel{
|
||||
[changeMethod]('payment_amount', Math.abs(amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sale invoice meta.
|
||||
*/
|
||||
// static get meta() {
|
||||
// return SaleInvoiceMeta;
|
||||
// }
|
||||
|
||||
static dueAmountFieldSortQuery(query, role) {
|
||||
query.modify('sortByDueAmount', role.order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the default custom views, roles and columns.
|
||||
*/
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model searchable.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const DEFAULT_RECEIPT_MAIL_SUBJECT =
|
||||
'Receipt {Receipt Number} from {Company Name}';
|
||||
|
||||
|
||||
export const DEFAULT_RECEIPT_MAIL_CONTENT = `Hi {Customer Name},
|
||||
|
||||
Here's receipt # {Receipt Number} for Receipt {Receipt Amount}
|
||||
@@ -29,7 +29,7 @@ export const ERRORS = {
|
||||
};
|
||||
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const SaleReceiptDefaultViews = [
|
||||
{
|
||||
name: 'Draft',
|
||||
slug: 'draft',
|
||||
|
||||
@@ -16,6 +16,8 @@ import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.dec
|
||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { SaleReceiptMeta } from './SaleReceipt.meta';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { SaleReceiptDefaultViews } from '../constants';
|
||||
|
||||
const ExtendedModel = R.pipe(
|
||||
CustomViewBaseModelMixin,
|
||||
@@ -27,6 +29,7 @@ const ExtendedModel = R.pipe(
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(SaleReceiptMeta)
|
||||
@InjectModelDefaultViews(SaleReceiptDefaultViews)
|
||||
export class SaleReceipt extends ExtendedModel {
|
||||
public amount!: number;
|
||||
public exchangeRate!: number;
|
||||
@@ -371,20 +374,6 @@ export class SaleReceipt extends ExtendedModel {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sale invoice meta.
|
||||
*/
|
||||
// static get meta() {
|
||||
// return SaleReceiptSettings;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieve the default custom views, roles and columns.
|
||||
*/
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@ export const ERRORS = {
|
||||
};
|
||||
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const VendorCreditDefaultViews = [
|
||||
{
|
||||
name: 'vendor_credit.view.draft',
|
||||
slug: 'draft',
|
||||
|
||||
@@ -9,10 +9,13 @@ import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.dec
|
||||
import { ImportableModel } from '@/modules/Import/decorators/Import.decorator';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { VendorCreditMeta } from './VendorCredit.meta';
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { VendorCreditDefaultViews } from '../constants';
|
||||
|
||||
@ExportableModel()
|
||||
@ImportableModel()
|
||||
@InjectModelMeta(VendorCreditMeta)
|
||||
@InjectModelDefaultViews(VendorCreditDefaultViews)
|
||||
export class VendorCredit extends TenantBaseModel {
|
||||
vendorId: number;
|
||||
amount: number;
|
||||
@@ -367,20 +370,6 @@ export class VendorCredit extends TenantBaseModel {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// static get meta() {
|
||||
// return VendorCreditMeta;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieve the default custom views, roles and columns.
|
||||
*/
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const DEFAULT_VIEW_COLUMNS = [];
|
||||
|
||||
export const DEFAULT_VIEWS = [
|
||||
export const VendorDefaultViews = [
|
||||
{
|
||||
name: 'Overdue',
|
||||
slug: 'overdue',
|
||||
|
||||
@@ -11,21 +11,12 @@ import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||
import { InjectModelMeta } from '@/modules/Tenancy/TenancyModels/decorators/InjectModelMeta.decorator';
|
||||
import { VendorMeta } from './Vendor.meta';
|
||||
|
||||
// class VendorQueryBuilder extends PaginationQueryBuilder {
|
||||
// constructor(...args) {
|
||||
// super(...args);
|
||||
|
||||
// this.onBuild((builder) => {
|
||||
// if (builder.isFind() || builder.isDelete() || builder.isUpdate()) {
|
||||
// builder.where('contact_service', 'vendor');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
import { InjectModelDefaultViews } from '@/modules/Views/decorators/InjectModelDefaultViews.decorator';
|
||||
import { VendorDefaultViews } from '../constants';
|
||||
|
||||
@ExportableModel()
|
||||
@InjectModelMeta(VendorMeta)
|
||||
@InjectModelDefaultViews(VendorDefaultViews)
|
||||
export class Vendor extends TenantBaseModel {
|
||||
contactService: string;
|
||||
contactType: string;
|
||||
@@ -196,17 +187,6 @@ export class Vendor extends TenantBaseModel {
|
||||
};
|
||||
}
|
||||
|
||||
// static get meta() {
|
||||
// return VendorSettings;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Retrieve the default custom views, roles and columns.
|
||||
// */
|
||||
// static get defaultViews() {
|
||||
// return DEFAULT_VIEWS;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Model search attributes.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Transformer } from '../Transformer/Transformer';
|
||||
import { View } from './models/View.model';
|
||||
|
||||
export class GetResourceViewTransformer extends Transformer {
|
||||
public includeAttributes = (): string[] => {
|
||||
return ['name'];
|
||||
};
|
||||
|
||||
name(view: View) {
|
||||
return this.context.i18n.t(view.name);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,17 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { View } from './models/View.model';
|
||||
import { ResourceService } from '../Resource/ResourceService';
|
||||
import { I18nService } from 'nestjs-i18n';
|
||||
import { TransformerInjectable } from '../Transformer/TransformerInjectable.service';
|
||||
import { GetResourceViewTransformer } from './GetResourceView.transformer';
|
||||
|
||||
@Injectable()
|
||||
export class GetResourceViewsService {
|
||||
constructor(private readonly resourceService: ResourceService) {}
|
||||
constructor(
|
||||
private readonly resourceService: ResourceService,
|
||||
private readonly transformerInjectable: TransformerInjectable,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Listing resource views.
|
||||
* @param {string} resourceModel -
|
||||
@@ -16,6 +23,9 @@ export class GetResourceViewsService {
|
||||
// Default views.
|
||||
const defaultViews = resourceModel().getDefaultViews();
|
||||
|
||||
return defaultViews;
|
||||
return this.transformerInjectable.transform(
|
||||
defaultViews,
|
||||
new GetResourceViewTransformer(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,38 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiExtraModels,
|
||||
ApiOperation,
|
||||
ApiParam,
|
||||
ApiResponse,
|
||||
ApiTags,
|
||||
getSchemaPath,
|
||||
} from '@nestjs/swagger';
|
||||
import { GetResourceViewsService } from './GetResourceViews.service';
|
||||
import { ViewResponseDto } from './dtos/ViewResponse.dto';
|
||||
|
||||
@Controller('views')
|
||||
@ApiTags('Views')
|
||||
@ApiExtraModels(ViewResponseDto)
|
||||
export class ViewsController {
|
||||
constructor(
|
||||
private readonly getResourceViewsService: GetResourceViewsService,
|
||||
) {}
|
||||
|
||||
@Get('/resource/:resourceModel')
|
||||
@ApiResponse({ status: 200, description: 'Specific resource views' })
|
||||
@ApiParam({
|
||||
name: 'resourceModel',
|
||||
description: 'The resource model to get views for',
|
||||
type: String,
|
||||
})
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Specific resource views',
|
||||
schema: { $ref: getSchemaPath(ViewResponseDto) },
|
||||
})
|
||||
@ApiOperation({ summary: 'Get the given resource views' })
|
||||
async getResourceViews(@Param('resourceModel') resourceModel: string) {
|
||||
const views =
|
||||
await this.getResourceViewsService.getResourceViews(resourceModel);
|
||||
return { views };
|
||||
return views;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
export function InjectModelDefaultViews(defaultViews: any[]) {
|
||||
return function (target: any) {
|
||||
// Define the defaultViews static property on the class
|
||||
Object.defineProperty(target, 'defaultViews', {
|
||||
get: function () {
|
||||
return defaultViews;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
return target;
|
||||
};
|
||||
}
|
||||
30
packages/server/src/modules/Views/dtos/RoleResponse.dto.ts
Normal file
30
packages/server/src/modules/Views/dtos/RoleResponse.dto.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class RoleResponseDto {
|
||||
@ApiProperty({ description: 'The unique identifier of the role' })
|
||||
id: number;
|
||||
|
||||
@ApiProperty({ description: 'The index of the role' })
|
||||
index: number;
|
||||
|
||||
@ApiProperty({ description: 'The field key associated with the role' })
|
||||
fieldKey: string;
|
||||
|
||||
@ApiProperty({
|
||||
description:
|
||||
'The comparator used for the role (equals, not_equal, contains, not_contain)',
|
||||
})
|
||||
comparator: string;
|
||||
|
||||
@ApiProperty({ description: 'The value to compare against' })
|
||||
value: string;
|
||||
|
||||
@ApiProperty({ description: 'The ID of the view this role belongs to' })
|
||||
viewId: number;
|
||||
|
||||
@ApiProperty({ description: 'The creation timestamp' })
|
||||
createdAt: Date;
|
||||
|
||||
@ApiProperty({ description: 'The last update timestamp' })
|
||||
updatedAt: Date;
|
||||
}
|
||||
44
packages/server/src/modules/Views/dtos/ViewResponse.dto.ts
Normal file
44
packages/server/src/modules/Views/dtos/ViewResponse.dto.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { ViewColumn } from '../models/ViewColumn.model';
|
||||
import { RoleResponseDto } from './RoleResponse.dto';
|
||||
|
||||
export class ViewResponseDto {
|
||||
@ApiProperty({ description: 'The unique identifier of the view' })
|
||||
id: number;
|
||||
|
||||
@ApiProperty({ description: 'The name of the view' })
|
||||
name: string;
|
||||
|
||||
@ApiProperty({ description: 'The slug of the view' })
|
||||
slug: string;
|
||||
|
||||
@ApiProperty({ description: 'Whether the view is predefined' })
|
||||
predefined: boolean;
|
||||
|
||||
@ApiProperty({ description: 'The resource model associated with the view' })
|
||||
resourceModel: string;
|
||||
|
||||
@ApiProperty({ description: 'Whether the view is marked as favourite' })
|
||||
favourite: boolean;
|
||||
|
||||
@ApiProperty({ description: 'The roles logic expression for the view' })
|
||||
rolesLogicExpression: string;
|
||||
|
||||
@ApiProperty({
|
||||
type: [RoleResponseDto],
|
||||
description: 'The roles associated with the view',
|
||||
})
|
||||
roles: RoleResponseDto[];
|
||||
|
||||
@ApiProperty({
|
||||
type: [ViewColumn],
|
||||
description: 'The columns associated with the view',
|
||||
})
|
||||
columns: ViewColumn[];
|
||||
|
||||
@ApiProperty({ description: 'The creation timestamp' })
|
||||
createdAt: Date;
|
||||
|
||||
@ApiProperty({ description: 'The last update timestamp' })
|
||||
updatedAt: Date;
|
||||
}
|
||||
@@ -1,7 +1,14 @@
|
||||
import { Model } from 'objection';
|
||||
import { BaseModel } from '@/models/Model';
|
||||
import { ViewRole } from './ViewRole.model';
|
||||
|
||||
export class View extends BaseModel {
|
||||
name: string;
|
||||
slug: string;
|
||||
rolesLogicExpression: number;
|
||||
|
||||
roles!: Array<ViewRole>;
|
||||
|
||||
/**
|
||||
* Table name.
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,10 @@ import { BaseModel } from '@/models/Model';
|
||||
import { Model } from 'objection';
|
||||
|
||||
export class ViewRole extends BaseModel {
|
||||
index: number;
|
||||
fieldKey: string;
|
||||
comparator: string;
|
||||
value: string;
|
||||
|
||||
/**
|
||||
* Virtual attributes.
|
||||
@@ -11,9 +15,7 @@ export class ViewRole extends BaseModel {
|
||||
}
|
||||
|
||||
static get comparators() {
|
||||
return [
|
||||
'equals', 'not_equal', 'contains', 'not_contain',
|
||||
];
|
||||
return ['equals', 'not_equal', 'contains', 'not_contain'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user