Commit 1a6e8873 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Only display invoices to pay on main View

  On invoices tab, only display invoices Unpaid (missing payments).

  This makes easy the user know what is pending to pay and on the 'List all' tab, he can
  search old invoices (and view them all by date)
parent 0173ec07
......@@ -79,6 +79,8 @@ url_list = [
"gadget_slapos_annotated_helper.js",
"gadget_slapos_annotated_helper.html",
"gadget_slapos_annotated_helper.css",
"gadget_erp5_page_slap_all_invoice_list.html",
"gadget_erp5_page_slap_all_invoice_list.js",
"gadget_erp5_page_slap_invoice_list.html",
"gadget_erp5_page_slap_invoice_list.js",
"gadget_erp5_page_slap_load_schema.html",
......
<!DOCTYPE html>
<html>
<!--
data-i18n=Date
data-i18n=Price
data-i18n=Currency
data-i18n=Payment
data-i18n=Download
data-i18n=Invoices
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Site List</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_slapos_utils.js" type="text/javascript"></script>
<script src="gadget_erp5_page_slap_all_invoice_list.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_pt_form_list.html" data-gadget-scope="form_list"></div>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i, value, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("start_date")) {
value = new Date(result.data.rows[i].value.start_date);
result.data.rows[i].value.start_date = {
"field_gadget_param": {
allow_empty_time: 0,
ampm_time_style: 0,
css_class: "date_field",
date_only: true,
description: "The Date",
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": value.toUTCString(),
key: "date",
required: 0,
timezone_style: 0,
title: "Date",
type: "DateTimeField"
}
};
}
if (result.data.rows[i].value.hasOwnProperty("total_price")) {
value = window.parseFloat(result.data.rows[i].value.total_price);
// The field seemms not set precision to display
value = value.toFixed(2); // round on this case for 2 digits as
// float field is bugged.
result.data.rows[i].value.total_price = value;
}
if (1 || (result.data.rows[i].hasOwnProperty("id"))) {
value = result.data.rows[i].value.AccountingTransaction_getPaymentStateAsHateoas;
result.data.rows[i].value.AccountingTransaction_getPaymentStateAsHateoas = {
field_gadget_param : {
css_class: "",
description: "Payment State",
hidden: 0,
"default": {value: value},
key: "translated_simulation_state_title",
url: "gadget_slapos_invoice_state.html",
title: "Payment State",
type: "GadgetField"
}
};
result.data.rows[i].value.download = {
field_gadget_param : {
css_class: "",
description: "Download Invoice",
hidden: 0,
"default": {jio_key: value},
key: "download",
url: "gadget_slapos_invoice_printout.html",
title: "Download",
type: "GadgetField"
}
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
}
return result;
});
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_list')
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
})
.declareMethod("render", function () {
var gadget = this,
lines_limit,
invoices_translation,
translation_list = [
"Date",
"Price",
"Currency",
"Payment",
"Download",
"Invoices",
"Reference"
];
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_list'),
gadget.getSetting("listbox_lines_limit", 20),
gadget.getTranslationList(translation_list)
]);
})
.push(function (result) {
var column_list = [
['reference', result[2][6]],
['start_date', result[2][0]],
['total_price', result[2][1]],
['resource_reference', result[2][2]],
['AccountingTransaction_getPaymentStateAsHateoas', result[2][3]],
['download', result[2][4]]
],
form_list = result[0];
lines_limit = result[1];
invoices_translation = result[2][5];
return form_list.render({
erp5_document: {
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "slap_invoice_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
// XXX FIX ME: Missing default_destination_section_uid=person.getUid()
"query": "urn:jio:allDocs?query=(NOT%20title%3A%22Reversal%20Transaction%20for%20%25%22)%20AND%20(portal_type%3A%20%22Sale%20Invoice%20Transaction%22)",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["creation_date", "descending"]],
"title": invoices_translation,
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
});
})
.push(function () {
return RSVP.all([
gadget.getSetting("hateoas_url"),
window.getSettingMe(gadget)
]);
})
.push(function (url_list) {
return RSVP.all([
gadget.jio_getAttachment("contract_relative_url",
url_list[0] + url_list[1] + "/Person_getCloudContractRelated?return_json=True"),
gadget.updatePanel({jio_key: "accounting_module"}),
gadget.getSetting('frontpage_gadget')
]);
})
.push(function (result) {
var promise_list = [
gadget.getUrlFor({command: "change", options: {"page": result[2]}}),
gadget.getUrlFor({command: "change", options: {"page": "slap_rss_ticket",
"jio_key": "accounting_module"}}),
gadget.getUrlFor({command: "change", options: {"page": 'slap_invoice_list'}})
];
if (result[0]) {
promise_list.push(
gadget.getUrlFor({command: "change", options: {"jio_key": result[0],
"page": "slap_controller"}})
);
}
return RSVP.all(promise_list);
})
.push(function (result) {
var header_dict = {
page_title: invoices_translation,
selection_url: result[0],
tab_url: result[2],
rss_url: result[1],
filter_action: true
};
if (result[3]) {
header_dict.contract_url = result[3];
}
return gadget.updateHeader(header_dict);
});
});
}(window, rJS, RSVP));
......@@ -52,13 +52,13 @@
result.data.rows[i].value.total_price = value;
}
if (1 || (result.data.rows[i].hasOwnProperty("id"))) {
value = result.data.rows[i].id;
result.data.rows[i].value.translated_simulation_state_title = {
value = result.data.rows[i].value.AccountingTransaction_getPaymentStateAsHateoas;
result.data.rows[i].value.AccountingTransaction_getPaymentStateAsHateoas = {
field_gadget_param : {
css_class: "",
description: "Payment State",
hidden: 0,
"default": {jio_key: value},
"default": {value: value},
key: "translated_simulation_state_title",
url: "gadget_slapos_invoice_state.html",
title: "Payment State",
......@@ -125,7 +125,7 @@
['start_date', result[2][0]],
['total_price', result[2][1]],
['resource_reference', result[2][2]],
['translated_simulation_state_title', result[2][3]],
['AccountingTransaction_getPaymentStateAsHateoas', result[2][3]],
['download', result[2][4]]
],
form_list = result[0];
......@@ -142,9 +142,12 @@
"editable_column_list": [],
"key": "slap_invoice_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
// XXX FIX ME: Missing default_destination_section_uid=person.getUid()
"query": "urn:jio:allDocs?query=(NOT%20title%3A%22Reversal%20Transaction%20for%20%25%22)%20AND%20(portal_type%3A%20%22Sale%20Invoice%20Transaction%22)",
"list_method": "AccountingTransactionModule_getUnpaidInvoiceList",
"list_method_template": result[1] + "ERP5Document_getHateoas?mode=search&" +
"list_method=AccountingTransactionModule_getUnpaidInvoiceList&relative_url=" +
gadget.state.jio_key + "{&query,select_list*,limit*,sort_on*,local_roles*}",
"query": "urn:jio:allDocs?query=",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
......@@ -186,7 +189,8 @@
var promise_list = [
gadget.getUrlFor({command: "change", options: {"page": result[2]}}),
gadget.getUrlFor({command: "change", options: {"page": "slap_rss_ticket",
"jio_key": "accounting_module"}})
"jio_key": "accounting_module"}}),
gadget.getUrlFor({command: "change", options: {"page": 'slap_all_invoice_list'}})
];
if (result[0]) {
promise_list.push(
......@@ -200,11 +204,12 @@
var header_dict = {
page_title: invoices_translation,
selection_url: result[0],
list_all_url: result[2],
rss_url: result[1],
filter_action: true
};
if (result[2]) {
header_dict.contract_url = result[2];
if (result[3]) {
header_dict.contract_url = result[3];
}
return gadget.updateHeader(header_dict);
});
......
......@@ -56,7 +56,8 @@
['transfer_url', 'Transfer', 'exchange'],
['accept_url', 'Accept', 'check-circle'],
['reject_url', 'Reject', 'ban'],
['contract_url', 'Contract', 'usd']
['contract_url', 'Contract', 'usd'],
['list_all_url', 'Show all', 'eye']
],
header_button_template = function (data) {
// <form><button name='{{name}}' data-i18n="{{title}}" type='submit' class='ui-icon-{{icon}} ui-btn-icon-left {{class}}'>{{title}}</button></form>
......
......@@ -37,6 +37,8 @@ web_page_module/rjs_gadget_erp5_page_slap_add_software_installation_html
web_page_module/rjs_gadget_erp5_page_slap_add_software_installation_js
web_page_module/rjs_gadget_erp5_page_slap_add_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_add_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_all_invoice_list_html
web_page_module/rjs_gadget_erp5_page_slap_all_invoice_list_js
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_html
......
......@@ -34,6 +34,8 @@ web_page_module/rjs_gadget_erp5_page_slap_add_software_installation_html
web_page_module/rjs_gadget_erp5_page_slap_add_software_installation_js
web_page_module/rjs_gadget_erp5_page_slap_add_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_add_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_all_invoice_list_html
web_page_module/rjs_gadget_erp5_page_slap_all_invoice_list_js
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_html
web_page_module/rjs_gadget_erp5_page_slap_close_ticket_js
web_page_module/rjs_gadget_erp5_page_slap_compute_node_get_token_html
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment