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
Léo-Paul Géneau
slapos.core
Commits
ac978a55
Commit
ac978a55
authored
Dec 06, 2022
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_payzen&wechat: Update script to create reversal Sale Invoice Transaction
parent
f090874c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
31 deletions
+14
-31
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/SaleInvoiceTransaction_createReversalPayzenTransaction.py
...SaleInvoiceTransaction_createReversalPayzenTransaction.py
+6
-15
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/SaleInvoiceTransaction_createReversalWechatTransaction.py
...SaleInvoiceTransaction_createReversalWechatTransaction.py
+8
-16
No files found.
master/bt5/slapos_payzen/SkinTemplateItem/portal_skins/slapos_payzen/SaleInvoiceTransaction_createReversalPayzenTransaction.py
View file @
ac978a55
...
...
@@ -13,14 +13,9 @@ assert context.getTotalPrice() != 0
assert
context
.
getSpecialise
()
in
(
"sale_trade_condition_module/slapos_aggregated_trade_condition"
,
"sale_trade_condition_module/slapos_aggregated_subscription_trade_condition"
)
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
assert
not
paid
# Dont create if the invoice is already paied
assert
not
context
.
SaleInvoiceTransaction_isLettered
()
payment
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Payment Transaction"
,
...
...
@@ -28,17 +23,13 @@ payment = portal.portal_catalog.getResultValue(
default_causality_uid
=
context
.
getUid
(),
default_payment_mode_uid
=
portal
.
portal_categories
.
payment_mode
.
payzen
.
getUid
(),
)
assert
payment
is
not
None
assert
payment
.
getSimulationState
()
==
'started'
assert
payment
.
getPaymentMode
()
==
'payzen'
assert
payment
.
PaymentTransaction_getPayzenId
()[
1
]
is
None
if
payment
is
not
None
and
payment
.
PaymentTransaction_getPayzenId
()[
1
]
is
None
:
# The payment transaction will be cancelled by a proper alarm.
raise
ValueError
(
"Payment Transaction is waiting for External Payzen confirmation!"
)
# Should be safe now to fix everything
context
.
SaleInvoiceTransaction_resetPaymentMode
()
payment
.
edit
(
payment_mode
=
None
)
reversal_transaction
=
context
.
Base_createCloneDocument
(
batch_mode
=
1
)
payment
.
cancel
(
comment
=
"Reversal sale invoice transaction created %s"
%
reversal_transaction
.
getRelativeUrl
())
reversal_transaction
.
edit
(
title
=
"Reversal Transaction for %s"
%
context
.
getTitle
(),
...
...
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/SaleInvoiceTransaction_createReversalWechatTransaction.py
View file @
ac978a55
...
...
@@ -10,16 +10,12 @@ assert context.getPortalType() == 'Sale Invoice Transaction'
assert
context
.
getPaymentMode
()
==
'wechat'
assert
context
.
getSimulationState
()
==
'stopped'
assert
context
.
getTotalPrice
()
!=
0
assert
context
.
getSpecialise
()
==
"sale_trade_condition_module/slapos_aggregated_trade_condition"
assert
context
.
getSpecialise
()
in
(
"sale_trade_condition_module/slapos_aggregated_trade_condition"
,
"sale_trade_condition_module/slapos_aggregated_subscription_trade_condition"
)
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
assert
not
paid
# Dont create if the invoice is already paied
assert
not
context
.
SaleInvoiceTransaction_isLettered
()
payment
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Payment Transaction"
,
...
...
@@ -27,17 +23,13 @@ payment = portal.portal_catalog.getResultValue(
default_causality_uid
=
context
.
getUid
(),
default_payment_mode_uid
=
portal
.
portal_categories
.
payment_mode
.
wechat
.
getUid
(),
)
assert
payment
is
not
None
assert
payment
.
getSimulationState
()
==
'started'
assert
payment
.
getPaymentMode
()
==
'wechat'
assert
payment
.
PaymentTransaction_getWechatId
()[
1
]
is
None
if
payment
is
not
None
and
payment
.
PaymentTransaction_getWechatId
()[
1
]
is
None
:
# The payment transaction will be cancelled by a proper alarm.
raise
ValueError
(
"Payment Transaction is waiting for External Wechat confirmation!"
)
# Should be safe now to fix everything
context
.
SaleInvoiceTransaction_resetPaymentMode
()
payment
.
edit
(
payment_mode
=
None
)
reversal_transaction
=
context
.
Base_createCloneDocument
(
batch_mode
=
1
)
payment
.
cancel
(
comment
=
"Reversal sale invoice transaction created %s"
%
reversal_transaction
.
getRelativeUrl
())
reversal_transaction
.
edit
(
title
=
"Reversal Transaction for %s"
%
context
.
getTitle
(),
...
...
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