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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
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()
...
@@ -16,33 +16,45 @@ entity = portal.portal_membership.getAuthenticatedMember().getUserValue()
if
entity
is
None
:
if
entity
is
None
:
return
'<p>Nothing to pay with your account</p>'
return
'<p>Nothing to pay with your account</p>'
is_payment_configured
=
1
for
currency_value
,
secure_service_relative_url
in
[
for
currency_value
,
secure_service_relative_url
in
[
(
portal
.
currency_module
.
EUR
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
(
portal
.
currency_module
.
EUR
,
portal
.
Base_getPayzenServiceRelativeUrl
()),
# (portal.currency_module.CNY, portal.Base_getWechatServiceRelativeUrl())
# (portal.currency_module.CNY, portal.Base_getWechatServiceRelativeUrl())
]:
]:
currency_uid
=
currency_value
.
getUid
()
currency_uid
=
currency_value
.
getUid
()
if
secure_service_relative_url
is
not
None
:
# Existing invoices
if
secure_service_relative_url
is
None
:
outstanding_amount_list
=
entity
.
Entity_getOutstandingAmountList
(
is_payment_configured
=
0
ledger_uid
=
ledger_uid
,
resource_uid
=
currency_uid
outstanding_amount_list
=
entity
.
Entity_getOutstandingAmountList
(
)
ledger_uid
=
ledger_uid
,
for
outstanding_amount
in
outstanding_amount_list
:
resource_uid
=
currency_uid
html_content
+=
"""
)
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
for
outstanding_amount
in
outstanding_amount_list
:
"""
%
{
if
not
is_payment_configured
:
'total_price'
:
outstanding_amount
.
total_price
,
return
'<p>Please contact us to handle your payment</p>'
'currency'
:
outstanding_amount
.
getPriceCurrencyReference
(),
'payment_url'
:
'%s/SaleInvoiceTransaction_createExternalPaymentTransactionFromAmountAndRedirect'
%
outstanding_amount
.
absolute_url
()
html_content
+=
"""
}
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
"""
%
{
deposit_price
=
entity
.
Entity_getOutstandingDepositAmount
(
currency_uid
)
'total_price'
:
outstanding_amount
.
total_price
,
if
0
<
deposit_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
+=
"""
html_content
+=
"""
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
<p><a href="%(payment_url)s">%(total_price)s %(currency)s</a></p>
"""
%
{
"""
%
{
'total_price'
:
deposit
_price
,
'total_price'
:
outstanding_amount
.
total
_price
,
'currency'
:
currency_value
.
getReference
(),
'currency'
:
currency_value
.
getReference
(),
'payment_url'
:
'%s/Entity_createExternalPaymentTransactionFromDepositAndRedirect?currency_reference=%s'
%
(
entity
.
absolute_url
(),
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:
...
@@ -10,10 +10,20 @@ if currency_reference:
if
currency_value
is
None
:
if
currency_value
is
None
:
raise
ValueError
(
"Unknown Currency: %s"
%
currency_reference
)
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
())
payment_mode
=
context
.
Base_getPaymentModeForCurrency
(
currency_value
.
getUid
())
assert
payment_mode
is
not
None
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
:
if
0
>=
deposit_price
:
raise
ValueError
(
"Nothing to pay"
)
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