Skip to content

Commit

Permalink
Merge pull request #32 from flyingcircusio/add-prices
Browse files Browse the repository at this point in the history
Add customer agreement as model
  • Loading branch information
zagy authored May 31, 2024
2 parents 936d1de + 8ec7184 commit 4ce1bf1
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 15 deletions.
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
Binary file modified collmex.ini.gpg
Binary file not shown.
13 changes: 13 additions & 0 deletions src/gocept/collmex/collmex.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,19 @@ 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
4 changes: 4 additions & 0 deletions src/gocept/collmex/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class IProduct(IModel):
"""A product (CMXPRD)."""


class ICustomerAgreement(IModel):
"""A customer agreement (CMXCAG)."""


class IActivity(IModel):
"""A product (CMXACT)."""

Expand Down
18 changes: 18 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
13 changes: 0 additions & 13 deletions src/gocept/collmex/tests/test_doctest.py

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ deps=flake8
commands=flake8 src setup.py --doctest

[pytest]
addopts = src -x --timeout=60 --instafail --reruns 2
addopts = src -x --timeout=60 --instafail --reruns 2 --doctest-modules --doctest-glob="*.rst"

0 comments on commit 4ce1bf1

Please sign in to comment.