2595 - Added invoiceIn module #545

Merged
carlosjr merged 11 commits from 2595-invoiceIn-index into dev 2021-03-03 11:47:43 +00:00
10 changed files with 74 additions and 13 deletions
Showing only changes of commit c270ec6207 - Show all commits

View File

@ -0,0 +1 @@
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) VALUES ('InvoiceIn', '*', '*', 'ALLOW', 'ROLE', 'administrative');

View File

@ -29,7 +29,7 @@ export default class Contextmenu {
if (!event.defaultPrevented)
event.preventDefault();
if (!this.isFilterEnabled()) return;
if (!this.isMenuEnabled()) return;
const parent = this.$.contextmenu;
parent.style.top = event.pageY + 'px';
@ -121,13 +121,31 @@ export default class Contextmenu {
return isEnabled != 'false';
}
isMenuEnabled() {
if (!this.rowHeader) return true;
const isEnabled = this.rowHeader.getAttribute('menu-enabled');
return isEnabled != 'false';
}
/**
* Returns true if filter
* by selection is allowed
* by selection is enabled and
* the menu can be interacted
*
* @return {Boolean}
*/
isFilterAllowed() {
return this.isActionAllowed() && this.isFilterEnabled();
}
/**
* Returns true if the
* context menu can be interacted
*
* @return {Boolean}
*/
isActionAllowed() {
if (!this.target) return false;
const isTableCell = this.target.closest('vn-td, .vn-td');
@ -179,9 +197,13 @@ export default class Contextmenu {
if (!where) return;
const whereKeys = Object.keys(where);
for (let key of whereKeys)
for (let key of whereKeys) {
removeProp(where, filterKey, key);
if (!Object.keys(where))
delete userFilter.where;
}
function removeProp(instance, findProp, prop) {
if (prop == findProp)
delete instance[prop];
@ -208,6 +230,16 @@ export default class Contextmenu {
const userParams = this.model.userParams;
this.model.applyFilter(null, userParams);
}
/**
* Copies the current field
* value to the clipboard
*/
copyValue() {
console.log(this.field);
if (navigator && navigator.clipboard)
navigator.clipboard.writeText(this.fieldValue);
}
}
Contextmenu.$inject = ['$element', '$scope', '$transclude'];

View File

@ -60,11 +60,6 @@ module.exports = Self => {
type: 'number',
description: 'The account number'
},
{
arg: 'hasPdf',
type: 'boolean',
description: 'Whether the the invoice has PDF or not',
},
{
arg: 'isBooked',
type: 'boolean',
@ -90,12 +85,9 @@ module.exports = Self => {
return /^\d+$/.test(value)
? {'ii.id': value}
: {'s.name': {like: `%${value}%`}};
case 'hasPdf':
return {'i.hasPdf': value};
case 'account':
case 'fi':
return {[`s.${param}`]: value};
case 'amount':
case 'supplierRef':
case 'serialNumber':
case 'serial':
@ -130,13 +122,25 @@ module.exports = Self => {
LEFT JOIN company co ON co.id = ii.companyFk`
);
stmt.merge(conn.makeWhere(filter.where));
const sqlWhere = conn.makeWhere(filter.where);
stmt.merge(sqlWhere);
stmt.merge(`GROUP BY ii.id`);
const amount = ctx.args.amount;
if (amount) {
stmt.merge({
sql: `HAVING SUM(iid.amount) = ?`,
params: [amount],
});
}
stmt.merge(conn.makePagination(filter));
let itemsIndex = stmts.push(stmt) - 1;
let sql = ParameterizedSQL.join(stmts, ';');
console.log(sql.sql);
let result = await conn.executeStmt(sql);
return itemsIndex === 0 ? result : result[itemsIndex];
};

View File

@ -16,7 +16,7 @@
<vn-th field="account">Account</vn-th>
<vn-th field="issued" expand>Issued</vn-th>
<vn-th field="isBooked" center>Is booked</vn-th>
<vn-th field="amount">Amount</vn-th>
<vn-th field="amount" filter-enabled="false">Amount</vn-th>
<vn-th></vn-th>
</vn-tr>
</vn-thead>
@ -93,6 +93,7 @@
Remove all filters
</vn-item>
<vn-item translate
ng-if="contextmenu.isActionAllowed()"
ng-click="contextmenu.copyValue()" >
Copy value
</vn-item>

View File

@ -30,6 +30,8 @@ export default class Controller extends Section {
case 'account':
case 'fi':
return {[`s.${param}`]: value};
default:
return {[param]: value};
}
}
}

View File

@ -109,5 +109,10 @@
ng-click="contextmenu.removeAllFilters()" >
Remove all filters
</vn-item>
<vn-item translate
ng-if="contextmenu.isActionAllowed()"
ng-click="contextmenu.copyValue()" >
Copy value
</vn-item>
</slot-menu>
</vn-contextmenu>

View File

@ -153,5 +153,10 @@
ng-click="contextmenu.removeAllFilters()" >
Remove all filters
</vn-item>
<vn-item translate
ng-if="contextmenu.isActionAllowed()"
ng-click="contextmenu.copyValue()" >
Copy value
</vn-item>
</slot-menu>
</vn-contextmenu>

View File

@ -213,5 +213,10 @@
ng-click="contextmenu.removeAllFilters()" >
Remove all filters
</vn-item>
<vn-item translate
ng-if="contextmenu.isActionAllowed()"
ng-click="contextmenu.copyValue()" >
Copy value
</vn-item>
</slot-menu>
</vn-contextmenu>

View File

@ -9,4 +9,5 @@ Filter by selection: Filtro por selección
Exclude selection: Excluir selección
Remove filter: Quitar filtro por selección
Remove all filters: Eliminar todos los filtros
Copy value: Copiar valor
No verified data: Sin datos comprobados

View File

@ -106,5 +106,10 @@
ng-click="contextmenu.removeAllFilters()" >
Remove all filters
</vn-item>
<vn-item translate
ng-if="contextmenu.isActionAllowed()"
ng-click="contextmenu.copyValue()" >
Copy value
</vn-item>
</slot-menu>
</vn-contextmenu>