Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
f1dc41ed
Commit
f1dc41ed
authored
May 17, 2024
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_panel: Handle deposit outstanding amount as a list
Since it should handle multiple *_section.
parent
752f6121
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
20 deletions
+42
-20
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
...e_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
+31
-19
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.py
...createExternalPaymentTransactionFromDepositAndRedirect.py
+11
-1
No files found.
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/AccountingTransactionModule_getCreateExternalPaymentTransactionOnSlaposPanelHTML.py
View file @
f1dc41ed
...
...
@@ -16,33 +16,45 @@ entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if
entity
is
None
:
return
'<p>Nothing to pay with your account</p>'
is_payment_configured
=
1
for
currency_value
,
secure_service_relative_url
in
[
(
portal
.
currency_module
.
EUR
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
# (portal.currency_module.CNY, portal.Base_getWechatServiceRelativeUrl())
]:
currency_uid
=
currency_value
.
getUid
()
if
secure_service_relative_url
is
not
None
:
# Existing invoices
outstanding_amount_list
=
entity
.
Entity_getOutstandingAmountList
(
ledger_uid
=
ledger_uid
,
resource_uid
=
currency_uid
)
for
outstanding_amount
in
outstanding_amount_list
:
html_content
+=
"""
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
"""
%
{
'total_price'
:
outstanding_amount
.
total_price
,
'currency'
:
outstanding_amount
.
getPriceCurrencyReference
(),
'payment_url'
:
'%s/SaleInvoiceTransaction_createExternalPaymentTransactionFromAmountAndRedirect'
%
outstanding_amount
.
absolute_url
()
}
deposit_price
=
entity
.
Entity_getOutstandingDepositAmount
(
currency_uid
)
if
0
<
deposit_price
:
if
secure_service_relative_url
is
None
:
is_payment_configured
=
0
outstanding_amount_list
=
entity
.
Entity_getOutstandingAmountList
(
ledger_uid
=
ledger_uid
,
resource_uid
=
currency_uid
)
for
outstanding_amount
in
outstanding_amount_list
:
if
not
is_payment_configured
:
return
'<p>Please contact us to handle your payment</p>'
html_content
+=
"""
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
"""
%
{
'total_price'
:
outstanding_amount
.
total_price
,
'currency'
:
outstanding_amount
.
getPriceCurrencyReference
(),
'payment_url'
:
'%s/SaleInvoiceTransaction_createExternalPaymentTransactionFromAmountAndRedirect'
%
outstanding_amount
.
absolute_url
()
}
outstanding_amount_list
=
entity
.
Entity_getOutstandingDepositAmountList
(
resource_uid
=
currency_uid
,
ledger_uid
=
ledger_uid
)
for
outstanding_amount
in
outstanding_amount_list
:
if
0
<
outstanding_amount
.
total_price
:
if
not
is_payment_configured
:
return
'<p>Please contact us to handle your payment</p>'
html_content
+=
"""
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
"""
%
{
'total_price'
:
deposit
_price
,
'currency'
:
currency_value
.
getReference
(),
'total_price'
:
outstanding_amount
.
total
_price
,
'currency'
:
currency_value
.
getReference
(),
'payment_url'
:
'%s/Entity_createExternalPaymentTransactionFromDepositAndRedirect?currency_reference=%s'
%
(
entity
.
absolute_url
(),
currency_value
.
getReference
())
}
...
...
master/bt5/slapos_panel/SkinTemplateItem/portal_skins/slapos_panel/Entity_createExternalPaymentTransactionFromDepositAndRedirect.py
View file @
f1dc41ed
...
...
@@ -10,10 +10,20 @@ if currency_reference:
if
currency_value
is
None
:
raise
ValueError
(
"Unknown Currency: %s"
%
currency_reference
)
ledger_uid
=
portal
.
portal_categories
.
ledger
.
automated
.
getUid
()
currency_uid
=
currency_value
.
getUid
()
payment_mode
=
context
.
Base_getPaymentModeForCurrency
(
currency_value
.
getUid
())
assert
payment_mode
is
not
None
deposit_price
=
context
.
Entity_getOutstandingDepositAmount
(
currency_value
.
getUid
())
outstanding_amount_list
=
context
.
Entity_getOutstandingDepositAmountList
(
resource_uid
=
currency_uid
,
ledger_uid
=
ledger_uid
)
if
len
(
outstanding_amount_list
)
!=
1
:
raise
ValueError
(
"It was expected exactly one amount to pay for %s currency (%s found)"
%
(
currency_uid
,
outstanding_amount_list
))
deposit_price
=
outstanding_amount_list
[
0
].
total_price
if
0
>=
deposit_price
:
raise
ValueError
(
"Nothing to pay"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment