Skip to content

Commit

Permalink
Add CustomerAgreemnt (CMXCAG)
Browse files Browse the repository at this point in the history
  • Loading branch information
zagy committed May 29, 2024
1 parent 4e18d9f commit a025b02
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Changes
- Update invoice items to current collmex field names.
(`#27 <https://github.com/gocept/gocept.collmex/pull/27>`_)

- Add CustomerAgreement (CMXCAG)


2.0.1 (2023-08-23)
------------------
Expand Down
14 changes: 14 additions & 0 deletions src/gocept/collmex/collmex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 19 additions & 1 deletion src/gocept/collmex/doctest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
-------------------------------------------------

Expand Down Expand Up @@ -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']
Expand Down
2 changes: 2 additions & 0 deletions src/gocept/collmex/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)."""
Expand Down
21 changes: 21 additions & 0 deletions src/gocept/collmex/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -408,3 +426,6 @@ class Project(Model):
'Mengeneinheit',
'Inaktiv',
)



0 comments on commit a025b02

Please sign in to comment.