account-payment-team team mailing list archive
-
account-payment-team team
-
Mailing list archive
-
Message #00315
[Merge] lp:~icsergio/account-payment/commercial-year-payment into lp:account-payment
Sergio Corato has proposed merging lp:~icsergio/account-payment/commercial-year-payment into lp:account-payment.
Requested reviews:
Account Payment (account-payment-team)
For more details, see:
https://code.launchpad.net/~icsergio/account-payment/commercial-year-payment/+merge/210700
As of this thread https://lists.launchpad.net/openerp-expert-accounting/msg02101.html I submit a module that allows to consider the months all equals, giving a standard result from end of month payment.
--
https://code.launchpad.net/~icsergio/account-payment/commercial-year-payment/+merge/210700
Your team Account Payment is requested to review the proposed merge of lp:~icsergio/account-payment/commercial-year-payment into lp:account-payment.
=== added directory 'account_payment_commercial_year'
=== added file 'account_payment_commercial_year/__init__.py'
--- account_payment_commercial_year/__init__.py 1970-01-01 00:00:00 +0000
+++ account_payment_commercial_year/__init__.py 2014-03-12 22:11:03 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (C) 2014 Didotech SRL
+# (<http://www.didotech.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import payment_term
=== added file 'account_payment_commercial_year/__openerp__.py'
--- account_payment_commercial_year/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_payment_commercial_year/__openerp__.py 2014-03-12 22:11:03 +0000
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (C) 2014 Didotech SRL
+# (<http://www.didotech.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+ 'name': 'Commercial Year Payment',
+ 'version': '0.0.1',
+ 'category': 'Generic Modules/Accounting',
+ 'description': """This module customizes OpenERP in order to add more payment functionalities.
+ It adds a boolean field to allow to compute all months of the same lenght, giving a more predictable result from the payment terms.
+""",
+ 'author': 'Sergio Corato',
+ 'website': 'http://www.didotech.com',
+ 'license': 'AGPL-3',
+ "depends": [
+ 'base',
+ 'account',
+# 'account_voucher',
+ ],
+ "init_xml": [
+ ],
+ "update_xml": [
+ "payment_term_view.xml",
+ ],
+ "demo_xml": [],
+ "test": [
+ "test/invoice_emission.yml",
+ ],
+ "active": False,
+ "installable": True
+}
=== added directory 'account_payment_commercial_year/i18n'
=== added file 'account_payment_commercial_year/i18n/account_payment_commercial_year.pot'
--- account_payment_commercial_year/i18n/account_payment_commercial_year.pot 1970-01-01 00:00:00 +0000
+++ account_payment_commercial_year/i18n/account_payment_commercial_year.pot 2014-03-12 22:11:03 +0000
@@ -0,0 +1,27 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * account_payment_commercial_year
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-03-12 21:51+0000\n"
+"PO-Revision-Date: 2014-03-12 21:51+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: account_payment_commercial_year
+#: constraint:account.payment.term:0
+msgid "Error: Payment days field format is not valid."
+msgstr ""
+
+#. module: account_payment_commercial_year
+#: model:ir.model,name:account_payment_commercial_year.model_account_payment_term
+msgid "Payment Term"
+msgstr ""
+
=== added file 'account_payment_commercial_year/i18n/it.po'
--- account_payment_commercial_year/i18n/it.po 1970-01-01 00:00:00 +0000
+++ account_payment_commercial_year/i18n/it.po 2014-03-12 22:11:03 +0000
@@ -0,0 +1,27 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * account_payment_commercial_year
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-03-12 21:53+0000\n"
+"PO-Revision-Date: 2014-03-12 21:53+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: account_payment_commercial_year
+#: constraint:account.payment.term:0
+msgid "Error: Payment days field format is not valid."
+msgstr "Errore: il formato del campo Payment days non è valido."
+
+#. module: account_payment_commercial_year
+#: model:ir.model,name:account_payment_commercial_year.model_account_payment_term
+msgid "Payment Term"
+msgstr "Termine di pagamento"
+
=== added file 'account_payment_commercial_year/payment_term.py'
--- account_payment_commercial_year/payment_term.py 1970-01-01 00:00:00 +0000
+++ account_payment_commercial_year/payment_term.py 2014-03-12 22:11:03 +0000
@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+
+from openerp.osv import fields, osv
+
+
+class account_payment_term(osv.osv):
+ _inherit = "account.payment.term"
+ _columns = {
+ 'commercial_year': fields.boolean('Commercial year', help="If the Commercial year field is set to True, it will allow to compute all months of the same lenght, giving a more predictable result from the payment terms."),
+ }
+
+ def compute(self, cr, uid, id, value, date_ref=False, context=None):
+ if not date_ref:
+ date_ref = datetime.now().strftime('%Y-%m-%d')
+ pt = self.browse(cr, uid, id, context=context)
+ amount = value
+ result = []
+ obj_precision = self.pool.get('decimal.precision')
+ for line in pt.line_ids:
+ prec = obj_precision.precision_get(cr, uid, 'Account')
+ if line.value == 'fixed':
+ amt = round(line.value_amount, prec)
+ elif line.value == 'procent':
+ amt = round(value * line.value_amount, prec)
+ elif line.value == 'balance':
+ amt = round(amount, prec)
+ if amt:
+ if line.payment_id.commercial_year:
+ next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(months=line.days / 30))
+ else:
+ next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days))
+ if line.days2 < 0:
+ next_first_date = next_date + relativedelta(day=1, months=1) # Getting 1st of next month
+ next_date = next_first_date + relativedelta(days=line.days2)
+ if line.days2 > 0:
+ next_date += relativedelta(day=line.days2, months=1)
+ result.append((next_date.strftime('%Y-%m-%d'), amt))
+ amount -= amt
+ return result
+
+account_payment_term()
=== added file 'account_payment_commercial_year/payment_term_view.xml'
--- account_payment_commercial_year/payment_term_view.xml 1970-01-01 00:00:00 +0000
+++ account_payment_commercial_year/payment_term_view.xml 2014-03-12 22:11:03 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="view_payment_term_form_commercial_year" model="ir.ui.view">
+ <field name="name">account.payment.term.form.commercial.year</field>
+ <field name="model">account.payment.term</field>
+ <field name="inherit_id" ref="account.view_payment_term_form"/>
+ <field name="arch" type="xml">
+ <field name="line_ids" position="before">
+ <field name="commercial_year"/>
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>
=== added directory 'account_payment_commercial_year/test'
=== added file 'account_payment_commercial_year/test/invoice_emission.yml'
--- account_payment_commercial_year/test/invoice_emission.yml 1970-01-01 00:00:00 +0000
+++ account_payment_commercial_year/test/invoice_emission.yml 2014-03-12 22:11:03 +0000
@@ -0,0 +1,89 @@
+-
+ I create a account payment term record.
+-
+ !record {model: account.payment.term, id: account_payment_term_daysendofmonth0}:
+ line_ids:
+ - days: 30
+ days2: -1
+ name: one
+ sequence: 5
+ value: balance
+ value_amount: 0.0
+ name: 30 days end of month
+-
+ I create a supplier invoice
+-
+ !record {model: account.invoice, id: account_invoice_supplier0}:
+ account_id: account.a_pay
+ address_contact_id: base.res_partner_address_3000
+ address_invoice_id: base.res_partner_address_3000
+ check_total: 3000.0
+ company_id: base.main_company
+ currency_id: base.EUR
+ date_invoice: '2014-01-30'
+ invoice_line:
+ - account_id: account.a_expense
+ name: '[PC1] Basic PC'
+ price_unit: 300.0
+ product_id: product.product_product_pc1
+ quantity: 10.0
+ uos_id: product.product_uom_unit
+ journal_id: account.expenses_journal
+ partner_id: base.res_partner_desertic_hispafuentes
+ payment_term: account_payment_term_daysendofmonth0
+ reference_type: none
+ type: in_invoice
+-
+ I change the state of invoice to open by clicking Validate button
+-
+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier0}
+-
+ I check that payment expiration is wrong at 2014-03-31
+-
+ !assert {model: account.invoice, id: account_invoice_supplier0}:
+ - date_due == '2014-03-31'
+-
+ I create another end of month payment term with commercial_year true
+-
+ !record {model: account.payment.term, id: account_payment_term_daysendofmonth1}:
+ line_ids:
+ - days: 30
+ days2: -1
+ name: one
+ sequence: 5
+ value: balance
+ value_amount: 0.0
+ name: 30 days end of month
+ commercial_year: true
+-
+ I create an invoice with the commercial_year payment term
+-
+ !record {model: account.invoice, id: account_invoice_supplier1}:
+ account_id: account.a_pay
+ address_contact_id: base.res_partner_address_3000
+ address_invoice_id: base.res_partner_address_3000
+ check_total: 3000.0
+ company_id: base.main_company
+ currency_id: base.EUR
+ date_invoice: '2014-01-30'
+ invoice_line:
+ - account_id: account.a_expense
+ name: '[PC1] Basic PC'
+ price_unit: 300.0
+ product_id: product.product_product_pc1
+ quantity: 10.0
+ uos_id: product.product_uom_unit
+ journal_id: account.expenses_journal
+ partner_id: base.res_partner_desertic_hispafuentes
+ payment_term: account_payment_term_daysendofmonth1
+ reference_type: none
+ type: in_invoice
+-
+ I change the state of invoice to open by clicking Validate button
+-
+ !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_supplier1}
+-
+ I check that payment expiration is correct at 2014-02-28
+-
+ !assert {model: account.invoice, id: account_invoice_supplier1}:
+ - date_due == '2014-02-28'
=== added file 'account_payment_commercial_year/test/test.xml'
--- account_payment_commercial_year/test/test.xml 1970-01-01 00:00:00 +0000
+++ account_payment_commercial_year/test/test.xml 2014-03-12 22:11:03 +0000
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data noupdate="1">
+
+ <record id="res_partner_category_myf" model="res.partner.category">
+ <field name="name">Fornitori</field>
+ </record>
+
+ <record id="res_partner_category_fb" model="res.partner.category">
+ <field name="name">Fornitori bum</field>
+ <field name="parent_id" ref="res_partner_category_myf"/>
+ </record>
+
+ <record id="res_partner_fornitorediprova" model="res.partner">
+ <field name="name">Fornitore di prova</field>
+ <field eval="[(6,0,[ref('res_partner_category_fb')])]" name="category_id"/>
+ <field name="supplier">1</field>
+ <field eval="0" name="customer"/>
+ <field name="address" eval="[]"/>
+ <field name="website">woodywoodpecker.com</field>
+ </record>
+
+ <record id="res_partner_address_fdp" model="res.partner.address">
+ <field name="city">Champs sur Marne</field>
+ <field name="name">Montecchio Maggiore</field>
+ <field name="zip">36075</field>
+ <field model="res.country" name="country_id" search="[('name','=','Italia')]"/>
+ <field name="email">info@xxxxxxxxxx</field>
+ <field name="phone">+33 1 64 61 04 01</field>
+ <field name="street">12 rue Albert Einstein</field>
+ <field name="type">default</field>
+ <field name="partner_id" ref="res_partner_fornitorediprova"/>
+ </record>
+
+ </data>
+</openerp>
Follow ups