feat: add models fields labels.

This commit is contained in:
Ahmed Bouhuolia
2020-10-17 19:11:51 +02:00
parent 078098c593
commit bd2ce7ccee
7 changed files with 86 additions and 7 deletions

View File

@@ -1,13 +1,12 @@
import { Inject, Service } from 'typedi';
import { Router, Request, Response, NextFunction } from 'express';
import { check, param, query, ValidationChain, matchedData } from 'express-validator';
import { check, param, query, ValidationChain } from 'express-validator';
import asyncMiddleware from 'api/middleware/asyncMiddleware';
import ItemsService from 'services/Items/ItemsService';
import BaseController from 'api/controllers/BaseController';
import DynamicListingService from 'services/DynamicListing/DynamicListService';
import { ServiceError } from 'exceptions';
import { IItemDTO } from 'interfaces';
import { Request } from 'express-validator/src/base';
@Service()
export default class ItemsController extends BaseController {

View File

@@ -45,4 +45,14 @@ export default {
// config: true,
},
],
manual_journals: [
{
key: 'journal_number_next',
type: 'number',
},
{
key: 'journal_number_prefix',
type: 'string',
},
]
};

View File

@@ -43,5 +43,29 @@
"Credit": "Credit",
"Interest": "Interest",
"Depreciation": "Depreciation",
"Payroll": "Payroll"
"Payroll": "Payroll",
"Type": "Type",
"Name": "Name",
"Sellable": "Sellable",
"Purchasable": "Purchasable",
"Sell price": "Sell price",
"Cost price": "Cost price",
"User": "User",
"Category": "Category",
"Note": "Note",
"Quantity on hand": "Quantity on hand",
"Purchase description": "Purchase description",
"Sell description": "Sell description",
"Sell account": "Sell account",
"Cost account": "Cost account",
"Inventory account": "Inventory account",
"Payment date": "Payment date",
"Payment account": "Payment account",
"Amount": "Amount",
"Reference No.": "Reference No.",
"Published": "Published",
"Journal number": "Journal number",
"Status": "Status",
"Journal type": "Journal type",
"Date": "Date"
}

View File

@@ -125,33 +125,42 @@ export default class Expense extends TenantModel {
static get fields() {
return {
payment_date: {
label: 'Payment date',
column: 'payment_date',
},
payment_account: {
label: 'Payment account',
column: 'payment_account_id',
relation: 'accounts.id',
},
amount: {
label: 'Amount',
column: 'total_amount',
},
currency_code: {
label: 'Currency',
column: 'currency_code',
},
reference_no: {
label: 'Reference No.',
column: 'reference_no'
},
description: {
label: 'Description',
column: 'description',
},
published: {
label: 'Published',
column: 'published',
},
user: {
label: 'User',
column: 'user_id',
relation: 'users.id',
relationColumn: 'users.id',
},
created_at: {
label: 'Created at',
column: 'created_at',
},
};

View File

@@ -103,64 +103,83 @@ export default class Item extends TenantModel {
};
}
/**
* Item fields.
*/
static get fields() {
return {
type: {
label: 'Type',
column: 'type',
},
name: {
label: 'Name',
column: 'name',
},
sellable: {
label: 'Sellable',
column: 'sellable',
},
purchasable: {
label: 'Purchasable',
column: 'purchasable',
},
sell_price: {
label: 'Sell price',
column: 'sell_price'
},
cost_price: {
label: 'Cost price',
column: 'cost_price',
},
currency_code: {
label: 'Currency',
column: 'currency_code',
},
cost_account: {
label: 'Cost account',
column: 'cost_account_id',
relation: 'accounts.id',
},
sell_account: {
label: 'Sell account',
column: 'sell_account_id',
relation: 'accounts.id',
},
inventory_account: {
label: "Inventory account",
column: 'inventory_account_id',
relation: 'accounts.id',
},
sell_description: {
label: "Sell description",
column: 'sell_description',
},
purchase_description: {
label: "Purchase description",
column: 'purchase_description',
},
quantity_on_hand: {
label: "Quantity on hand",
column: 'quantity_on_hand',
},
note: {
label: 'Note',
column: 'note',
},
category: {
label: "Category",
column: 'category_id',
relation: 'categories.id',
},
user: {
label: 'User',
column: 'user_id',
relation: 'users.id',
relationColumn: 'users.id',
},
created_at: {
label: 'Created at',
column: 'created_at',
}
};

View File

@@ -42,40 +42,52 @@ export default class ItemCategory extends TenantModel {
};
}
/**
* Item category fields.
*/
static get fields() {
return {
name: {
label: 'Name',
column: 'name',
},
description: {
label: 'Description',
column: 'description',
},
parent_category_id: {
label: 'Parent category',
column: 'parent_category_id',
relation: 'items_categories.id',
relationColumn: 'items_categories.id',
},
user: {
label: 'User',
column: 'user_id',
relation: 'users.id',
relationColumn: 'users.id',
},
cost_account: {
label: 'Cost account',
column: 'cost_account_id',
relation: 'accounts.id',
},
sell_account: {
label: 'Sell account',
column: 'sell_account_id',
relation: 'accounts.id',
},
inventory_account: {
label: 'Inventory account',
column: 'inventory_account_id',
relation: 'accounts.id',
},
cost_method: {
label: 'Cost method',
column: 'cost_method',
},
created_at: {
label: 'Created at',
column: 'created_at',
},
};

View File

@@ -17,9 +17,6 @@ export default class ManualJournal extends TenantModel {
return ['createdAt', 'updatedAt'];
}
/**
*
*/
static get resourceable() {
return true;
}
@@ -67,32 +64,41 @@ export default class ManualJournal extends TenantModel {
static get fields() {
return {
date: {
label: 'Date',
column: 'date',
},
journal_number: {
label: 'Journal number',
column: 'journal_number',
},
reference: {
label: 'Reference No.',
column: 'reference',
},
status: {
label: 'Status',
column: 'status',
},
amount: {
label: 'Amount',
column: 'amount',
},
description: {
label: 'Description',
column: 'description',
},
user: {
label: 'User',
column: 'user_id',
relation: 'users.id',
relationColumn: 'users.id',
},
journal_type: {
label: 'Journal type',
column: 'journal_type',
},
created_at: {
label: 'Created at',
column: 'created_at',
},
};