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
...
@@ -13,14 +13,9 @@ assert context.getTotalPrice() != 0
assert
context
.
getSpecialise
()
in
(
"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"
)
"sale_trade_condition_module/slapos_aggregated_subscription_trade_condition"
)
paid
=
True
for
line
in
context
.
getMovementList
(
portal
.
getPortalAccountingMovementTypeList
()):
# Dont create if the invoice is already paied
node_value
=
line
.
getSourceValue
(
portal_type
=
'Account'
)
assert
not
context
.
SaleInvoiceTransaction_isLettered
()
if
node_value
.
getAccountType
()
==
'asset/receivable'
:
if
not
line
.
hasGroupingReference
():
paid
=
False
break
assert
not
paid
payment
=
portal
.
portal_catalog
.
getResultValue
(
payment
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Payment Transaction"
,
portal_type
=
"Payment Transaction"
,
...
@@ -28,17 +23,13 @@ payment = portal.portal_catalog.getResultValue(
...
@@ -28,17 +23,13 @@ payment = portal.portal_catalog.getResultValue(
default_causality_uid
=
context
.
getUid
(),
default_causality_uid
=
context
.
getUid
(),
default_payment_mode_uid
=
portal
.
portal_categories
.
payment_mode
.
payzen
.
getUid
(),
default_payment_mode_uid
=
portal
.
portal_categories
.
payment_mode
.
payzen
.
getUid
(),
)
)
assert
payment
is
not
None
if
payment
is
not
None
and
payment
.
PaymentTransaction_getPayzenId
()[
1
]
is
None
:
assert
payment
.
getSimulationState
()
==
'started'
# The payment transaction will be cancelled by a proper alarm.
assert
payment
.
getPaymentMode
()
==
'payzen'
raise
ValueError
(
"Payment Transaction is waiting for External Payzen confirmation!"
)
assert
payment
.
PaymentTransaction_getPayzenId
()[
1
]
is
None
# Should be safe now to fix everything
# Should be safe now to fix everything
context
.
SaleInvoiceTransaction_resetPaymentMode
()
context
.
SaleInvoiceTransaction_resetPaymentMode
()
payment
.
edit
(
payment_mode
=
None
)
reversal_transaction
=
context
.
Base_createCloneDocument
(
batch_mode
=
1
)
reversal_transaction
=
context
.
Base_createCloneDocument
(
batch_mode
=
1
)
payment
.
cancel
(
comment
=
"Reversal sale invoice transaction created %s"
%
reversal_transaction
.
getRelativeUrl
())
reversal_transaction
.
edit
(
reversal_transaction
.
edit
(
title
=
"Reversal Transaction for %s"
%
context
.
getTitle
(),
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'
...
@@ -10,16 +10,12 @@ assert context.getPortalType() == 'Sale Invoice Transaction'
assert
context
.
getPaymentMode
()
==
'wechat'
assert
context
.
getPaymentMode
()
==
'wechat'
assert
context
.
getSimulationState
()
==
'stopped'
assert
context
.
getSimulationState
()
==
'stopped'
assert
context
.
getTotalPrice
()
!=
0
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
()):
# Dont create if the invoice is already paied
node_value
=
line
.
getSourceValue
(
portal_type
=
'Account'
)
assert
not
context
.
SaleInvoiceTransaction_isLettered
()
if
node_value
.
getAccountType
()
==
'asset/receivable'
:
if
not
line
.
hasGroupingReference
():
paid
=
False
break
assert
not
paid
payment
=
portal
.
portal_catalog
.
getResultValue
(
payment
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Payment Transaction"
,
portal_type
=
"Payment Transaction"
,
...
@@ -27,17 +23,13 @@ payment = portal.portal_catalog.getResultValue(
...
@@ -27,17 +23,13 @@ payment = portal.portal_catalog.getResultValue(
default_causality_uid
=
context
.
getUid
(),
default_causality_uid
=
context
.
getUid
(),
default_payment_mode_uid
=
portal
.
portal_categories
.
payment_mode
.
wechat
.
getUid
(),
default_payment_mode_uid
=
portal
.
portal_categories
.
payment_mode
.
wechat
.
getUid
(),
)
)
assert
payment
is
not
None
if
payment
is
not
None
and
payment
.
PaymentTransaction_getWechatId
()[
1
]
is
None
:
assert
payment
.
getSimulationState
()
==
'started'
# The payment transaction will be cancelled by a proper alarm.
assert
payment
.
getPaymentMode
()
==
'wechat'
raise
ValueError
(
"Payment Transaction is waiting for External Wechat confirmation!"
)
assert
payment
.
PaymentTransaction_getWechatId
()[
1
]
is
None
# Should be safe now to fix everything
# Should be safe now to fix everything
context
.
SaleInvoiceTransaction_resetPaymentMode
()
context
.
SaleInvoiceTransaction_resetPaymentMode
()
payment
.
edit
(
payment_mode
=
None
)
reversal_transaction
=
context
.
Base_createCloneDocument
(
batch_mode
=
1
)
reversal_transaction
=
context
.
Base_createCloneDocument
(
batch_mode
=
1
)
payment
.
cancel
(
comment
=
"Reversal sale invoice transaction created %s"
%
reversal_transaction
.
getRelativeUrl
())
reversal_transaction
.
edit
(
reversal_transaction
.
edit
(
title
=
"Reversal Transaction for %s"
%
context
.
getTitle
(),
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