mirror of
https://github.com/itsdave-de/msp.git
synced 2025-05-06 15:35:12 +02:00
Sales Invoice Item Group Separation
This commit is contained in:
parent
d251f7e783
commit
7157f40831
78
msp/billing_tools.py
Normal file
78
msp/billing_tools.py
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
|
||||||
|
import frappe
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
#ssigss = Sales Invoice Item Group Separation
|
||||||
|
|
||||||
|
|
||||||
|
def get_sales_invoice_item_group_separation(customer):
|
||||||
|
#check, that we have exactly one Sales Invoice Item Group Separation Entry for this customer, and return it Parent Name
|
||||||
|
ssigss = frappe.get_all(
|
||||||
|
"Sales Invoice Item Group Separation Customer",
|
||||||
|
filters={"customer": customer},
|
||||||
|
fields=["name", "parent"])
|
||||||
|
if not ssigss:
|
||||||
|
frappe.throw("No Sales Invoice Item Group Separation Customer.")
|
||||||
|
if len(ssigss) > 1:
|
||||||
|
frappe.throw("More then one Sales Invoice Item Group Separation Customer.")
|
||||||
|
return ssigss[0]["parent"]
|
||||||
|
|
||||||
|
|
||||||
|
def get_item_group_separation_dict(ssigs):
|
||||||
|
"""get item groups to concider from ssigss, should return something like:
|
||||||
|
{1: {'filter': ['Anwendungsentwicklung'],
|
||||||
|
'idx': 1,
|
||||||
|
'item_group': 'Anwendungsentwicklung',
|
||||||
|
'recursive': 0},
|
||||||
|
2: {'filter': ['Dienstleistungen',
|
||||||
|
'Zuschläge',
|
||||||
|
'Anwendungsentwicklung',
|
||||||
|
'Arbeitszeiten Techniker'],
|
||||||
|
'idx': 2,
|
||||||
|
'item_group': 'Dienstleistungen',
|
||||||
|
'recursive': 1}}
|
||||||
|
"""
|
||||||
|
item_group_separation_dict = frappe.get_all(
|
||||||
|
"Sales Invoice Item Group Separation Entry",
|
||||||
|
filters={"parent": ssigs},
|
||||||
|
fields=["idx", "item_group", "recursive"],
|
||||||
|
order_by="idx")
|
||||||
|
ordered_filters_dict = {}
|
||||||
|
|
||||||
|
for item_group_separation in item_group_separation_dict:
|
||||||
|
ordered_filters_dict[item_group_separation["idx"]] = item_group_separation
|
||||||
|
if item_group_separation["recursive"]:
|
||||||
|
ordered_filters_dict[item_group_separation["idx"]]["filter"] = search_child_item_groups(item_group_separation["item_group"])
|
||||||
|
else:
|
||||||
|
ordered_filters_dict[item_group_separation["idx"]]["filter"] = [item_group_separation["item_group"]]
|
||||||
|
|
||||||
|
return ordered_filters_dict
|
||||||
|
|
||||||
|
|
||||||
|
def search_child_item_groups(item_group, item_groups_to_filter = None):
|
||||||
|
#get all child item groups, return list with childs and parent
|
||||||
|
if not item_groups_to_filter:
|
||||||
|
item_groups_to_filter = []
|
||||||
|
|
||||||
|
item_groups_to_filter.append(item_group)
|
||||||
|
|
||||||
|
child_locations = frappe.get_all(
|
||||||
|
"Item Group",
|
||||||
|
filters = {"parent_item_group": item_group})
|
||||||
|
|
||||||
|
if child_locations:
|
||||||
|
for child_location in child_locations:
|
||||||
|
search_child_item_groups(child_location['name'], item_groups_to_filter)
|
||||||
|
|
||||||
|
return item_groups_to_filter
|
||||||
|
|
||||||
|
def get_item_group_assignment_table(customer):
|
||||||
|
ssigs = get_sales_invoice_item_group_separation(customer)
|
||||||
|
item_group_separation_dict = get_item_group_separation_dict(ssigs)
|
||||||
|
return item_group_separation_dict
|
||||||
|
# for idx in range(1, len(item_group_separation_dict) + 1):
|
||||||
|
# print("prüfe artikel auf prio " + str(idx))
|
||||||
|
# print(item_group_separation_dict[idx])
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Sales Invoice Item Group Separation', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"autoname": "SIIGS-.#####",
|
||||||
|
"creation": "2022-09-20 14:17:11.567012",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"active",
|
||||||
|
"customers",
|
||||||
|
"item_groups"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"description": "Legt fest, ob diese Regel aktiv ist. Es darf immer nur eine aktive Regel per Kunde geben.",
|
||||||
|
"fieldname": "active",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Active"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Es wird nach folgenden Item-Groups getrennt. Die Priorisierung erfolgt gem. der Reihenfolge innerhalb der Liste. Nur wenn die Option \"recursive\" aktiv ist, werden alle Child Item-Groups unterhalb der genannten Item-Group ber\u00fccksichtigt. ( Ermitteln und immer \"in\" - Filter verwenden) ",
|
||||||
|
"fieldname": "item_groups",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Item Groups",
|
||||||
|
"options": "Sales Invoice Item Group Separation Entry"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Diese Regel ist f\u00fcr die folgenden Kunden anzuwenden, solange eine der Abrechungsmethoden mit Item-Group Bezug beim Customer hinterlegt ist.",
|
||||||
|
"fieldname": "customers",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Customers",
|
||||||
|
"options": "Sales Invoice Item Group Separation Customer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-09-20 14:34:09.246244",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "MSP",
|
||||||
|
"name": "Sales Invoice Item Group Separation",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class SalesInvoiceItemGroupSeparation(Document):
|
||||||
|
pass
|
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestSalesInvoiceItemGroupSeparation(unittest.TestCase):
|
||||||
|
pass
|
@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2022-09-20 14:22:26.303420",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"customer",
|
||||||
|
"customer_name"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "customer",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Customer",
|
||||||
|
"options": "Customer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "customer.customer_name",
|
||||||
|
"fieldname": "customer_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Customer Name",
|
||||||
|
"read_only": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-09-20 14:23:31.490359",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "MSP",
|
||||||
|
"name": "Sales Invoice Item Group Separation Customer",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class SalesInvoiceItemGroupSeparationCustomer(Document):
|
||||||
|
pass
|
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2022-09-20 14:19:56.912230",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"item_group",
|
||||||
|
"recursive"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "item_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Item Group",
|
||||||
|
"options": "Item Group"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "recursive",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Recursive"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"istable": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-09-20 14:37:16.713669",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "MSP",
|
||||||
|
"name": "Sales Invoice Item Group Separation Entry",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class SalesInvoiceItemGroupSeparationEntry(Document):
|
||||||
|
pass
|
Loading…
x
Reference in New Issue
Block a user