Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

cosi5 : a Lino Così for Bangladesh

A demo project showing a Lino Così configured for usage in Bangladesh.

It is also a proof of concept for a point of sale.

See also Lino in Bengali.

>>> from lino import startup
>>> startup('lino_book.projects.cosi5.settings')
>>> from lino.api.doctest import *
>>> ses = rt.login('robin')

Overview

The lino_book.projects.cosi5 demo project is an example of a Lino Così having

The sales journal

>>> rt.show(accounting.JournalsOverview)
| **SLS** |  0 Sales invoices |
|---------|-------------------|
| **SSN** |  29 Sales notes |
|---------|-----------------|
| **SO** |  0 Sales order |
|--------|----------------|
| **SLC** |  0 Sales credit notes |
|---------|-----------------------|
| **PRC** |  42 Purchase invoices |
|---------|-----------------------|
| **OPR** |  1 Online payment reports |
|---------|---------------------------|
| **CSH** |  0 Cash book |
|---------|--------------|
| **BNK** |  5 Bestbank |
|---------|-------------|
| **MSC** |  0 Miscellaneous transactions |
|---------|-------------------------------|
| **PRE** |  1 Preliminary transactions |
|---------|-----------------------------|
| **SAL** |  0 Paychecks |
|---------|--------------|
>>> rt.show('accounting.Journals', column_names="ref name trade_type")
=========== ============================ ========================== ============
 Reference   Designation                  Designation (bn)           Trade type
----------- ---------------------------- -------------------------- ------------
 SLS         Sales invoices               বিক্রয়ের চালান              Sales
 SSN         Sales notes                  বিক্রয় চালান                Sales
 SO          Sales order                  Sales order                Sales
 SLC         Sales credit notes           Sales credit notes         Sales
 PRC         Purchase invoices            Purchase invoices          Purchases
 OPR         Online payment reports       Online payment reports
 CSH         Cash book                    Cash book
 BNK         Bestbank                     বেস্টব্যাংক
 MSC         Miscellaneous transactions   বিবিধ লেনদেন
 PRE         Preliminary transactions     Preliminary transactions
 SAL         Paychecks                    Paychecks
=========== ============================ ========================== ============
>>> rt.show(accounting.PaymentMethods)
...
==== ============== ================== ======================== ======
 ID   Designation    Designation (bn)   Payment account          Cash
---- -------------- ------------------ ------------------------ ------
 1    Cash payment   Cash payment       (5700) Cash              Yes
 2    PayPal         PayPal             (5710) Online payments   No
 3    bKash          bKash              (5710) Online payments   No
 4    Not now        Not now                                     No
==== ============== ================== ======================== ======
>>> jnl = rt.models.accounting.Journal.get_by_ref("SSN")
>>> jnl.voucher_type.table_class
lino_xl.lib.trading.ui.CashInvoicesByJournal
>>> rt.show(jnl.voucher_type.table_class, jnl)
...
===================== ============ =================================== =============== ================ =============== =============== ================
 No.                   Date         Partner                             TotIncl         Payment method   Cash received   Cash returned   Workflow
