feat: purchase grouped asset
This commit is contained in:
parent
fabe0bce15
commit
35a6b58c12
@ -35,6 +35,7 @@
|
|||||||
"available_for_use_date",
|
"available_for_use_date",
|
||||||
"column_break_23",
|
"column_break_23",
|
||||||
"gross_purchase_amount",
|
"gross_purchase_amount",
|
||||||
|
"asset_quantity",
|
||||||
"purchase_date",
|
"purchase_date",
|
||||||
"section_break_23",
|
"section_break_23",
|
||||||
"calculate_depreciation",
|
"calculate_depreciation",
|
||||||
@ -480,6 +481,12 @@
|
|||||||
"fieldname": "section_break_36",
|
"fieldname": "section_break_36",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Finance Books"
|
"label": "Finance Books"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "asset_quantity",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Asset Quantity",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 72,
|
"idx": 72,
|
||||||
@ -502,10 +509,11 @@
|
|||||||
"link_fieldname": "asset"
|
"link_fieldname": "asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-06-24 14:58:51.097908",
|
"modified": "2022-01-18 12:57:36.741192",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
|
"naming_rule": "By \"Naming Series\" field",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
@ -542,6 +550,7 @@
|
|||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
|
"states": [],
|
||||||
"title_field": "asset_name",
|
"title_field": "asset_name",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
@ -554,7 +554,10 @@ class BuyingController(StockController, Subcontracting):
|
|||||||
# Check for asset naming series
|
# Check for asset naming series
|
||||||
if item_data.get('asset_naming_series'):
|
if item_data.get('asset_naming_series'):
|
||||||
created_assets = []
|
created_assets = []
|
||||||
|
if item_data.get('is_grouped_asset'):
|
||||||
|
asset = self.make_asset(d, is_grouped_asset=True)
|
||||||
|
created_assets.append(asset)
|
||||||
|
else:
|
||||||
for qty in range(cint(d.qty)):
|
for qty in range(cint(d.qty)):
|
||||||
asset = self.make_asset(d)
|
asset = self.make_asset(d)
|
||||||
created_assets.append(asset)
|
created_assets.append(asset)
|
||||||
@ -580,14 +583,18 @@ class BuyingController(StockController, Subcontracting):
|
|||||||
for message in messages:
|
for message in messages:
|
||||||
frappe.msgprint(message, title="Success", indicator="green")
|
frappe.msgprint(message, title="Success", indicator="green")
|
||||||
|
|
||||||
def make_asset(self, row):
|
def make_asset(self, row, is_grouped_asset=False):
|
||||||
if not row.asset_location:
|
if not row.asset_location:
|
||||||
frappe.throw(_("Row {0}: Enter location for the asset item {1}").format(row.idx, row.item_code))
|
frappe.throw(_("Row {0}: Enter location for the asset item {1}").format(row.idx, row.item_code))
|
||||||
|
|
||||||
item_data = frappe.db.get_value('Item',
|
item_data = frappe.db.get_value('Item',
|
||||||
row.item_code, ['asset_naming_series', 'asset_category'], as_dict=1)
|
row.item_code, ['asset_naming_series', 'asset_category'], as_dict=1)
|
||||||
|
|
||||||
|
if is_grouped_asset:
|
||||||
|
purchase_amount = flt(row.base_amount + row.item_tax_amount)
|
||||||
|
else:
|
||||||
purchase_amount = flt(row.base_rate + row.item_tax_amount)
|
purchase_amount = flt(row.base_rate + row.item_tax_amount)
|
||||||
|
|
||||||
asset = frappe.get_doc({
|
asset = frappe.get_doc({
|
||||||
'doctype': 'Asset',
|
'doctype': 'Asset',
|
||||||
'item_code': row.item_code,
|
'item_code': row.item_code,
|
||||||
@ -601,6 +608,7 @@ class BuyingController(StockController, Subcontracting):
|
|||||||
'calculate_depreciation': 1,
|
'calculate_depreciation': 1,
|
||||||
'purchase_receipt_amount': purchase_amount,
|
'purchase_receipt_amount': purchase_amount,
|
||||||
'gross_purchase_amount': purchase_amount,
|
'gross_purchase_amount': purchase_amount,
|
||||||
|
'asset_quantity': row.qty if is_grouped_asset else 0,
|
||||||
'purchase_receipt': self.name if self.doctype == 'Purchase Receipt' else None,
|
'purchase_receipt': self.name if self.doctype == 'Purchase Receipt' else None,
|
||||||
'purchase_invoice': self.name if self.doctype == 'Purchase Invoice' else None
|
'purchase_invoice': self.name if self.doctype == 'Purchase Invoice' else None
|
||||||
})
|
})
|
||||||
@ -687,7 +695,7 @@ class BuyingController(StockController, Subcontracting):
|
|||||||
|
|
||||||
def get_asset_item_details(asset_items):
|
def get_asset_item_details(asset_items):
|
||||||
asset_items_data = {}
|
asset_items_data = {}
|
||||||
for d in frappe.get_all('Item', fields = ["name", "auto_create_assets", "asset_naming_series"],
|
for d in frappe.get_all('Item', fields = ["name", "auto_create_assets", "asset_naming_series", "is_grouped_asset"],
|
||||||
filters = {'name': ('in', asset_items)}):
|
filters = {'name': ('in', asset_items)}):
|
||||||
asset_items_data.setdefault(d.name, d)
|
asset_items_data.setdefault(d.name, d)
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"standard_rate",
|
"standard_rate",
|
||||||
"is_fixed_asset",
|
"is_fixed_asset",
|
||||||
"auto_create_assets",
|
"auto_create_assets",
|
||||||
|
"is_grouped_asset",
|
||||||
"asset_category",
|
"asset_category",
|
||||||
"asset_naming_series",
|
"asset_naming_series",
|
||||||
"over_delivery_receipt_allowance",
|
"over_delivery_receipt_allowance",
|
||||||
@ -1026,6 +1027,13 @@
|
|||||||
"fieldname": "grant_commission",
|
"fieldname": "grant_commission",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Grant Commission"
|
"label": "Grant Commission"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "auto_create_assets",
|
||||||
|
"fieldname": "is_grouped_asset",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Create Grouped Asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 1,
|
"has_web_view": 1,
|
||||||
@ -1034,7 +1042,7 @@
|
|||||||
"image_field": "image",
|
"image_field": "image",
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-12-14 04:13:16.857534",
|
"modified": "2022-01-18 12:57:54.273202",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Item",
|
"name": "Item",
|
||||||
@ -1104,6 +1112,7 @@
|
|||||||
"show_preview_popup": 1,
|
"show_preview_popup": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
|
"states": [],
|
||||||
"title_field": "item_name",
|
"title_field": "item_name",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user