first commit

This commit is contained in:
root
2026-03-14 09:42:12 +00:00
commit 0adbd20c2c
10991 changed files with 1646955 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,103 @@
==============================
Account Cash Rounding Scenario
==============================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.modules.currency.tests.tools import get_currency
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules(
... ['account_cash_rounding', 'account_invoice'], create_company, create_chart)
>>> Account = Model.get('account.account')
>>> AccountConfig = Model.get('account.configuration')
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear())
>>> fiscalyear.click('create_period')
Get accounts::
>>> accounts = get_accounts()
Set cash rounding::
>>> cash_rounding_credit = Account(name="Cash Rounding")
>>> cash_rounding_credit.type = accounts['revenue'].type
>>> cash_rounding_credit.deferral = True
>>> cash_rounding_credit.save()
>>> cash_rounding_debit = Account(name="Cash Rounding")
>>> cash_rounding_debit.type = accounts['expense'].type
>>> cash_rounding_debit.deferral = True
>>> cash_rounding_debit.save()
>>> account_config = AccountConfig(1)
>>> account_config.cash_rounding = True
>>> account_config.cash_rounding_credit_account = cash_rounding_credit
>>> account_config.cash_rounding_debit_account = cash_rounding_debit
>>> account_config.save()
>>> currency = get_currency()
>>> currency.cash_rounding = Decimal('0.05')
>>> currency.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.save()
Create payment term::
>>> PaymentTerm = Model.get('account.invoice.payment_term')
>>> payment_term = PaymentTerm(name='Term')
>>> line = payment_term.lines.new(type='percent', ratio=Decimal('.5'))
>>> delta, = line.relativedeltas
>>> delta.days = 20
>>> line = payment_term.lines.new(type='remainder')
>>> delta = line.relativedeltas.new(days=40)
>>> payment_term.save()
Create invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> bool(invoice.cash_rounding)
True
>>> invoice.party = party
>>> invoice.payment_term = payment_term
>>> line = invoice.lines.new()
>>> line.account = accounts['revenue']
>>> line.quantity = 1
>>> line.unit_price = Decimal('42.06')
>>> invoice.untaxed_amount, invoice.tax_amount, invoice.total_amount
(Decimal('42.06'), Decimal('0.00'), Decimal('42.10'))
>>> invoice.cash_rounding = False
>>> invoice.untaxed_amount, invoice.tax_amount, invoice.total_amount
(Decimal('42.06'), Decimal('0.00'), Decimal('42.06'))
>>> invoice.cash_rounding = True
>>> invoice.save()
>>> invoice.total_amount
Decimal('42.10')
Post invoice::
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('42.10')
>>> cash_rounding_credit.reload()
>>> cash_rounding_credit.credit
Decimal('0.04')

View File

@@ -0,0 +1,110 @@
=================================================
Account Cash Rounding Alternate Currency Scenario
=================================================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import (
... create_chart, create_fiscalyear, get_accounts)
>>> from trytond.modules.account_invoice.tests.tools import (
... set_fiscalyear_invoice_sequences)
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.modules.currency.tests.tools import get_currency
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules(
... ['account_cash_rounding', 'account_invoice'], create_company, create_chart)
>>> Account = Model.get('account.account')
>>> AccountConfig = Model.get('account.configuration')
>>> Configuration = Model.get('account.configuration')
Set alternate currencies::
>>> currency = get_currency('USD')
>>> eur = get_currency('EUR')
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear())
>>> fiscalyear.click('create_period')
Get accounts::
>>> accounts = get_accounts()
Configure currency exchange::
>>> currency_exchange_account, = (
... accounts['revenue'].duplicate(
... default={'name': "Currency Exchange"}))
>>> configuration = Configuration(1)
>>> configuration.currency_exchange_debit_account = (
... currency_exchange_account)
>>> configuration.save()
Set cash rounding::
>>> cash_rounding_credit = Account(name="Cash Rounding")
>>> cash_rounding_credit.type = accounts['revenue'].type
>>> cash_rounding_credit.deferral = True
>>> cash_rounding_credit.save()
>>> cash_rounding_debit = Account(name="Cash Rounding")
>>> cash_rounding_debit.type = accounts['expense'].type
>>> cash_rounding_debit.deferral = True
>>> cash_rounding_debit.save()
>>> account_config = AccountConfig(1)
>>> account_config.cash_rounding = True
>>> account_config.cash_rounding_credit_account = cash_rounding_credit
>>> account_config.cash_rounding_debit_account = cash_rounding_debit
>>> account_config.save()
>>> eur.cash_rounding = Decimal('0.05')
>>> eur.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name="Party")
>>> party.save()
Create invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.cash_rounding = True
>>> invoice.currency = eur
>>> bool(invoice.cash_rounding)
True
>>> invoice.party = party
>>> line = invoice.lines.new()
>>> line.account = accounts['revenue']
>>> line.quantity = 1
>>> line.unit_price = Decimal('42.06')
>>> invoice.untaxed_amount, invoice.tax_amount, invoice.total_amount
(Decimal('42.06'), Decimal('0.00'), Decimal('42.05'))
>>> invoice.save()
>>> invoice.total_amount
Decimal('42.05')
Post invoice::
>>> invoice.click('post')
>>> invoice.total_amount
Decimal('42.05')
>>> cash_rounding_credit.reload()
>>> cash_rounding_credit.credit, cash_rounding_credit.debit
(Decimal('0.00'), Decimal('0.00'))
>>> line_to_pay, = invoice.lines_to_pay
>>> line_to_pay.debit, line_to_pay.credit
(Decimal('21.02'), Decimal('0'))
>>> line_to_pay.amount_second_currency
Decimal('42.05')