--------------------- ------------ ----------------------------------- --------------- ---------------- --------------- --------------- ----------------
 29/2021               11/06/2021   Ernst Berta                         2 299,81        Cash payment     2 300,00        0,19            **Registered**
 28/2021               10/06/2021   Dobbelstein Dorothée                11,20           Not now                                          **Registered**
 27/2021               09/06/2021   Dobbelstein-Demeulenaere Dorothée   834,00          bKash                                            **Registered**
 26/2021               08/06/2021   Demeulenaere Dorothée               580,00          PayPal                                           **Registered**
 25/2021               07/06/2021   Dericum Daniel                      59,85           Cash payment     60,00           0,15            **Registered**
 24/2021               12/05/2021   Chantraine Marc                     2 359,78        Not now                                          **Registered**
 23/2021               11/05/2021   Chantraine Marc                     3 005,45        bKash                                            **Registered**
 22/2021               10/05/2021   Charlier Ulrike                     239,20          PayPal                                           **Registered**
 21/2021               09/05/2021   Collard Charlotte                   990,00          Cash payment     995,00          5,00            **Registered**
 20/2021               08/05/2021   Bastiaensen Laurent                 279,90          Not now                                          **Registered**
 19/2021               07/05/2021   Ausdemwald Alfons                   1 199,85        bKash                                            **Registered**
 18/2021               14/04/2021   Altenberg Hans                      3 319,78        PayPal                                           **Registered**
 17/2021               13/04/2021   Arens Annette                       140,60          Cash payment     145,00          4,40            **Registered**
 16/2021               12/04/2021   Arens Andreas                       200,00          Not now                                          **Registered**
 15/2021               11/04/2021   Arens Andreas                       1 045,00        bKash                                            **Registered**
 14/2021               10/04/2021   Auto École Verte                    831,82          PayPal                                           **Registered**
 13/2021               09/04/2021   Moulin Rouge                        1 949,85        Cash payment     1 950,00        0,15            **Registered**
 12/2021               08/04/2021   Reinhards Baumschule                2 013,88        Not now                                          **Registered**
 11/2021               07/04/2021   Bernd Brechts Bücherladen           548,50          bKash                                            **Registered**
 10/2021               07/03/2021   Hans Flott & Co                     320,00          PayPal                                           **Registered**
 9/2021                10/02/2021   Van Achter NV                       815,96          Cash payment     820,00          4,04            **Registered**
 8/2021                09/02/2021   Donderweer BV                       1 939,82        Not now                                          **Registered**
 7/2021                08/02/2021   Garage Mergelsberg                  1 499,85        bKash                                            **Registered**
 6/2021                07/02/2021   Bäckerei Schmitz                    1 110,16        PayPal                                           **Registered**
 5/2021                11/01/2021   Bäckerei Mießen                     535,00          Cash payment     540,00          5,00            **Registered**
 4/2021                10/01/2021   Bäckerei Ausdemwald                 280,00          Not now                                          **Registered**
 3/2021                09/01/2021   Rumma & Ko OÜ                       679,81          bKash                                            **Registered**
 2/2021                08/01/2021   Bestbank                            2 039,82        PayPal                                           **Registered**
 1/2021                07/01/2021   Miscellaneous                       2 999,85        Cash payment     3 000,00        0,15            **Registered**
 **Total (29 rows)**                                                    **34 128,74**                    **9 810,00**    **19,08**
===================== ============ =================================== =============== ================ =============== =============== ================
>>> # invoice = rt.models.trading.CashInvoice.objects.get(id=1)
>>> invoice = rt.models.trading.CashInvoice.objects.get(
...     number=1, journal__ref="SSN", fiscal_year__ref="2021")
>>> print(invoice.payment_method)
Cash payment
>>> rt.show('accounting.MovementsByVoucher', invoice)
...
================== =============== ============== ============== ==================== =========
 Account            Partner         Debit          Credit         Match                Cleared
------------------ --------------- -------------- -------------- -------------------- ---------
 (7000) Sales                                      2 999,85                            Yes
 (4000) Customers   Miscellaneous   2 999,85                      `SSN 1/2021 <…>`__   Yes
 (4000) Customers   Miscellaneous                  2 999,85       `SSN 1/2021 <…>`__   Yes
 (5700) Cash        Miscellaneous   2 999,85                      `SSN 1/2021 <…>`__   No
                                    **5 999,70**   **5 999,70**
================== =============== ============== ============== ==================== =========
>>> # invoice = rt.models.trading.CashInvoice.objects.get(id=2)
>>> invoice = rt.models.trading.CashInvoice.objects.get(
...     number=2, journal__ref="SSN", fiscal_year__ref="2021")
>>> print(invoice.payment_method)
PayPal
>>> rt.show('accounting.MovementsByVoucher', invoice)
...
================== ========== ============== ============== ==================== =========
 Account            Partner    Debit          Credit         Match                Cleared
------------------ ---------- -------------- -------------- -------------------- ---------
 (7000) Sales                                 2 039,82                            Yes
 (4000) Customers   Bestbank   2 039,82                      `SSN 2/2021 <…>`__   Yes
                               **2 039,82**   **2 039,82**
