shutro-erp 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account_portal/.kosh/bindings.js +1 -1
- package/dist/account_portal/.kosh/schema.d.ts +54 -3
- package/dist/account_portal/module.d.ts +359 -6
- package/dist/accounting/.kosh/bindings.js +1 -1
- package/dist/accounting/.kosh/schema.d.ts +54 -3
- package/dist/accounting/index.js +214 -2
- package/dist/accounting/module.d.ts +217 -5
- package/dist/accounting/module.js +23 -2
- package/dist/calendar/.kosh/bindings.d.ts +22 -0
- package/dist/calendar/.kosh/bindings.js +15 -0
- package/dist/calendar/.kosh/schema.d.ts +795 -0
- package/dist/calendar/demo.d.ts +6 -0
- package/dist/calendar/demo.js +24 -0
- package/dist/calendar/index.d.ts +3 -0
- package/dist/calendar/index.js +291 -0
- package/dist/calendar/module.d.ts +1705 -0
- package/dist/calendar/module.js +180 -0
- package/dist/cli/init.js +48 -0
- package/dist/cli/templates.d.ts +1 -1
- package/dist/cli/templates.js +137 -0
- package/dist/contacts/.kosh/bindings.js +1 -1
- package/dist/contacts/.kosh/schema.d.ts +78 -3
- package/dist/contacts/demo.js +30 -1
- package/dist/contacts/index.d.ts +1 -1
- package/dist/contacts/index.js +155 -9
- package/dist/contacts/module.d.ts +338 -2
- package/dist/contacts/module.js +82 -5
- package/dist/crm/.kosh/bindings.d.ts +22 -0
- package/dist/crm/.kosh/bindings.js +15 -0
- package/dist/crm/.kosh/schema.d.ts +799 -0
- package/dist/crm/demo.d.ts +6 -0
- package/dist/crm/demo.js +45 -0
- package/dist/crm/index.d.ts +3 -0
- package/dist/crm/index.js +361 -0
- package/dist/crm/module.d.ts +1843 -0
- package/dist/crm/module.js +207 -0
- package/dist/event/.kosh/bindings.d.ts +22 -0
- package/dist/event/.kosh/bindings.js +15 -0
- package/dist/event/.kosh/schema.d.ts +843 -0
- package/dist/event/demo.d.ts +6 -0
- package/dist/event/demo.js +65 -0
- package/dist/event/index.d.ts +14 -0
- package/dist/event/index.js +333 -0
- package/dist/event/mails.d.ts +15 -0
- package/dist/event/mails.js +112 -0
- package/dist/event/module.d.ts +2800 -0
- package/dist/event/module.js +323 -0
- package/dist/event/web/CheckInBox.d.ts +9 -0
- package/dist/event/web/CheckInBox.js +87 -0
- package/dist/event/web/index.d.ts +11 -0
- package/dist/event/web/index.js +16 -0
- package/dist/event/web/messages.d.ts +2 -0
- package/dist/event/web/messages.js +23 -0
- package/dist/event_account/.kosh/bindings.d.ts +22 -0
- package/dist/event_account/.kosh/bindings.js +15 -0
- package/dist/event_account/.kosh/schema.d.ts +1639 -0
- package/dist/event_account/index.d.ts +3 -0
- package/dist/event_account/index.js +28 -0
- package/dist/event_account/module.d.ts +6968 -0
- package/dist/event_account/module.js +90 -0
- package/dist/hr/.kosh/bindings.d.ts +22 -0
- package/dist/hr/.kosh/bindings.js +15 -0
- package/dist/hr/.kosh/schema.d.ts +878 -0
- package/dist/hr/demo.d.ts +6 -0
- package/dist/hr/demo.js +60 -0
- package/dist/hr/index.d.ts +3 -0
- package/dist/hr/index.js +483 -0
- package/dist/hr/module.d.ts +2611 -0
- package/dist/hr/module.js +350 -0
- package/dist/l10n_bd/.kosh/bindings.js +1 -1
- package/dist/l10n_bd/.kosh/schema.d.ts +54 -3
- package/dist/l10n_bd/module.d.ts +359 -6
- package/dist/l10n_in/.kosh/bindings.js +1 -1
- package/dist/l10n_in/.kosh/schema.d.ts +54 -3
- package/dist/l10n_in/module.d.ts +380 -7
- package/dist/maintenance/.kosh/bindings.d.ts +22 -0
- package/dist/maintenance/.kosh/bindings.js +15 -0
- package/dist/maintenance/.kosh/schema.d.ts +911 -0
- package/dist/maintenance/demo.d.ts +6 -0
- package/dist/maintenance/demo.js +60 -0
- package/dist/maintenance/index.d.ts +3 -0
- package/dist/maintenance/index.js +422 -0
- package/dist/maintenance/module.d.ts +3545 -0
- package/dist/maintenance/module.js +446 -0
- package/dist/maintenance_stock/.kosh/bindings.d.ts +22 -0
- package/dist/maintenance_stock/.kosh/bindings.js +15 -0
- package/dist/maintenance_stock/.kosh/schema.d.ts +1371 -0
- package/dist/maintenance_stock/index.d.ts +9 -0
- package/dist/maintenance_stock/index.js +52 -0
- package/dist/maintenance_stock/module.d.ts +6953 -0
- package/dist/maintenance_stock/module.js +192 -0
- package/dist/modules-sdk/index.d.ts +1 -1
- package/dist/modules-sdk/manifest.d.ts +70 -0
- package/dist/modules-sdk/manifest.js +35 -1
- package/dist/mrp/.kosh/bindings.d.ts +22 -0
- package/dist/mrp/.kosh/bindings.js +15 -0
- package/dist/mrp/.kosh/schema.d.ts +1378 -0
- package/dist/mrp/demo.d.ts +7 -0
- package/dist/mrp/demo.js +42 -0
- package/dist/mrp/index.d.ts +3 -0
- package/dist/mrp/index.js +392 -0
- package/dist/mrp/module.d.ts +8608 -0
- package/dist/mrp/module.js +695 -0
- package/dist/mrp_account/.kosh/bindings.d.ts +22 -0
- package/dist/mrp_account/.kosh/bindings.js +15 -0
- package/dist/mrp_account/.kosh/schema.d.ts +2106 -0
- package/dist/mrp_account/index.d.ts +3 -0
- package/dist/mrp_account/index.js +22 -0
- package/dist/mrp_account/module.d.ts +20840 -0
- package/dist/mrp_account/module.js +123 -0
- package/dist/payment/.kosh/bindings.js +1 -1
- package/dist/payment/.kosh/schema.d.ts +54 -3
- package/dist/payment/module.d.ts +359 -6
- package/dist/portal/.kosh/bindings.js +1 -1
- package/dist/portal/.kosh/schema.d.ts +78 -3
- package/dist/portal/module.d.ts +166 -2
- package/dist/pos/.kosh/bindings.d.ts +22 -0
- package/dist/pos/.kosh/bindings.js +15 -0
- package/dist/pos/.kosh/schema.d.ts +1690 -0
- package/dist/pos/accounting.d.ts +10 -0
- package/dist/pos/accounting.js +149 -0
- package/dist/pos/demo.d.ts +6 -0
- package/dist/pos/demo.js +90 -0
- package/dist/pos/index.d.ts +9 -0
- package/dist/pos/index.js +349 -0
- package/dist/pos/module.d.ts +9636 -0
- package/dist/pos/module.js +423 -0
- package/dist/pos/routes.d.ts +39 -0
- package/dist/pos/routes.js +368 -0
- package/dist/pos/web/Register.d.ts +9 -0
- package/dist/pos/web/Register.js +252 -0
- package/dist/pos/web/index.d.ts +11 -0
- package/dist/pos/web/index.js +16 -0
- package/dist/pos/web/messages.d.ts +2 -0
- package/dist/pos/web/messages.js +87 -0
- package/dist/pos_stock/.kosh/bindings.d.ts +22 -0
- package/dist/pos_stock/.kosh/bindings.js +15 -0
- package/dist/pos_stock/.kosh/schema.d.ts +2015 -0
- package/dist/pos_stock/index.d.ts +9 -0
- package/dist/pos_stock/index.js +35 -0
- package/dist/pos_stock/module.d.ts +11935 -0
- package/dist/pos_stock/module.js +115 -0
- package/dist/product/.kosh/bindings.js +1 -1
- package/dist/product/.kosh/schema.d.ts +51 -1
- package/dist/product/index.js +81 -4
- package/dist/product/module.d.ts +43 -1
- package/dist/product/module.js +9 -2
- package/dist/project/.kosh/bindings.js +1 -1
- package/dist/project/.kosh/schema.d.ts +54 -3
- package/dist/project/index.js +147 -7
- package/dist/project/module.d.ts +210 -2
- package/dist/project/module.js +52 -5
- package/dist/project_portal/.kosh/bindings.js +1 -1
- package/dist/project_portal/.kosh/schema.d.ts +54 -3
- package/dist/project_portal/module.d.ts +353 -4
- package/dist/purchase/.kosh/bindings.js +1 -1
- package/dist/purchase/.kosh/schema.d.ts +54 -3
- package/dist/purchase/index.js +163 -3
- package/dist/purchase/module.d.ts +215 -3
- package/dist/purchase/module.js +21 -3
- package/dist/purchase_account/.kosh/bindings.js +1 -1
- package/dist/purchase_account/.kosh/schema.d.ts +55 -3
- package/dist/purchase_account/index.js +26 -1
- package/dist/purchase_account/module.d.ts +393 -7
- package/dist/purchase_portal/.kosh/bindings.js +1 -1
- package/dist/purchase_portal/.kosh/schema.d.ts +54 -3
- package/dist/purchase_portal/module.d.ts +366 -5
- package/dist/purchase_stock/.kosh/bindings.d.ts +22 -0
- package/dist/purchase_stock/.kosh/bindings.js +15 -0
- package/dist/purchase_stock/.kosh/schema.d.ts +1310 -0
- package/dist/purchase_stock/index.d.ts +7 -0
- package/dist/purchase_stock/index.js +91 -0
- package/dist/purchase_stock/module.d.ts +6763 -0
- package/dist/purchase_stock/module.js +144 -0
- package/dist/purchase_stock_account/.kosh/bindings.d.ts +22 -0
- package/dist/purchase_stock_account/.kosh/bindings.js +15 -0
- package/dist/purchase_stock_account/.kosh/schema.d.ts +1959 -0
- package/dist/purchase_stock_account/index.d.ts +3 -0
- package/dist/purchase_stock_account/index.js +24 -0
- package/dist/purchase_stock_account/module.d.ts +35366 -0
- package/dist/purchase_stock_account/module.js +162 -0
- package/dist/recruitment/.kosh/bindings.d.ts +22 -0
- package/dist/recruitment/.kosh/bindings.js +15 -0
- package/dist/recruitment/.kosh/schema.d.ts +990 -0
- package/dist/recruitment/demo.d.ts +6 -0
- package/dist/recruitment/demo.js +45 -0
- package/dist/recruitment/index.d.ts +3 -0
- package/dist/recruitment/index.js +385 -0
- package/dist/recruitment/module.d.ts +3247 -0
- package/dist/recruitment/module.js +193 -0
- package/dist/recruitment/web/HireButton.d.ts +9 -0
- package/dist/recruitment/web/HireButton.js +32 -0
- package/dist/recruitment/web/index.d.ts +11 -0
- package/dist/recruitment/web/index.js +16 -0
- package/dist/recruitment/web/messages.d.ts +2 -0
- package/dist/recruitment/web/messages.js +19 -0
- package/dist/reporting/documents.d.ts +5 -0
- package/dist/reporting/documents.js +28 -1
- package/dist/reporting/index.d.ts +1 -1
- package/dist/reporting/index.js +4 -2
- package/dist/reporting/models.js +9 -0
- package/dist/reporting/overviews.d.ts +16 -0
- package/dist/reporting/overviews.js +56 -0
- package/dist/reporting/routes-documents.js +1 -1
- package/dist/reporting/routes.js +138 -80
- package/dist/reporting/web/DashboardView.d.ts +11 -0
- package/dist/reporting/web/DashboardView.js +2 -2
- package/dist/reporting/web/DesignerView.js +5 -0
- package/dist/reporting/web/Overview.d.ts +9 -0
- package/dist/reporting/web/Overview.js +53 -0
- package/dist/reporting/web/index.d.ts +1 -0
- package/dist/reporting/web/index.js +4 -1
- package/dist/reporting/web/messages.js +9 -0
- package/dist/sale_account/.kosh/bindings.js +1 -1
- package/dist/sale_account/.kosh/schema.d.ts +59 -3
- package/dist/sale_account/index.js +22 -1
- package/dist/sale_account/module.d.ts +461 -7
- package/dist/sale_portal/.kosh/bindings.js +1 -1
- package/dist/sale_portal/.kosh/schema.d.ts +58 -3
- package/dist/sale_portal/module.d.ts +434 -5
- package/dist/sale_project/.kosh/bindings.js +1 -1
- package/dist/sale_project/.kosh/schema.d.ts +60 -3
- package/dist/sale_project/module.d.ts +476 -6
- package/dist/sale_stock/.kosh/bindings.d.ts +22 -0
- package/dist/sale_stock/.kosh/bindings.js +15 -0
- package/dist/sale_stock/.kosh/schema.d.ts +1228 -0
- package/dist/sale_stock/index.d.ts +7 -0
- package/dist/sale_stock/index.js +84 -0
- package/dist/sale_stock/module.d.ts +6791 -0
- package/dist/sale_stock/module.js +146 -0
- package/dist/sales/.kosh/bindings.js +1 -1
- package/dist/sales/.kosh/schema.d.ts +58 -3
- package/dist/sales/index.js +191 -4
- package/dist/sales/module.d.ts +355 -3
- package/dist/sales/module.js +78 -3
- package/dist/server/api/metadata.d.ts +5 -0
- package/dist/server/api/metadata.js +5 -0
- package/dist/server/api/rest.js +64 -1
- package/dist/server/api/views.js +1 -0
- package/dist/server/app-settings.d.ts +7 -0
- package/dist/server/app-settings.js +10 -0
- package/dist/server/auth/base.js +9 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/settings/app-settings.d.ts +2 -0
- package/dist/settings/app-settings.js +518 -0
- package/dist/settings/index.d.ts +1 -0
- package/dist/settings/index.js +15 -0
- package/dist/settings/people.js +29 -5
- package/dist/settings/web/AppSettingsPage.d.ts +11 -0
- package/dist/settings/web/AppSettingsPage.js +210 -0
- package/dist/settings/web/OverviewPage.js +16 -3
- package/dist/settings/web/PeoplePage.js +20 -6
- package/dist/settings/web/index.d.ts +1 -0
- package/dist/settings/web/index.js +3 -0
- package/dist/settings/web/messages.js +118 -2
- package/dist/stock/.kosh/bindings.d.ts +22 -0
- package/dist/stock/.kosh/bindings.js +15 -0
- package/dist/stock/.kosh/schema.d.ts +1147 -0
- package/dist/stock/demo.d.ts +7 -0
- package/dist/stock/demo.js +55 -0
- package/dist/stock/index.d.ts +3 -0
- package/dist/stock/index.js +674 -0
- package/dist/stock/module.d.ts +6330 -0
- package/dist/stock/module.js +1325 -0
- package/dist/stock/web/ScanBox.d.ts +8 -0
- package/dist/stock/web/ScanBox.js +90 -0
- package/dist/stock/web/index.d.ts +11 -0
- package/dist/stock/web/index.js +16 -0
- package/dist/stock/web/messages.d.ts +2 -0
- package/dist/stock/web/messages.js +25 -0
- package/dist/stock_account/.kosh/bindings.d.ts +22 -0
- package/dist/stock_account/.kosh/bindings.js +15 -0
- package/dist/stock_account/.kosh/schema.d.ts +1875 -0
- package/dist/stock_account/index.d.ts +3 -0
- package/dist/stock_account/index.js +130 -0
- package/dist/stock_account/module.d.ts +10655 -0
- package/dist/stock_account/module.js +339 -0
- package/dist/storage/attachments.d.ts +5 -0
- package/dist/storage/attachments.js +12 -1
- package/dist/storage/models.js +3 -0
- package/dist/storage/routes.js +13 -2
- package/dist/todo/.kosh/bindings.d.ts +22 -0
- package/dist/todo/.kosh/bindings.js +15 -0
- package/dist/todo/.kosh/schema.d.ts +732 -0
- package/dist/todo/demo.d.ts +6 -0
- package/dist/todo/demo.js +35 -0
- package/dist/todo/index.d.ts +3 -0
- package/dist/todo/index.js +187 -0
- package/dist/todo/module.d.ts +1180 -0
- package/dist/todo/module.js +130 -0
- package/dist/trade_finance/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance/.kosh/bindings.js +15 -0
- package/dist/trade_finance/.kosh/schema.d.ts +884 -0
- package/dist/trade_finance/demo.d.ts +6 -0
- package/dist/trade_finance/demo.js +63 -0
- package/dist/trade_finance/index.d.ts +3 -0
- package/dist/trade_finance/index.js +413 -0
- package/dist/trade_finance/module.d.ts +3779 -0
- package/dist/trade_finance/module.js +505 -0
- package/dist/trade_finance_account/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_account/.kosh/bindings.js +15 -0
- package/dist/trade_finance_account/.kosh/schema.d.ts +1711 -0
- package/dist/trade_finance_account/index.d.ts +3 -0
- package/dist/trade_finance_account/index.js +92 -0
- package/dist/trade_finance_account/module.d.ts +7928 -0
- package/dist/trade_finance_account/module.js +244 -0
- package/dist/trade_finance_purchase/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_purchase/.kosh/bindings.js +15 -0
- package/dist/trade_finance_purchase/.kosh/schema.d.ts +1153 -0
- package/dist/trade_finance_purchase/index.d.ts +8 -0
- package/dist/trade_finance_purchase/index.js +50 -0
- package/dist/trade_finance_purchase/module.d.ts +4252 -0
- package/dist/trade_finance_purchase/module.js +44 -0
- package/dist/trade_finance_sale/.kosh/bindings.d.ts +22 -0
- package/dist/trade_finance_sale/.kosh/bindings.js +15 -0
- package/dist/trade_finance_sale/.kosh/schema.d.ts +1071 -0
- package/dist/trade_finance_sale/index.d.ts +8 -0
- package/dist/trade_finance_sale/index.js +50 -0
- package/dist/trade_finance_sale/module.d.ts +4280 -0
- package/dist/trade_finance_sale/module.js +44 -0
- package/dist/ui/api.d.ts +2 -1
- package/dist/ui/api.js +2 -1
- package/dist/ui/app.js +2 -1
- package/dist/ui/components/AppIcon.js +23 -1
- package/dist/ui/components/primitives.d.ts +2 -0
- package/dist/ui/components/primitives.js +7 -1
- package/dist/ui/i18n/messages.d.ts +23 -0
- package/dist/ui/i18n/messages.js +38 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/offline/queue.d.ts +5 -1
- package/dist/ui/offline/queue.js +2 -0
- package/dist/ui/registry.d.ts +5 -0
- package/dist/ui/shell/Home.js +55 -4
- package/dist/ui/views/FormView.js +98 -17
- package/dist/ui/views/KanbanView.d.ts +2 -0
- package/dist/ui/views/KanbanView.js +32 -3
- package/dist/ui/views/ListView.js +108 -11
- package/dist/ui/views/StatsRow.d.ts +14 -0
- package/dist/ui/views/StatsRow.js +88 -0
- package/dist/ui/views/widgets.d.ts +2 -1
- package/dist/ui/views/widgets.js +194 -1
- package/dist/views/builders.d.ts +19 -2
- package/dist/views/builders.js +21 -1
- package/dist/views/condition.d.ts +6 -0
- package/dist/views/condition.js +20 -0
- package/dist/views/documents.d.ts +8 -0
- package/dist/views/extend.d.ts +2 -2
- package/dist/views/extend.js +11 -1
- package/dist/views/index.d.ts +2 -2
- package/dist/views/index.js +2 -2
- package/dist/views/types.d.ts +52 -5
- package/dist/views/validate.js +39 -1
- package/dist/website/.kosh/bindings.d.ts +22 -0
- package/dist/website/.kosh/bindings.js +15 -0
- package/dist/website/.kosh/schema.d.ts +881 -0
- package/dist/website/demo.d.ts +6 -0
- package/dist/website/demo.js +115 -0
- package/dist/website/index.d.ts +9 -0
- package/dist/website/index.js +250 -0
- package/dist/website/module.d.ts +2987 -0
- package/dist/website/module.js +281 -0
- package/dist/website/render.d.ts +45 -0
- package/dist/website/render.js +102 -0
- package/dist/website/routes.d.ts +12 -0
- package/dist/website/routes.js +246 -0
- package/dist/website/web/PagePreview.d.ts +7 -0
- package/dist/website/web/PagePreview.js +33 -0
- package/dist/website/web/index.d.ts +11 -0
- package/dist/website/web/index.js +16 -0
- package/dist/website/web/messages.d.ts +2 -0
- package/dist/website/web/messages.js +15 -0
- package/dist/website_crm/.kosh/bindings.d.ts +22 -0
- package/dist/website_crm/.kosh/bindings.js +15 -0
- package/dist/website_crm/.kosh/schema.d.ts +966 -0
- package/dist/website_crm/index.d.ts +3 -0
- package/dist/website_crm/index.js +39 -0
- package/dist/website_crm/module.d.ts +2955 -0
- package/dist/website_crm/module.js +44 -0
- package/package.json +118 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A closed session in the books (RFC 0021, Counter step 2): one entry in the shop's sales journal — the sales'
|
|
3
|
+
* untaxed amounts to the journal's income account, each tax to its account, the payments per method to their
|
|
4
|
+
* journals' accounts (cash less the change given), and the cash difference at closing to the shop's difference
|
|
5
|
+
* account — posted as the cashier with the posting grant. A shop without a sales journal books nothing.
|
|
6
|
+
*/
|
|
7
|
+
import { type Id } from '../server/orm.js';
|
|
8
|
+
import type { Env } from './.kosh/bindings.js';
|
|
9
|
+
/** Books the closed sessions that have a sales journal; returns the entries made, by session. */
|
|
10
|
+
export declare function bookSessions(env: Env, ids: readonly Id<'pos.session'>[]): Promise<Map<number, number>>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A closed session in the books (RFC 0021, Counter step 2): one entry in the shop's sales journal — the sales'
|
|
3
|
+
* untaxed amounts to the journal's income account, each tax to its account, the payments per method to their
|
|
4
|
+
* journals' accounts (cash less the change given), and the cash difference at closing to the shop's difference
|
|
5
|
+
* account — posted as the cashier with the posting grant. A shop without a sales journal books nothing.
|
|
6
|
+
*/
|
|
7
|
+
import { orm } from '../server/orm.js';
|
|
8
|
+
const ZERO = orm.toDecimal(0);
|
|
9
|
+
/** Books the closed sessions that have a sales journal; returns the entries made, by session. */
|
|
10
|
+
export async function bookSessions(env, ids) {
|
|
11
|
+
const out = new Map();
|
|
12
|
+
const sessions = await env
|
|
13
|
+
.model('pos.session')
|
|
14
|
+
.browse(ids)
|
|
15
|
+
.load({
|
|
16
|
+
shop: { salesJournal: true, differenceAccount: true },
|
|
17
|
+
company: { currency: true },
|
|
18
|
+
orders: { lines: { taxes: true }, payments: { method: { journal: true } } },
|
|
19
|
+
});
|
|
20
|
+
for (const s of sessions) {
|
|
21
|
+
if (s.state !== 'closed' || s.entry !== null)
|
|
22
|
+
continue;
|
|
23
|
+
const journal = s.shop.salesJournal;
|
|
24
|
+
if (journal === null)
|
|
25
|
+
continue;
|
|
26
|
+
const income = journal.defaultAccount?.id ?? null;
|
|
27
|
+
if (income === null)
|
|
28
|
+
throw new orm.ValidationError('pos.session', ['state'], `The sales journal ${journal.code} of ${s.shop.name} has no default account.`, 'Set the income account as the journal’s default account (Accounting › Configuration).');
|
|
29
|
+
const lines = [];
|
|
30
|
+
const add = (account, debit, credit, name) => {
|
|
31
|
+
const existing = lines.find((l) => l.account === account && l.name === name);
|
|
32
|
+
if (existing === undefined)
|
|
33
|
+
lines.push({ account, debit, credit, name });
|
|
34
|
+
else {
|
|
35
|
+
existing.debit = existing.debit.plus(debit);
|
|
36
|
+
existing.credit = existing.credit.plus(credit);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
let untaxed = ZERO;
|
|
40
|
+
const taxes = new Map();
|
|
41
|
+
const byMethod = new Map();
|
|
42
|
+
for (const o of s.orders) {
|
|
43
|
+
if (o.state !== 'paid')
|
|
44
|
+
continue;
|
|
45
|
+
for (const l of o.lines) {
|
|
46
|
+
untaxed = untaxed.plus(l.subtotal ?? ZERO);
|
|
47
|
+
// The line's tax, shared between its taxes in proportion to their rates (fixed taxes by their amount).
|
|
48
|
+
const lineTax = l.taxAmount ?? ZERO;
|
|
49
|
+
const parts = [...l.taxes].map((t) => ({
|
|
50
|
+
tax: t,
|
|
51
|
+
weight: t.amountType === 'percent' ? t.rate : t.fixedAmount.times(l.quantity),
|
|
52
|
+
}));
|
|
53
|
+
const total = parts.reduce((sum, p) => sum.plus(p.weight), ZERO);
|
|
54
|
+
for (const p of parts) {
|
|
55
|
+
const share = total.isZero()
|
|
56
|
+
? ZERO
|
|
57
|
+
: lineTax.times(p.weight).div(total).toDecimalPlaces(2);
|
|
58
|
+
const slot = taxes.get(p.tax.id) ?? {
|
|
59
|
+
account: p.tax.account?.id ?? null,
|
|
60
|
+
name: p.tax.name,
|
|
61
|
+
amount: ZERO,
|
|
62
|
+
};
|
|
63
|
+
slot.amount = slot.amount.plus(share);
|
|
64
|
+
taxes.set(p.tax.id, slot);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const p of o.payments) {
|
|
68
|
+
const slot = byMethod.get(p.method.id) ?? {
|
|
69
|
+
account: p.method.journal?.defaultAccount?.id ?? null,
|
|
70
|
+
name: p.method.name,
|
|
71
|
+
amount: ZERO,
|
|
72
|
+
};
|
|
73
|
+
slot.amount = slot.amount.plus(p.amount);
|
|
74
|
+
byMethod.set(p.method.id, slot);
|
|
75
|
+
}
|
|
76
|
+
// The change comes out of the cash taken.
|
|
77
|
+
const change = o.change ?? ZERO;
|
|
78
|
+
if (change.gt(0)) {
|
|
79
|
+
const cash = [...o.payments].find((p) => p.method.kind === 'cash');
|
|
80
|
+
if (cash !== undefined) {
|
|
81
|
+
const slot = byMethod.get(cash.method.id);
|
|
82
|
+
if (slot !== undefined)
|
|
83
|
+
slot.amount = slot.amount.minus(change);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
add(income, ZERO, untaxed, `${s.name} sales`);
|
|
88
|
+
for (const t of taxes.values())
|
|
89
|
+
add(t.account ?? income, ZERO, t.amount, `${s.name} ${t.name}`);
|
|
90
|
+
for (const m of byMethod.values()) {
|
|
91
|
+
if (m.account === null)
|
|
92
|
+
throw new orm.ValidationError('pos.session', ['state'], `The payment method ${m.name} has no journal with a default account.`, 'Give the method a journal (Counter › Shops).');
|
|
93
|
+
add(m.account, m.amount, ZERO, `${s.name} ${m.name}`);
|
|
94
|
+
}
|
|
95
|
+
const difference = s.closingDifference ?? ZERO;
|
|
96
|
+
if (!difference.isZero()) {
|
|
97
|
+
// More cash than expected: the drawer holds it (debit), a gain (credit); less: a loss.
|
|
98
|
+
const cash = [...byMethod.values()].find((m) => m.account !== null);
|
|
99
|
+
const differenceAccount = s.shop.differenceAccount?.id ?? income;
|
|
100
|
+
if (cash?.account !== null && cash !== undefined) {
|
|
101
|
+
if (difference.gt(0)) {
|
|
102
|
+
add(cash.account, difference, ZERO, `${s.name} cash counted over`);
|
|
103
|
+
add(differenceAccount, ZERO, difference, `${s.name} cash difference`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
add(differenceAccount, difference.neg(), ZERO, `${s.name} cash difference`);
|
|
107
|
+
add(cash.account, ZERO, difference.neg(), `${s.name} cash counted short`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const debit = lines.reduce((sum, l) => sum.plus(l.debit), ZERO);
|
|
112
|
+
const credit = lines.reduce((sum, l) => sum.plus(l.credit), ZERO);
|
|
113
|
+
if (debit.isZero() && credit.isZero())
|
|
114
|
+
continue;
|
|
115
|
+
if (!debit.minus(credit).abs().lt(orm.toDecimal('0.05')))
|
|
116
|
+
throw new orm.ValidationError('pos.session', ['state'], `${s.name} does not balance (${debit.toString()} against ${credit.toString()}).`, 'Check the sales’ taxes and payments.');
|
|
117
|
+
// Rounding of tax shares: the last cent goes with the income.
|
|
118
|
+
const gap = debit.minus(credit);
|
|
119
|
+
if (!gap.isZero())
|
|
120
|
+
add(income, ZERO, gap, `${s.name} rounding`);
|
|
121
|
+
const made = await env.model('account.move').create([
|
|
122
|
+
{
|
|
123
|
+
kind: 'entry',
|
|
124
|
+
journal: journal.id,
|
|
125
|
+
company: s.company.id,
|
|
126
|
+
currency: s.company.currency.id,
|
|
127
|
+
date: env.today(),
|
|
128
|
+
ref: `${s.name} (${s.shop.name})`,
|
|
129
|
+
lines: {
|
|
130
|
+
create: lines.map((l) => ({
|
|
131
|
+
...l,
|
|
132
|
+
debit: l.debit.toString(),
|
|
133
|
+
credit: l.credit.toString(),
|
|
134
|
+
})),
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
]);
|
|
138
|
+
await env.withGrants({ grants: ['account.post'], reason: `counter session ${s.name}` }, (e) => e.model('account.move').browse(made.ids).post());
|
|
139
|
+
const entry = made.ids[0];
|
|
140
|
+
if (entry !== undefined) {
|
|
141
|
+
await env
|
|
142
|
+
.model('pos.session')
|
|
143
|
+
.browse([s.id])
|
|
144
|
+
.write({ entry });
|
|
145
|
+
out.set(s.id, entry);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counter's demo data (RFC 0008 §5.8): the shop with cash and card, a session opened by the cashier with the
|
|
3
|
+
* drawer's cash, and two sales paid — one by card, one in cash with change given.
|
|
4
|
+
*/
|
|
5
|
+
import type { DemoContext } from '../modules-sdk/index.js';
|
|
6
|
+
export declare function posDemo(ctx: DemoContext): Promise<string>;
|
package/dist/pos/demo.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { orm } from '../server/orm.js';
|
|
2
|
+
const DINA = { login: 'dina', name: 'Dina Rahman', groups: ['pos.manager'] };
|
|
3
|
+
const RAHIM = { login: 'rahim', name: 'Rahim Uddin', groups: ['pos.cashier'] };
|
|
4
|
+
export async function posDemo(ctx) {
|
|
5
|
+
let shop;
|
|
6
|
+
let cash;
|
|
7
|
+
let card;
|
|
8
|
+
await ctx.as(DINA, async (raw) => {
|
|
9
|
+
const env = raw;
|
|
10
|
+
const [journal] = (await env.model('account.journal').search({ where: { type: 'sale' }, limit: 1 })).ids;
|
|
11
|
+
const made = await env.model('pos.shop').create([
|
|
12
|
+
{
|
|
13
|
+
name: 'Padma Shop, Dhanmondi',
|
|
14
|
+
pricesIncludeTax: true,
|
|
15
|
+
receiptFooter: 'Thank you — exchanges within 7 days with this receipt.',
|
|
16
|
+
...(journal === undefined ? {} : { salesJournal: journal }),
|
|
17
|
+
methods: {
|
|
18
|
+
create: [
|
|
19
|
+
{ name: 'Cash', kind: 'cash', sequence: 1 },
|
|
20
|
+
{ name: 'Card', kind: 'card', sequence: 2 },
|
|
21
|
+
{ name: 'bKash', kind: 'mobile', sequence: 3 },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
]);
|
|
26
|
+
shop = made.ids[0];
|
|
27
|
+
if (shop === undefined)
|
|
28
|
+
return;
|
|
29
|
+
const methods = await env
|
|
30
|
+
.model('pos.payment.method')
|
|
31
|
+
.search({ where: { shop: shop } });
|
|
32
|
+
for (const m of methods) {
|
|
33
|
+
if (m.kind === 'cash')
|
|
34
|
+
cash = m.id;
|
|
35
|
+
if (m.kind === 'card')
|
|
36
|
+
card = m.id;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (shop === undefined || cash === undefined || card === undefined)
|
|
40
|
+
return 'Counter: no shop';
|
|
41
|
+
await ctx.as(RAHIM, async (raw) => {
|
|
42
|
+
const env = raw;
|
|
43
|
+
const session = await env
|
|
44
|
+
.model('pos.session')
|
|
45
|
+
.create([{ shop: shop, openingCash: orm.toDecimal('5000') }]);
|
|
46
|
+
const [sessionId] = session.ids;
|
|
47
|
+
if (sessionId === undefined)
|
|
48
|
+
return;
|
|
49
|
+
const products = await env
|
|
50
|
+
.model('product.product')
|
|
51
|
+
.search({ where: { saleOk: true, kind: 'goods' }, order: ['id asc'], limit: 2 });
|
|
52
|
+
const [first, second] = [...products];
|
|
53
|
+
if (first === undefined)
|
|
54
|
+
return;
|
|
55
|
+
const sale = async (lines, payments, clientId) => {
|
|
56
|
+
const made = await env.model('pos.order').create([
|
|
57
|
+
{
|
|
58
|
+
session: sessionId,
|
|
59
|
+
clientId,
|
|
60
|
+
lines: {
|
|
61
|
+
create: lines.map((l) => ({
|
|
62
|
+
product: l.product.id,
|
|
63
|
+
name: l.product.name,
|
|
64
|
+
quantity: orm.toDecimal(l.quantity),
|
|
65
|
+
priceUnit: l.product.listPrice,
|
|
66
|
+
discount: orm.toDecimal(0),
|
|
67
|
+
})),
|
|
68
|
+
},
|
|
69
|
+
payments: {
|
|
70
|
+
create: payments.map((p) => ({ method: p.method, amount: orm.toDecimal(p.amount) })),
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
await env.flush();
|
|
75
|
+
await made.pay();
|
|
76
|
+
};
|
|
77
|
+
const price = (p, qty) => p.listPrice.times(qty).toString();
|
|
78
|
+
await sale([{ product: first, quantity: '2' }], [{ method: card, amount: price(first, 2) }], 'demo-1');
|
|
79
|
+
if (second !== undefined) {
|
|
80
|
+
const due = second.listPrice.plus(first.listPrice);
|
|
81
|
+
const given = due.plus(100);
|
|
82
|
+
await sale([
|
|
83
|
+
{ product: second, quantity: '1' },
|
|
84
|
+
{ product: first, quantity: '1' },
|
|
85
|
+
], [{ method: cash, amount: given.toString() }], 'demo-2');
|
|
86
|
+
void due;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return 'Counter: a shop with 3 payment methods, an open session, 2 sales';
|
|
90
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineModule } from '../modules-sdk/index.js';
|
|
2
|
+
import { type CounterOptions } from './routes.js';
|
|
3
|
+
export { bookSessions } from './accounting.js';
|
|
4
|
+
export { amountOf, PosOrder, PosOrderLine, PosOrderPayment, PosPaymentMethod, PosSession, PosShop, posShutro, } from './module.js';
|
|
5
|
+
export { type CounterOptions, registerCounterRoutes, type SaleInput } from './routes.js';
|
|
6
|
+
/** Counter with explicit options (tests: a memory mailer and messenger for receipts). */
|
|
7
|
+
export declare function posModule(options?: CounterOptions): ReturnType<typeof defineModule>;
|
|
8
|
+
/** Counter: SMTP and the text messenger from the environment for receipts. */
|
|
9
|
+
export declare const pos: ReturnType<typeof defineModule>;
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* `shutro-erp/pos` (RFC 0021): the **Counter** app. Shops with their payment methods, cashiers' sessions with opening
|
|
4
|
+
* and closing counts, sales with lines, taxes, several payments and the change — accepted once per device
|
|
5
|
+
* reference — and the register, a page for a tablet or a phone. Receipts are documents. What a closed session
|
|
6
|
+
* means to Stockroom and Accounting is the bridges' (`pos_stock`, `pos_account`).
|
|
7
|
+
*/
|
|
8
|
+
import { accounting } from '../accounting/index.js';
|
|
9
|
+
import { contacts } from '../contacts/index.js';
|
|
10
|
+
import { messaging } from '../messaging/index.js';
|
|
11
|
+
import { defineModule } from '../modules-sdk/index.js';
|
|
12
|
+
import { product } from '../product/index.js';
|
|
13
|
+
import { reporting } from '../reporting/index.js';
|
|
14
|
+
import { action, form, list, search } from '../views/index.js';
|
|
15
|
+
import { posDemo } from './demo.js';
|
|
16
|
+
import { PosOrder, PosPaymentMethod, PosSession, PosShop, posShutro } from './module.js';
|
|
17
|
+
import { registerCounterRoutes } from './routes.js';
|
|
18
|
+
export { bookSessions } from './accounting.js';
|
|
19
|
+
export { amountOf, PosOrder, PosOrderLine, PosOrderPayment, PosPaymentMethod, PosSession, PosShop, posShutro, } from './module.js';
|
|
20
|
+
export { registerCounterRoutes } from './routes.js';
|
|
21
|
+
/** Counter with explicit options (tests: a memory mailer and messenger for receipts). */
|
|
22
|
+
export function posModule(options = {}) {
|
|
23
|
+
return defineModule({
|
|
24
|
+
shutro: posShutro,
|
|
25
|
+
kosh: '^0.1.0',
|
|
26
|
+
hooks: { demo: posDemo },
|
|
27
|
+
depends: [product, contacts, accounting, messaging, reporting],
|
|
28
|
+
app: {
|
|
29
|
+
code: 'counter',
|
|
30
|
+
label: 'Counter',
|
|
31
|
+
icon: 'counter',
|
|
32
|
+
sequence: 43,
|
|
33
|
+
category: 'Sales',
|
|
34
|
+
summary: 'Point of sale: sessions, split payments, receipts, the register on a tablet',
|
|
35
|
+
},
|
|
36
|
+
accessLevels: {
|
|
37
|
+
cashier: { label: 'Cashier (sell in own sessions)', groups: ['pos.cashier'] },
|
|
38
|
+
manager: {
|
|
39
|
+
label: 'Manager (shops, methods, every session)',
|
|
40
|
+
groups: ['pos.manager'],
|
|
41
|
+
implies: ['cashier'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
events: [{ topic: 'pos.order.paid', model: 'pos.order', label: 'Sale paid at the counter' }],
|
|
45
|
+
documents: [
|
|
46
|
+
{
|
|
47
|
+
key: 'receipt',
|
|
48
|
+
name: 'Receipt',
|
|
49
|
+
model: 'pos.order',
|
|
50
|
+
layout: {
|
|
51
|
+
paper: 'A4',
|
|
52
|
+
header: '{{company.name}}',
|
|
53
|
+
blocks: [
|
|
54
|
+
{ kind: 'heading', id: 'title', text: '{{name}}', level: 1 },
|
|
55
|
+
{
|
|
56
|
+
kind: 'fields',
|
|
57
|
+
id: 'when',
|
|
58
|
+
items: [
|
|
59
|
+
{ label: 'Date', bind: 'date' },
|
|
60
|
+
{ label: 'Session', bind: 'session.name' },
|
|
61
|
+
{ label: 'Customer', bind: 'partner.name' },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
kind: 'table',
|
|
66
|
+
id: 'lines',
|
|
67
|
+
bind: 'lines',
|
|
68
|
+
columns: [
|
|
69
|
+
{ label: 'Item', bind: 'name' },
|
|
70
|
+
{ label: 'Qty', bind: 'quantity' },
|
|
71
|
+
{ label: 'Price', bind: 'priceUnit' },
|
|
72
|
+
{ label: 'Amount', bind: 'subtotal' },
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
kind: 'fields',
|
|
77
|
+
id: 'totals',
|
|
78
|
+
items: [
|
|
79
|
+
{ label: 'Untaxed', bind: 'amountUntaxed' },
|
|
80
|
+
{ label: 'Taxes', bind: 'amountTax' },
|
|
81
|
+
{ label: 'Total', bind: 'total' },
|
|
82
|
+
{ label: 'Paid', bind: 'amountPaid' },
|
|
83
|
+
{ label: 'Change', bind: 'change' },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{ kind: 'qr', id: 'qr', bind: 'name', size: 30, label: 'Sale reference' },
|
|
87
|
+
{ kind: 'text', id: 'footer', text: '{{session.shop.receiptFooter}}' },
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
routes: (context) => registerCounterRoutes(context, options),
|
|
93
|
+
overview: {
|
|
94
|
+
cards: [
|
|
95
|
+
{
|
|
96
|
+
id: 'sold_today',
|
|
97
|
+
title: 'Sold this month',
|
|
98
|
+
kind: 'kpi',
|
|
99
|
+
model: 'pos.order',
|
|
100
|
+
measure: 'sum:total',
|
|
101
|
+
filter: { state: 'paid' },
|
|
102
|
+
comparison: { field: 'date', mode: 'previous' },
|
|
103
|
+
w: 3,
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 'sales_month',
|
|
107
|
+
title: 'Sales this month',
|
|
108
|
+
kind: 'kpi',
|
|
109
|
+
model: 'pos.order',
|
|
110
|
+
measure: 'count',
|
|
111
|
+
filter: { state: 'paid' },
|
|
112
|
+
comparison: { field: 'date', mode: 'previous' },
|
|
113
|
+
w: 3,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 'open_sessions',
|
|
117
|
+
title: 'Open sessions',
|
|
118
|
+
kind: 'kpi',
|
|
119
|
+
model: 'pos.session',
|
|
120
|
+
measure: 'count',
|
|
121
|
+
filter: { state: 'open' },
|
|
122
|
+
w: 3,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 'average_sale',
|
|
126
|
+
title: 'Average sale',
|
|
127
|
+
kind: 'kpi',
|
|
128
|
+
model: 'pos.order',
|
|
129
|
+
measure: 'avg:total',
|
|
130
|
+
filter: { state: 'paid' },
|
|
131
|
+
w: 3,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 'by_day',
|
|
135
|
+
title: 'Sold by day',
|
|
136
|
+
kind: 'chart',
|
|
137
|
+
model: 'pos.order',
|
|
138
|
+
measure: 'sum:total',
|
|
139
|
+
groupBy: 'date:day',
|
|
140
|
+
filter: { state: 'paid' },
|
|
141
|
+
chart: 'bar',
|
|
142
|
+
w: 6,
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: 'by_method',
|
|
146
|
+
title: 'By payment method',
|
|
147
|
+
kind: 'chart',
|
|
148
|
+
model: 'pos.order.payment',
|
|
149
|
+
measure: 'sum:amount',
|
|
150
|
+
groupBy: 'method',
|
|
151
|
+
chart: 'pie',
|
|
152
|
+
w: 6,
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: 'top_products',
|
|
156
|
+
title: 'Best sellers',
|
|
157
|
+
kind: 'pivot',
|
|
158
|
+
model: 'pos.order.line',
|
|
159
|
+
measure: 'sum:quantity',
|
|
160
|
+
groupBy: 'product',
|
|
161
|
+
w: 6,
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: 'differences',
|
|
165
|
+
title: 'Closing differences',
|
|
166
|
+
kind: 'list',
|
|
167
|
+
model: 'pos.session',
|
|
168
|
+
measure: 'sum:closingDifference',
|
|
169
|
+
filter: { state: 'closed' },
|
|
170
|
+
w: 6,
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
actions: {
|
|
175
|
+
'counter.action_register': { type: 'client', page: 'counter.Register', label: 'Register' },
|
|
176
|
+
'counter.action_sessions': action(PosSession, { label: 'Sessions', views: ['list', 'form'] }),
|
|
177
|
+
'counter.action_orders': action(PosOrder, {
|
|
178
|
+
label: 'Sales',
|
|
179
|
+
views: ['list', 'form'],
|
|
180
|
+
defaultFilters: ['paid'],
|
|
181
|
+
}),
|
|
182
|
+
'counter.action_shops': action(PosShop, {
|
|
183
|
+
label: 'Shops',
|
|
184
|
+
views: ['list', 'form'],
|
|
185
|
+
visibleTo: ['pos.manager'],
|
|
186
|
+
}),
|
|
187
|
+
},
|
|
188
|
+
menus: [
|
|
189
|
+
{ id: 'counter.root', label: 'Counter', app: 'counter' },
|
|
190
|
+
{
|
|
191
|
+
id: 'counter.register',
|
|
192
|
+
parent: 'counter.root',
|
|
193
|
+
label: 'Register',
|
|
194
|
+
action: 'counter.action_register',
|
|
195
|
+
sequence: 1,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
id: 'counter.sessions',
|
|
199
|
+
parent: 'counter.root',
|
|
200
|
+
label: 'Sessions',
|
|
201
|
+
action: 'counter.action_sessions',
|
|
202
|
+
sequence: 2,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: 'counter.orders',
|
|
206
|
+
parent: 'counter.root',
|
|
207
|
+
label: 'Sales',
|
|
208
|
+
action: 'counter.action_orders',
|
|
209
|
+
sequence: 3,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: 'counter.shops',
|
|
213
|
+
parent: 'counter.root',
|
|
214
|
+
label: 'Shops',
|
|
215
|
+
action: 'counter.action_shops',
|
|
216
|
+
sequence: 9,
|
|
217
|
+
visibleTo: ['pos.manager'],
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
views: {
|
|
221
|
+
'pos.session.list': list(PosSession, {
|
|
222
|
+
columns: [
|
|
223
|
+
'name',
|
|
224
|
+
'shop',
|
|
225
|
+
'cashier',
|
|
226
|
+
'openedAt',
|
|
227
|
+
'closedAt',
|
|
228
|
+
'orderCount',
|
|
229
|
+
{ field: 'total', sum: true },
|
|
230
|
+
'expectedCash',
|
|
231
|
+
'closingCash',
|
|
232
|
+
'closingDifference',
|
|
233
|
+
{ field: 'state', widget: 'badge' },
|
|
234
|
+
],
|
|
235
|
+
decorations: {
|
|
236
|
+
success: { state: 'closed', closingDifference: '0' },
|
|
237
|
+
warning: { state: 'open' },
|
|
238
|
+
},
|
|
239
|
+
}),
|
|
240
|
+
'pos.session.form': form(PosSession, (k) => ({
|
|
241
|
+
header: {
|
|
242
|
+
statusbar: 'state',
|
|
243
|
+
buttons: [k.button('close', { primary: true, label: 'Close the session' })],
|
|
244
|
+
},
|
|
245
|
+
sheet: [
|
|
246
|
+
k.group('main', ['name', 'shop', 'cashier', 'openedAt', 'closedAt']),
|
|
247
|
+
k.group('cash', ['openingCash', 'expectedCash', 'closingCash', 'closingDifference', 'differenceReason'], {
|
|
248
|
+
label: 'Cash',
|
|
249
|
+
description: 'Count the drawer before closing; a difference needs a reason.',
|
|
250
|
+
}),
|
|
251
|
+
k.group('totals', ['orderCount', 'total', 'entry'], { label: 'Totals' }),
|
|
252
|
+
],
|
|
253
|
+
chatter: true,
|
|
254
|
+
})),
|
|
255
|
+
'pos.order.list': list(PosOrder, {
|
|
256
|
+
columns: [
|
|
257
|
+
'name',
|
|
258
|
+
'date',
|
|
259
|
+
'session',
|
|
260
|
+
'partner',
|
|
261
|
+
{ field: 'total', sum: true },
|
|
262
|
+
{ field: 'amountTax', sum: true },
|
|
263
|
+
'change',
|
|
264
|
+
{ field: 'state', widget: 'badge' },
|
|
265
|
+
],
|
|
266
|
+
decorations: { neutral: { state: 'void' } },
|
|
267
|
+
}),
|
|
268
|
+
'pos.order.form': form(PosOrder, (k) => ({
|
|
269
|
+
header: {
|
|
270
|
+
statusbar: 'state',
|
|
271
|
+
buttons: [
|
|
272
|
+
k.button('pay', { primary: true, label: 'Mark paid' }),
|
|
273
|
+
k.button('void', { label: 'Void' }),
|
|
274
|
+
],
|
|
275
|
+
},
|
|
276
|
+
sheet: [
|
|
277
|
+
k.group('main', [
|
|
278
|
+
'name',
|
|
279
|
+
'session',
|
|
280
|
+
'date',
|
|
281
|
+
'partner',
|
|
282
|
+
'refundOf',
|
|
283
|
+
'refundReason',
|
|
284
|
+
'note',
|
|
285
|
+
]),
|
|
286
|
+
k.lines('lines', [
|
|
287
|
+
'product',
|
|
288
|
+
{ field: 'name', id: 'line_name' },
|
|
289
|
+
'quantity',
|
|
290
|
+
'priceUnit',
|
|
291
|
+
'discount',
|
|
292
|
+
'taxes',
|
|
293
|
+
'subtotal',
|
|
294
|
+
'taxAmount',
|
|
295
|
+
]),
|
|
296
|
+
k.lines('payments', ['method', { field: 'amount', id: 'payment_amount' }, 'reference']),
|
|
297
|
+
k.group('totals', ['amountUntaxed', 'amountTax', 'total', 'amountPaid', 'change'], {
|
|
298
|
+
label: 'Totals',
|
|
299
|
+
}),
|
|
300
|
+
k.lines('refunds', [
|
|
301
|
+
{ field: 'name', id: 'refund_name' },
|
|
302
|
+
{ field: 'date', id: 'refund_date' },
|
|
303
|
+
{ field: 'refundReason', id: 'refund_reason' },
|
|
304
|
+
{ field: 'total', id: 'refund_total' },
|
|
305
|
+
]),
|
|
306
|
+
],
|
|
307
|
+
chatter: true,
|
|
308
|
+
})),
|
|
309
|
+
'pos.shop.list': list(PosShop, { columns: ['name', 'pricesIncludeTax', 'salesJournal'] }),
|
|
310
|
+
'pos.shop.form': form(PosShop, (k) => ({
|
|
311
|
+
header: { buttons: [] },
|
|
312
|
+
sheet: [
|
|
313
|
+
k.group('main', [
|
|
314
|
+
'name',
|
|
315
|
+
'pricesIncludeTax',
|
|
316
|
+
'salesJournal',
|
|
317
|
+
'differenceAccount',
|
|
318
|
+
'receiptFooter',
|
|
319
|
+
]),
|
|
320
|
+
k.lines('methods', [{ field: 'name', id: 'method_name' }, 'kind', 'journal', 'sequence']),
|
|
321
|
+
],
|
|
322
|
+
})),
|
|
323
|
+
'pos.payment.method.list': list(PosPaymentMethod, {
|
|
324
|
+
columns: ['name', 'shop', 'kind', 'journal'],
|
|
325
|
+
}),
|
|
326
|
+
},
|
|
327
|
+
search: {
|
|
328
|
+
'pos.session': search(PosSession, {
|
|
329
|
+
fields: ['name', 'shop.name', 'cashier.name'],
|
|
330
|
+
filters: {
|
|
331
|
+
open: { label: 'Open', domain: { state: 'open' }, group: 'state' },
|
|
332
|
+
closed: { label: 'Closed', domain: { state: 'closed' }, group: 'state' },
|
|
333
|
+
},
|
|
334
|
+
groupBy: ['shop', 'cashier', 'state', 'openedAt:day'],
|
|
335
|
+
}),
|
|
336
|
+
'pos.order': search(PosOrder, {
|
|
337
|
+
fields: ['name', 'partner.name', 'note'],
|
|
338
|
+
filters: {
|
|
339
|
+
paid: { label: 'Paid', domain: { state: 'paid' }, group: 'state' },
|
|
340
|
+
voided: { label: 'Voided', domain: { state: 'void' }, group: 'state' },
|
|
341
|
+
},
|
|
342
|
+
groupBy: ['session', 'partner', 'date:day'],
|
|
343
|
+
}),
|
|
344
|
+
'pos.shop': search(PosShop, { fields: ['name'] }),
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/** Counter: SMTP and the text messenger from the environment for receipts. */
|
|
349
|
+
export const pos = posModule();
|