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
Titouan Soulard
slapos.core
Commits
3a217f5b
Commit
3a217f5b
authored
Jun 02, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: add script to generate the deposit
parent
6c05b890
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
460 additions
and
0 deletions
+460
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Base_getAccountForUse.py
...m/portal_skins/slapos_accounting/Base_getAccountForUse.py
+19
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Base_getAccountForUse.xml
.../portal_skins/slapos_accounting/Base_getAccountForUse.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/PaymentTransaction_acceptDepositPayment.py
...pos_accounting/PaymentTransaction_acceptDepositPayment.py
+60
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/PaymentTransaction_acceptDepositPayment.xml
...os_accounting/PaymentTransaction_acceptDepositPayment.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Person_addDepositPayment.py
...ortal_skins/slapos_accounting/Person_addDepositPayment.py
+91
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Person_addDepositPayment.xml
...rtal_skins/slapos_accounting/Person_addDepositPayment.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SaleTradeCondition_getPriceAndVAT.py
...ns/slapos_accounting/SaleTradeCondition_getPriceAndVAT.py
+42
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SaleTradeCondition_getPriceAndVAT.xml
...s/slapos_accounting/SaleTradeCondition_getPriceAndVAT.xml
+62
-0
No files found.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Base_getAccountForUse.py
0 → 100644
View file @
3a217f5b
'''
Script to be used as API whenever we want to get an account for a
specific use. Returns the Account object
'''
id
=
{
'asset_receivable_subscriber'
:
'receivable'
,
'asset_deposit_subscriber'
:
'deposit'
,
'collection'
:
'payment_to_encash'
}[
use
]
account
,
=
context
.
getPortalObject
().
portal_catalog
(
portal_type
=
'Account'
,
id
=
id
,
validation_state
=
'validated'
,
limit
=
2
,
)
return
account
.
getObject
()
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Base_getAccountForUse.xml
0 → 100644
View file @
3a217f5b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</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>
use
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_getAccountForUse
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/PaymentTransaction_acceptDepositPayment.py
0 → 100644
View file @
3a217f5b
from
DateTime
import
DateTime
portal
=
context
.
getPortalObject
()
payment_transaction
=
context
payment_transaction
.
stop
()
start_date
=
DateTime
()
stop_date
=
None
resource_value
=
portal
.
restrictedTraverse
(
'service_module/slapos_deposit'
)
quantity_unit_value
=
resource_value
.
getQuantityUnitValue
()
order_portal_type
=
'Sale Packing List'
order_line_portal_type
=
'Sale Packing List Line'
activate_kw
=
None
#######################################################
# Open Sale Order
#raise NotImplementedError('Fix dates')
open_sale_order
=
portal
.
getDefaultModule
(
portal_type
=
order_portal_type
).
newContent
(
portal_type
=
order_portal_type
,
start_date
=
start_date
,
stop_date
=
stop_date
,
specialise_value
=
payment_transaction
.
getSpecialiseValue
(),
source_value
=
payment_transaction
.
getSourceValue
(),
source_section_value
=
payment_transaction
.
getSourceSectionValue
(),
source_decision_value
=
payment_transaction
.
getSourceDecisionValue
(),
source_project_value
=
payment_transaction
.
getSourceProjectValue
(),
destination_value
=
payment_transaction
.
getDestinationValue
(),
destination_section_value
=
payment_transaction
.
getDestinationSectionValue
(),
destination_decision_value
=
payment_transaction
.
getDestinationDecisionValue
(),
destination_project_value
=
payment_transaction
.
getDestinationProjectValue
(),
ledger_value
=
portal
.
portal_categories
.
ledger
.
automated
,
causality_value
=
payment_transaction
,
price_currency_value
=
payment_transaction
.
getResourceValue
(),
activate_kw
=
activate_kw
)
open_sale_order
.
newContent
(
portal_type
=
order_line_portal_type
,
resource_value
=
resource_value
,
quantity_unit_value
=
quantity_unit_value
,
base_contribution_list
=
resource_value
.
getBaseContributionList
(),
use
=
resource_value
.
getUse
(),
quantity
=
1
,
#price=-payment_transaction.getTotalPrice(),
price
=-
payment_transaction
.
PaymentTransaction_getTotalPayablePrice
(),
activate_kw
=
activate_kw
)
open_sale_order
.
confirm
()
open_sale_order
.
stop
()
open_sale_order
.
deliver
()
return
open_sale_order
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/PaymentTransaction_acceptDepositPayment.xml
0 → 100644
View file @
3a217f5b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</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>
PaymentTransaction_acceptDepositPayment
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Person_addDepositPayment.py
0 → 100644
View file @
3a217f5b
from
DateTime
import
DateTime
from
Products.ERP5Type.Message
import
translateString
portal
=
context
.
getPortalObject
()
######################################################
# Find Sale Trade Condition
source_section
=
context
# Create a temp Sale Order to calculate the real price and find the trade condition
now
=
DateTime
()
module
=
portal
.
portal_trash
tmp_sale_order
=
module
.
newContent
(
portal_type
=
'Sale Order'
,
temp_object
=
True
,
start_date
=
now
,
destination_value
=
source_section
,
destination_section_value
=
source_section
,
destination_decision_value
=
source_section
,
ledger_value
=
portal
.
portal_categories
.
ledger
.
automated
,
price_currency
=
currency_relative_url
)
tmp_sale_order
.
SaleOrder_applySaleTradeCondition
(
batch_mode
=
1
,
force
=
1
)
if
tmp_sale_order
.
getSpecialise
(
None
)
is
None
:
raise
AssertionError
(
'Can not find a trade condition to generate the Payment Transaction'
)
if
currency_relative_url
!=
tmp_sale_order
.
getPriceCurrency
():
raise
AssertionError
(
'Unexpected different currency: %s %s'
%
(
currency_relative_url
,
tmp_sale_order
.
getPriceCurrency
()))
# If no accounting is needed, no need to check the price
if
(
tmp_sale_order
.
getSourceSection
(
None
)
==
tmp_sale_order
.
getDestinationSection
(
None
))
or
\
(
tmp_sale_order
.
getSourceSection
(
None
)
is
None
):
raise
AssertionError
(
'The trade condition does not generate accounting: %s'
%
tmp_sale_order
.
getSpecialise
())
#######################################################
payment_transaction
=
portal
.
accounting_module
.
newContent
(
title
=
"reservation payment"
,
portal_type
=
"Payment Transaction"
,
start_date
=
now
,
stop_date
=
now
,
specialise_value
=
tmp_sale_order
.
getSpecialiseValue
(),
source_value
=
tmp_sale_order
.
getSourceValue
(),
source_section_value
=
tmp_sale_order
.
getSourceSectionValue
(),
source_decision_value
=
tmp_sale_order
.
getSourceDecisionValue
(),
source_project_value
=
tmp_sale_order
.
getSourceProjectValue
(),
destination_value
=
tmp_sale_order
.
getDestinationValue
(),
destination_section_value
=
tmp_sale_order
.
getDestinationSectionValue
(),
destination_decision_value
=
tmp_sale_order
.
getDestinationDecisionValue
(),
destination_project_value
=
tmp_sale_order
.
getDestinationProjectValue
(),
ledger_value
=
portal
.
portal_categories
.
ledger
.
automated
,
resource_value
=
tmp_sale_order
.
getPriceCurrencyValue
(),
created_by_builder
=
1
,
# XXX this prevent init script from creating lines.
activate_kw
=
{
'tag'
:
'%s_init'
%
context
.
getRelativeUrl
()}
)
getAccountForUse
=
context
.
Base_getAccountForUse
# receivable
payment_transaction
.
newContent
(
id
=
'receivable'
,
portal_type
=
'Accounting Transaction Line'
,
quantity
=
price
,
source_value
=
getAccountForUse
(
'asset_receivable_subscriber'
),
# XXX XXX XXX fetch from Business process instead of hardcoding?
# drop destination
destination
=
'account_module/payable'
)
# bank
payment_transaction
.
newContent
(
id
=
'bank'
,
portal_type
=
'Accounting Transaction Line'
,
quantity
=-
price
,
source_value
=
getAccountForUse
(
'collection'
)
)
if
len
(
payment_transaction
.
checkConsistency
())
!=
0
:
raise
AssertionError
(
payment_transaction
.
checkConsistency
()[
0
])
#tag = '%s_update' % context.getDestinationReference()
comment
=
translateString
(
"Deposit payment."
)
payment_transaction
.
PaymentTransaction_start
(
comment
=
comment
)
return
payment_transaction
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Person_addDepositPayment.xml
0 → 100644
View file @
3a217f5b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</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>
price, currency_relative_url, batch=0
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Person_addDepositPayment
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SaleTradeCondition_getPriceAndVAT.py
0 → 100644
View file @
3a217f5b
from
Products.ERP5Type.Cache
import
CachingMethod
portal
=
context
.
getPortalObject
()
def
getPriceAndVAT
():
assert
date
is
not
None
temp_sale_order
=
portal
.
sale_order_module
.
newContent
(
id
=
str
(
DateTime
().
timeTime
()),
# XXX: workaround for an obscure transactional cache (?) bug
temp_object
=
True
,
portal_type
=
'Sale Order'
,
start_date
=
date
,
)
temp_sale_order
.
Order_applyTradeCondition
(
context
)
temp_sale_order_line
=
temp_sale_order
.
newContent
(
id
=
str
(
DateTime
().
timeTime
()),
# XXX: workaround for an obscure transactional cache (?) bug
portal_type
=
'Sale Order Line'
,
resource_value
=
resource_value
,
# XXX Try without variation for now
quantity
=
quantity
,
price
=
price
)
temp_sale_order_line
.
setBaseContributionList
(
resource_value
.
getBaseContributionList
())
amount_list
=
temp_sale_order_line
.
getAggregatedAmountList
(
rounding
=
False
)
if
len
(
amount_list
)
==
0
:
raise
ValueError
(
'No amount generated for resource %s with Sale Trade Condition %s'
%
(
resource_value
.
getPath
(),
context
.
getPath
(),
)
)
total_price
=
temp_sale_order_line
.
getTotalPrice
()
or
0.0
# XXX does not work if quantity === total_price
amount
=
[
amount
for
amount
in
amount_list
if
amount
.
getQuantity
()
==
total_price
][
0
]
return
price
,
amount
.
getPrice
()
cache_index
=
0
#portal.sale_supply_module.getIntIndex(0)
return
CachingMethod
(
getPriceAndVAT
,
id
=
(
script
.
id
,
cache_index
,
context
.
getRelativeUrl
(),
resource_value
.
getRelativeUrl
(),
date
.
strftime
(
'%Y%m%d'
),
quantity
),
cache_factory
=
'erp5_content_long'
,
)()
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SaleTradeCondition_getPriceAndVAT.xml
0 → 100644
View file @
3a217f5b
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</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>
date, resource_value, quantity, price
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SaleTradeCondition_getPriceAndVAT
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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