mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat: seed sale receipt views.
This commit is contained in:
@@ -56,6 +56,10 @@ exports.up = (knex) => {
|
||||
{ id: 31, name: 'Rejected', slug: 'rejected', roles_logic_expression: '1', resource_model: 'SaleEstimate', predefined: true },
|
||||
{ id: 32, name: 'Invoiced', slug: 'invoiced', roles_logic_expression: '1', resource_model: 'SaleEstimate', predefined: true },
|
||||
{ id: 33, name: 'Expired', slug: 'expired', roles_logic_expression: '1', resource_model: 'SaleEstimate', predefined: true },
|
||||
|
||||
// Sale receipts.
|
||||
{ id: 34, name: 'Draft', slug: 'draft', roles_logic_expression: '1', resource_model: 'SaleReceipt', predefined: true },
|
||||
{ id: 35, name: 'Closed', slug: 'closed', roles_logic_expression: '1', resource_model: 'SaleReceipt', predefined: true },
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -46,6 +46,10 @@ exports.up = (knex) => {
|
||||
{ field_key: 'status', index: 1, comparator: 'is', value: 'rejected', view_id: 31 },
|
||||
{ field_key: 'status', index: 1, comparator: 'is', value: 'invoiced', view_id: 32 },
|
||||
{ field_key: 'status', index: 1, comparator: 'is', value: 'expired', view_id: 33 },
|
||||
|
||||
// Sale receipts.
|
||||
{ field_key: 'status', index: 1, comparator: 'is', value: 'draft', view_id: 34 },
|
||||
{ field_key: 'status', index: 1, comparator: 'is', value: 'closed', view_id: 35 },
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -42,6 +42,27 @@ export default class SaleReceipt extends TenantModel {
|
||||
return !this.closedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Model modifiers.
|
||||
*/
|
||||
static get modifiers() {
|
||||
return {
|
||||
/**
|
||||
* Filters the closed receipts.
|
||||
*/
|
||||
closed(query) {
|
||||
query.whereNot('closed_at', null);
|
||||
},
|
||||
|
||||
/**
|
||||
* Filters the invoices in draft status.
|
||||
*/
|
||||
draft(query) {
|
||||
query.where('closed_at', null);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
@@ -104,11 +125,78 @@ export default class SaleReceipt extends TenantModel {
|
||||
*/
|
||||
static get fields() {
|
||||
return {
|
||||
amount: {
|
||||
label: 'Amount',
|
||||
column: 'amount',
|
||||
columnType: 'number',
|
||||
fieldType: 'number',
|
||||
},
|
||||
deposit_account: {
|
||||
column: 'deposit_account_id',
|
||||
lable: 'Deposit account',
|
||||
relation: "accounts.id",
|
||||
optionsResource: "account",
|
||||
},
|
||||
customer: {
|
||||
label: 'Customer',
|
||||
column: 'customer_id',
|
||||
fieldType: 'options',
|
||||
optionsResource: 'customers',
|
||||
optionsKey: 'id',
|
||||
optionsLable: 'displayName',
|
||||
},
|
||||
receipt_date: {
|
||||
label: 'Receipt date',
|
||||
column: 'receipt_date',
|
||||
columnType: 'date',
|
||||
fieldType: 'date',
|
||||
},
|
||||
receipt_number: {
|
||||
label: 'Receipt No.',
|
||||
column: 'receipt_number',
|
||||
columnType: 'string',
|
||||
fieldType: 'text',
|
||||
},
|
||||
reference_no: {
|
||||
label: 'Reference No.',
|
||||
column: 'reference_no',
|
||||
columnType: 'text',
|
||||
fieldType: 'text',
|
||||
},
|
||||
receipt_message: {
|
||||
label: 'Receipt message',
|
||||
column: 'receipt_message',
|
||||
columnType: 'text',
|
||||
fieldType: 'text',
|
||||
},
|
||||
statement: {
|
||||
label: 'Statement',
|
||||
column: 'statement',
|
||||
columnType: 'text',
|
||||
fieldType: 'text',
|
||||
},
|
||||
created_at: {
|
||||
label: 'Created at',
|
||||
column: 'created_at',
|
||||
columnType: 'date',
|
||||
},
|
||||
status: {
|
||||
label: 'Status',
|
||||
options: [
|
||||
{ key: 'draft', label: 'Draft', },
|
||||
{ key: 'closed', label: 'Closed' },
|
||||
],
|
||||
query: (query, role) => {
|
||||
switch(role.value) {
|
||||
case 'draft':
|
||||
query.modify('draft');
|
||||
break;
|
||||
case 'closed':
|
||||
query.modify('closed');
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user