================== ========== ============== ============== ==================== =========
>>> print(invoice.partner)
Bestbank

TODO: Having “Bestbank” as a customer is perfectly legal, but confusing in the example above. The demo fixtures should avoid using Bestbank as a supplier or customer.

Places in Bangladesh

The Wikipedia article on Dhaka Division says it contains 13 districts:

Dhaka, Faridpur, Gazipur, Gopalganj, Kishoreganj, Madaripur, Manikganj, Munshiganj, Narayanganj, Narsingdi, Rajbari, Shariatpur and Tangail

Lino and commondata agree with this:

>>> dhaka_div = countries.Place.objects.get(
...     name="Dhaka", type=countries.PlaceTypes.division)
>>> ses.show("countries.PlacesByPlace", dhaka_div)
===================== ============ ==========
 Place                 Place Type   zip code
--------------------- ------------ ----------
 `Dhaka <…>`__         District
 `Faridpur <…>`__      District
 `Gazipur <…>`__       District
 `Gopalganj <…>`__     District
 `Kishoreganj <…>`__   District
 `Madaripur <…>`__     District
 `Manikganj <…>`__     District
 `Munshiganj <…>`__    District
 `Narayanganj <…>`__   District
 `Narsingdi <…>`__     District
 `Rajbari <…>`__       District
 `Shariatpur <…>`__    District
 `Tangail <…>`__       District
===================== ============ ==========

The Wikipedia article on Gazipur District says it contains 5 upazilas (subdistricts):

Gazipur Sadar, Kaliakair, Kaliganj, Kapasia and Sreepur

Lino and commondata agree with this:

>>> gazipur = countries.Place.objects.get(
...     name="Gazipur", type=countries.PlaceTypes.district)
>>> ses.show("countries.PlacesByPlace", gazipur)
======================= ============= ==========
 Place                   Place Type    zip code
----------------------- ------------- ----------
 `Gazipur Sadar <…>`__   Subdistrict
 `Kaliakair <…>`__       Subdistrict
 `Kaliganj <…>`__        Subdistrict
 `Kapasia <…>`__         Subdistrict
 `Sreepur <…>`__         Subdistrict
======================= ============= ==========

Formatting Bangladeshi postal addresses

The country is being printed in the address depending on the country_code setting.

>>> rmu(dd.plugins.countries.country_code)
'BD'
>>> dd.plugins.countries.get_my_country()
Country #BD ('Bangladesh')

A domestic address uses just the city name:

>>> bd = countries.Country.objects.get(isocode="BD")
>>> dhanmondi = countries.Place.objects.get(
...     name="Dhanmondi", type=countries.PlaceTypes.subdistrict)
>>> p = contacts.Person(first_name="Rahim", last_name="Uddin",
...     street="Road 15", street_no="27", street_box="A",
...     country=bd, city=dhanmondi)
>>> print(p.address)
Rahim Uddin
Road 15 27 A
Dhanmondi

When a zip code is known the zip code is shown before the city name:

>>> dhaka_city = countries.Place.objects.get(
...     name="Dhaka", type=countries.PlaceTypes.city)
>>> p = contacts.Person(first_name="Kazi", last_name="Nazrul",
...     street="Mirpur Road", street_no="10",
...     zip_code="1216", country=bd, city=dhaka_city)
>>> print(p.address)
Kazi Nazrul
Mirpur Road 10
1216 Dhaka

When the recipient is abroad the country name is appended:

>>> de = countries.Country.objects.get(isocode="DE")
>>> p = contacts.Person(first_name="Kazi", last_name="Nazrul",
...     street="Mirpur Road", street_no="10",
...     country=de, city=dhaka_city)
>>> print(p.address)
Kazi Nazrul
Mirpur Road 10
Dhaka
Germany

20260425

>>> voucher_table = finan.PaymentReportsByJournal
>>> suggestions_table = voucher_table.suggestions_table

There is only one Online payment report in the demo:

>>> obj = finan.PaymentOrder.objects.get(journal__ref="OPR")
>>> rt.show(finan.ItemsByPaymentReport, master_instance=obj)
===== ===================== ========== ============ ============== ======== ================
 No.   Partner               Workflow   Match        Expense        Income   Your reference
