From a025b0241b4d50bb76db7960f085f8436d8d8f5c Mon Sep 17 00:00:00 2001 From: Christian Zagrodnick Date: Mon, 27 May 2024 11:25:22 +0200 Subject: [PATCH] Add CustomerAgreemnt (CMXCAG) --- CHANGES.rst | 2 ++ src/gocept/collmex/collmex.py | 14 ++++++++++++++ src/gocept/collmex/doctest.rst | 20 +++++++++++++++++++- src/gocept/collmex/interfaces.py | 2 ++ src/gocept/collmex/model.py | 21 +++++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 62ed691..1570521 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,8 @@ Changes - Update invoice items to current collmex field names. (`#27 `_) +- Add CustomerAgreement (CMXCAG) + 2.0.1 (2023-08-23) ------------------ diff --git a/src/gocept/collmex/collmex.py b/src/gocept/collmex/collmex.py index 3c8b541..0c18ed5 100644 --- a/src/gocept/collmex/collmex.py +++ b/src/gocept/collmex/collmex.py @@ -215,6 +215,20 @@ def get_products(self, product_id=NULL, price_group, 0, self.system_identifier) + def get_customer_agreements(self, customer_id=NULL, product_id=NULL, + valid_on_date=NULL, inactive=NULL, + only_changed=NULL): + return self._query_objects( + 'CUSTOMER_AGREEMENT_GET', + self.company_id, + customer_id, + product_id, + date_to_collmex(valid_on_date), + inactive, + only_changed, + self.system_identifier) + + def get_projects(self, project_id=NULL, customer_id=NULL): return self._query_objects( 'PROJECT_GET', diff --git a/src/gocept/collmex/doctest.rst b/src/gocept/collmex/doctest.rst index dd878b8..713336f 100644 --- a/src/gocept/collmex/doctest.rst +++ b/src/gocept/collmex/doctest.rst @@ -90,6 +90,24 @@ Products are created using the ``create_product`` method: >>> collmex.get_products()[0]['Bezeichnung'] 'Testprodukt' +Customer Agreements +------------------- + +>>> cag = gocept.collmex.model.CustomerAgreement() +>>> cag['Kunde Nr'] = '10000' +>>> cag['Firma Nr'] = 1 +>>> cag['Produktnummer'] = 'TEST' +>>> cag['Gültig ab'] = '01.01.2000' +>>> cag['Gültig bis'] = '31.12.9999' +>>> cag['Preis'] = 7 +>>> cag['Währung'] = "EUR" +>>> collmex.create(cag) +>>> transaction.commit() +>>> cag_from_collmex = collmex.get_customer_agreements() +>>> list(cag) +['CMXCAG', '1', '10000', 'TEST', '(NULL)', '01.01.2000', '31.12.9999', 7, 'EUR', '(NULL)'] + + Invoices: ``create_invoice`` and ``get_invoices`` ------------------------------------------------- @@ -173,7 +191,7 @@ for every project set (Projektsatz) of each project (Projekt): True >>> proj[0]['Satz'] -'5,00' +'7,00' >>> proj[1]['Satz'] '9,65' >>> proj[0]['Inaktiv'] diff --git a/src/gocept/collmex/interfaces.py b/src/gocept/collmex/interfaces.py index d0dbc5e..5ebac29 100644 --- a/src/gocept/collmex/interfaces.py +++ b/src/gocept/collmex/interfaces.py @@ -65,6 +65,8 @@ class IMember(IModel): class IProduct(IModel): """A product (CMXPRD).""" +class ICustomerAgreement(IModel): + """A customer agreement (CMXCAG).""" class IActivity(IModel): """A product (CMXACT).""" diff --git a/src/gocept/collmex/model.py b/src/gocept/collmex/model.py index e1091fa..65e1e1b 100644 --- a/src/gocept/collmex/model.py +++ b/src/gocept/collmex/model.py @@ -325,6 +325,24 @@ def company(self, company_id): self['Firma'] = company_id +@zope.interface.implementer(gocept.collmex.interfaces.ICustomerAgreement) +class CustomerAgreement(Model): + + satzart = 'CMXCAG' + fields = ( + 'Satzart', + 'Firma Nr', + 'Kunde Nr', + 'Produktnummer', + 'Position', + 'Gültig ab', + 'Gültig bis', + 'Preis', + 'Währung', + 'Gelöscht', + ) + + @zope.interface.implementer(gocept.collmex.interfaces.IActivity) class Activity(Model): @@ -408,3 +426,6 @@ class Project(Model): 'Mengeneinheit', 'Inaktiv', ) + + +