View File

@@ -0,0 +1,74 @@
=======================================
Account Cash Rounding Purchase Scenario
=======================================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
>>> from trytond.modules.account_invoice.tests.tools import create_payment_term
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.modules.currency.tests.tools import get_currency
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules(
... ['account_cash_rounding', 'account_invoice', 'purchase'],
... create_company, create_chart)
>>> Account = Model.get('account.account')
>>> AccountConfig = Model.get('account.configuration')
Get accounts::
>>> accounts = get_accounts()
>>> Configuration = Model.get('account.configuration')
>>> config = Configuration(1)
>>> config.default_category_account_expense = accounts['expense']
>>> config.save()
Set cash rounding::
>>> currency = get_currency()
>>> currency.cash_rounding = Decimal('0.05')
>>> currency.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.save()
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Create purchase::
>>> Purchase = Model.get('purchase.purchase')
>>> purchase = Purchase()
>>> purchase.party = party
>>> purchase.payment_term = payment_term
>>> line = purchase.lines.new()
>>> line.quantity = 1
>>> line.unit_price = Decimal('42.07')
>>> purchase.untaxed_amount, purchase.tax_amount, purchase.total_amount
(Decimal('42.07'), Decimal('0.00'), Decimal('42.07'))
>>> purchase.cash_rounding = True
>>> purchase.untaxed_amount, purchase.tax_amount, purchase.total_amount
(Decimal('42.07'), Decimal('0.00'), Decimal('42.05'))
>>> purchase.click('quote')
>>> purchase.untaxed_amount, purchase.tax_amount, purchase.total_amount
(Decimal('42.07'), Decimal('0'), Decimal('42.05'))
Create invoice::
>>> purchase.click('confirm')
>>> invoice, = purchase.invoices
>>> bool(invoice.cash_rounding)
True

View File

@@ -0,0 +1,73 @@
===================================
Account Cash Rounding Sale Scenario
===================================
Imports::
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
>>> from trytond.modules.account_invoice.tests.tools import create_payment_term
>>> from trytond.modules.company.tests.tools import create_company
>>> from trytond.modules.currency.tests.tools import get_currency
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules(
... ['account_cash_rounding', 'account_invoice', 'sale'],
... create_company, create_chart)
>>> Account = Model.get('account.account')
>>> AccountConfig = Model.get('account.configuration')
Get accounts::
>>> accounts = get_accounts()
Set cash rounding::
>>> cash_rounding_credit = Account(name="Cash Rounding")
>>> cash_rounding_credit.type = accounts['revenue'].type
>>> cash_rounding_credit.deferral = True
>>> cash_rounding_credit.save()
>>> cash_rounding_debit = Account(name="Cash Rounding")
>>> cash_rounding_debit.type = accounts['expense'].type
>>> cash_rounding_debit.deferral = True
>>> cash_rounding_debit.save()
>>> account_config = AccountConfig(1)
>>> account_config.cash_rounding = True
>>> account_config.cash_rounding_credit_account = cash_rounding_credit
>>> account_config.cash_rounding_debit_account = cash_rounding_debit
>>> account_config.save()
>>> currency = get_currency()
>>> currency.cash_rounding = Decimal('0.05')
>>> currency.save()
Create party::
>>> Party = Model.get('party.party')
>>> party = Party(name='Party')
>>> party.save()
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Create sale::
>>> Sale = Model.get('sale.sale')
>>> sale = Sale()
>>> sale.party = party
>>> sale.payment_term = payment_term
>>> line = sale.lines.new()
>>> line.quantity = 1
>>> line.unit_price = Decimal('42.02')
>>> sale.untaxed_amount, sale.tax_amount, sale.total_amount
(Decimal('42.02'), Decimal('0.00'), Decimal('42.00'))
>>> sale.click('quote')
>>> sale.untaxed_amount, sale.tax_amount, sale.total_amount
(Decimal('42.02'), Decimal('0'), Decimal('42.00'))

View File

@@ -0,0 +1,13 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import ModuleTestCase
class AccountCashRoundingTestCase(ModuleTestCase):
'Test Account Cash Rounding module'
module = 'account_cash_rounding'
extras = ['account_invoice', 'purchase', 'sale']
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)