----- --------------------- ---------- ------------ -------------- -------- ----------------
 1     Miscellaneous                    PRC 1/2021   40,00
 2     Bestbank                         PRC 2/2021   141,30
 3     Rumma & Ko OÜ                    PRC 3/2021   603,60
 4     Bäckerei Ausdemwald              PRC 4/2021   1 199,90
 5     Bäckerei Mießen                  PRC 5/2021   3 241,68
       **Total (5 rows)**                            **5 226,48**
===== ===================== ========== ============ ============== ======== ================
>>> rt.show(suggestions_table, master_instance=obj)
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| Info                                            | Match       | Due date   | Debts                                  | Payments            | Balance      |
+=================================================+=============+============+========================================+=====================+==============+
| `Arens Andreas <…>`__ |br|                      | SSN 16/2021 | 12/04/2021 | `SSN 16/2021 <…>`__ `BNK 5/2021 <…>`__ | `BNK 4/2021 <…>`__  | 0,20         |
| `(4000) Customers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Rumma & Ko OÜ <…>`__ |br|                      | PRC 31/2021 | 05/05/2021 |                                        | `PRC 31/2021 <…>`__ | 602,20       |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Bäckerei Mießen <…>`__ |br|                    | PRC 33/2021 | 07/05/2021 | `BNK 5/2021 <…>`__                     | `PRC 33/2021 <…>`__ | 972,17       |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Bastiaensen Laurent <…>`__ |br|                | SSN 20/2021 | 08/05/2021 | `SSN 20/2021 <…>`__                    | `BNK 5/2021 <…>`__  | 5,60         |
| `(4000) Customers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Chantraine Marc <…>`__ |br|                    | SSN 24/2021 | 12/05/2021 | `SSN 24/2021 <…>`__                    | `BNK 5/2021 <…>`__  | -117,99      |
| `(4000) Customers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Miscellaneous <…>`__ |br|                      | PRC 36/2021 | 03/06/2021 |                                        | `PRC 36/2021 <…>`__ | 40,00        |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Bestbank <…>`__ |br|                           | PRC 37/2021 | 04/06/2021 |                                        | `PRC 37/2021 <…>`__ | 141,30       |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Rumma & Ko OÜ <…>`__ |br|                      | PRC 38/2021 | 05/06/2021 |                                        | `PRC 38/2021 <…>`__ | 603,60       |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Bäckerei Ausdemwald <…>`__ |br|                | PRC 39/2021 | 06/06/2021 |                                        | `PRC 39/2021 <…>`__ | 1 199,90     |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Bäckerei Mießen <…>`__ |br|                    | PRC 40/2021 | 07/06/2021 |                                        | `PRC 40/2021 <…>`__ | 3 241,68     |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Demeulenaere Dorothée <…>`__ |br|              | SSN 26/2021 | 08/06/2021 | `SSN 26/2021 <…>`__                    |                     | -580,00      |
| `(4000) Customers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Bäckerei Schmitz <…>`__ |br|                   | PRC 41/2021 | 08/06/2021 |                                        | `PRC 41/2021 <…>`__ | 143,40       |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Dobbelstein-Demeulenaere Dorothée <…>`__ |br|  | SSN 27/2021 | 09/06/2021 | `SSN 27/2021 <…>`__                    |                     | -834,00      |
| `(4000) Customers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Garage Mergelsberg <…>`__ |br|                 | PRC 42/2021 | 09/06/2021 |                                        | `PRC 42/2021 <…>`__ | 199,90       |
| `(4100) Suppliers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| `Dobbelstein Dorothée <…>`__ |br|               | SSN 28/2021 | 10/06/2021 | `SSN 28/2021 <…>`__                    |                     | -11,20       |
| `(4000) Customers <…>`__                        |             |            |                                        |                     |              |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+
| **Total (15 rows)**                             |             |            |                                        |                     | **5 606,76** |
+-------------------------------------------------+-------------+------------+----------------------------------------+---------------------+--------------+

Sales orders

>>> print(dd.plugins.invoicing.order_model)
<class 'lino_xl.lib.trading.models.VatProductInvoice'>