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
21
Merge Requests
21
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
a6bae06d
Commit
a6bae06d
authored
Jan 29, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_payzen: Include script to get Appropriate State of Payment to show to the user.
parent
44493e2e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
189 additions
and
0 deletions
+189
-0
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/AccountingTransaction_getPaymentState.py
...ns/slapos_payzen/AccountingTransaction_getPaymentState.py
+48
-0
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/AccountingTransaction_getPaymentState.xml
...s/slapos_payzen/AccountingTransaction_getPaymentState.xml
+62
-0
master/bt5/slapos_payzen/TestTemplateItem/portal_components/test.erp5.testSlapOSPayzenSkins.py
...Item/portal_components/test.erp5.testSlapOSPayzenSkins.py
+79
-0
No files found.
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/AccountingTransaction_getPaymentState.py
0 → 100644
View file @
a6bae06d
simulation_state
=
context
.
getSimulationState
()
if
simulation_state
in
(
"cancelled"
,
"deleted"
,
"draft"
):
result
=
"Cancelled"
elif
simulation_state
in
(
"planned"
,
"confirmed"
,
"ordered"
,
"started"
):
result
=
"Ongoing"
else
:
portal
=
context
.
getPortalObject
()
paid
=
True
for
line
in
context
.
getMovementList
(
portal
.
getPortalAccountingMovementTypeList
()):
node_value
=
line
.
getSourceValue
(
portal_type
=
'Account'
)
if
node_value
.
getAccountType
()
==
'asset/receivable'
:
if
not
line
.
hasGroupingReference
():
paid
=
False
break
reversal
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Sale Invoice Transaction"
,
simulation_state
=
"stopped"
,
default_causality_uid
=
context
.
getUid
()
)
if
reversal
is
not
None
and
(
context
.
getTotalPrice
()
+
reversal
.
getTotalPrice
())
==
0
:
result
=
"Cancelled"
elif
paid
:
result
=
"Paid"
elif
context
.
getTotalPrice
()
==
0
:
result
=
"Free!"
else
:
# Check if there is an ongoing payzen payment
payment
=
context
.
SaleInvoiceTransaction_getPayzenPaymentRelatedValue
()
if
payment
is
None
:
result
=
"Unpaid"
else
:
# Check if mapping exists
person
=
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
payzen_id
=
person
.
Person_restrictMethodAsShadowUser
(
shadow_document
=
person
,
callable_object
=
payment
.
PaymentTransaction_getPayzenId
,
argument_list
=
[])[
0
]
if
payzen_id
is
None
:
result
=
"Pay now"
else
:
result
=
"Waiting for payment confirmation"
return
result
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/AccountingTransaction_getPaymentState.xml
0 → 100644
View file @
a6bae06d
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
AccountingTransaction_getPaymentState
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_payzen/TestTemplateItem/portal_components/test.erp5.testSlapOSPayzenSkins.py
View file @
a6bae06d
...
...
@@ -541,6 +541,85 @@ class TestSlapOSPayzenBase_getPayzenServiceRelativeUrl(SlapOSTestCaseMixinWithAb
result
=
self
.
portal
.
Base_getPayzenServiceRelativeUrl
()
self
.
assertEquals
(
result
,
'portal_secure_payments/slapos_payzen_test'
)
class
TestSlapOSPayzenAccountingTransaction_getPaymentState
(
SlapOSTestCaseMixinWithAbort
):
def
test_AccountingTransaction_getPaymentState_draft_payment
(
self
):
invoice
=
self
.
createSaleInvoiceTransaction
()
self
.
assertEquals
(
"Cancelled"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_deleted_payment
(
self
):
invoice
=
self
.
createSaleInvoiceTransaction
()
invoice
.
delete
()
self
.
assertEquals
(
"Cancelled"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_cancelled_payment
(
self
):
invoice
=
self
.
createSaleInvoiceTransaction
()
invoice
.
cancel
()
self
.
assertEquals
(
"Cancelled"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_planned_payment
(
self
):
invoice
=
self
.
createSaleInvoiceTransaction
()
invoice
.
plan
()
self
.
assertEquals
(
"Ongoing"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_confirmed_payment
(
self
):
invoice
=
self
.
createSaleInvoiceTransaction
()
invoice
.
setStartDate
(
DateTime
())
invoice
.
confirm
()
self
.
assertEquals
(
"Ongoing"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_started_payment
(
self
):
invoice
=
self
.
createSaleInvoiceTransaction
()
invoice
.
start
()
self
.
assertEquals
(
"Ongoing"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_reversed_payment
(
self
):
invoice
=
self
.
createPayzenSaleInvoiceTransaction
()
self
.
tic
()
reversal
=
invoice
.
SaleInvoiceTransaction_createReversalPayzenTransaction
()
self
.
tic
()
self
.
assertEquals
(
"Cancelled"
,
invoice
.
AccountingTransaction_getPaymentState
())
self
.
assertEquals
(
0
,
invoice
.
getTotalPrice
()
+
reversal
.
getTotalPrice
())
def
test_AccountingTransaction_getPaymentState_free_payment
(
self
):
invoice
=
self
.
createPayzenSaleInvoiceTransaction
(
price
=
0
)
self
.
tic
()
self
.
assertEquals
(
"Free!"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_unpaid_payment
(
self
):
invoice
=
self
.
createPayzenSaleInvoiceTransaction
()
# If payment is not indexed or not started the state should be unpaid
self
.
assertEquals
(
"Unpaid"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_paynow_payment
(
self
):
person
=
self
.
makePerson
()
invoice
=
self
.
createPayzenSaleInvoiceTransaction
(
destination_section
=
person
.
getRelativeUrl
())
self
.
tic
()
self
.
login
(
person
.
getUserId
())
self
.
assertEquals
(
"Pay now"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_waiting_payment
(
self
):
person
=
self
.
makePerson
()
invoice
=
self
.
createPayzenSaleInvoiceTransaction
(
destination_section
=
person
.
getRelativeUrl
())
self
.
tic
()
payment
=
invoice
.
SaleInvoiceTransaction_getPayzenPaymentRelatedValue
()
payment
.
PaymentTransaction_generatePayzenId
()
self
.
login
(
person
.
getUserId
())
self
.
assertEquals
(
"Waiting for payment confirmation"
,
invoice
.
AccountingTransaction_getPaymentState
())
def
test_AccountingTransaction_getPaymentState_paid_payment
(
self
):
invoice
=
self
.
createPayzenSaleInvoiceTransaction
()
self
.
tic
()
for
line
in
invoice
.
getMovementList
(
self
.
portal
.
getPortalAccountingMovementTypeList
()):
node_value
=
line
.
getSourceValue
(
portal_type
=
'Account'
)
if
node_value
.
getAccountType
()
==
'asset/receivable'
:
line
.
setGroupingReference
(
"TEST%s"
%
self
.
new_id
)
self
.
assertEquals
(
"Paid"
,
invoice
.
AccountingTransaction_getPaymentState
())
class
TestSlapOSPayzenSaleInvoiceTransaction_getPayzenPaymentRelatedValue
(
SlapOSTestCaseMixinWithAbort
):
...
...
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