fix: POS Runtime Effect completed
This commit is contained in:
parent
5b1aa07ecb
commit
c9d5a62350
@ -542,6 +542,7 @@ def get_stock_availability(item_code, warehouse):
|
||||
is_stock_item = True
|
||||
bin_qty = get_bin_qty(item_code, warehouse)
|
||||
pos_sales_qty = get_pos_reserved_qty(item_code, warehouse)
|
||||
|
||||
return bin_qty - pos_sales_qty, is_stock_item
|
||||
else:
|
||||
is_stock_item = True
|
||||
|
@ -83,30 +83,19 @@ class POSInvoiceMergeLog(Document):
|
||||
pos_invoice_docs = [
|
||||
frappe.get_cached_doc("POS Invoice", d.pos_invoice) for d in self.pos_invoices
|
||||
]
|
||||
batched_invoices = self.get_batched_invoices(pos_invoice_docs)
|
||||
|
||||
for invoice in batched_invoices:
|
||||
sales_invoice, credit_note = "", ""
|
||||
if not invoice[0].get("is_return"):
|
||||
sales_invoice = self.process_merging_into_sales_invoice(invoice)
|
||||
else:
|
||||
credit_note = self.process_merging_into_credit_note(invoice)
|
||||
returns = [d for d in pos_invoice_docs if d.get("is_return") == 1]
|
||||
sales = [d for d in pos_invoice_docs if d.get("is_return") == 0]
|
||||
|
||||
self.save() # save consolidated_sales_invoice & consolidated_credit_note ref in merge log
|
||||
self.update_pos_invoices(pos_invoice_docs, sales_invoice, credit_note)
|
||||
sales_invoice, credit_note = "", ""
|
||||
if returns:
|
||||
credit_note = self.process_merging_into_credit_note(returns)
|
||||
|
||||
# returns = [d for d in pos_invoice_docs if d.get("is_return") == 1]
|
||||
# sales = [d for d in pos_invoice_docs if d.get("is_return") == 0]
|
||||
if sales:
|
||||
sales_invoice = self.process_merging_into_sales_invoice(sales)
|
||||
|
||||
# sales_invoice, credit_note = "", ""
|
||||
# if returns:
|
||||
# credit_note = self.process_merging_into_credit_note(returns)
|
||||
|
||||
# if sales:
|
||||
# sales_invoice = self.process_merging_into_sales_invoice(sales)
|
||||
|
||||
# self.save() # save consolidated_sales_invoice & consolidated_credit_note ref in merge log
|
||||
# self.update_pos_invoices(pos_invoice_docs, sales_invoice, credit_note)
|
||||
self.save() # save consolidated_sales_invoice & consolidated_credit_note ref in merge log
|
||||
self.update_pos_invoices(pos_invoice_docs, sales_invoice, credit_note)
|
||||
|
||||
def on_cancel(self):
|
||||
pos_invoice_docs = [
|
||||
@ -171,23 +160,20 @@ class POSInvoiceMergeLog(Document):
|
||||
|
||||
for item in doc.get("items"):
|
||||
found = False
|
||||
if not item.serial_and_batch_bundle:
|
||||
for i in items:
|
||||
|
||||
if (
|
||||
i.item_code == item.item_code
|
||||
and not i.serial_no
|
||||
and not i.batch_no
|
||||
and i.uom == item.uom
|
||||
and i.net_rate == item.net_rate
|
||||
and i.warehouse == item.warehouse
|
||||
):
|
||||
found = True
|
||||
i.qty = i.qty + item.qty
|
||||
i.amount = i.amount + item.net_amount
|
||||
i.net_amount = i.amount
|
||||
i.base_amount = i.base_amount + item.base_net_amount
|
||||
i.base_net_amount = i.base_amount
|
||||
for i in items:
|
||||
if (
|
||||
i.item_code == item.item_code
|
||||
and not i.serial_and_batch_bundle
|
||||
and i.uom == item.uom
|
||||
and i.net_rate == item.net_rate
|
||||
and i.warehouse == item.warehouse
|
||||
):
|
||||
found = True
|
||||
i.qty = i.qty + item.qty
|
||||
i.amount = i.amount + item.net_amount
|
||||
i.net_amount = i.amount
|
||||
i.base_amount = i.base_amount + item.base_net_amount
|
||||
i.base_net_amount = i.base_amount
|
||||
|
||||
if not found:
|
||||
item.rate = item.net_rate
|
||||
@ -287,21 +273,6 @@ class POSInvoiceMergeLog(Document):
|
||||
si.flags.ignore_validate = True
|
||||
si.cancel()
|
||||
|
||||
def get_batched_invoices(self, pos_invoice_docs):
|
||||
grouped_batch = []
|
||||
current_batch = []
|
||||
for item in pos_invoice_docs:
|
||||
if not current_batch:
|
||||
current_batch.append(item)
|
||||
elif current_batch[-1].get("is_return") != item.get("is_return"):
|
||||
grouped_batch.append(current_batch)
|
||||
current_batch = [item]
|
||||
else:
|
||||
current_batch.append(item)
|
||||
|
||||
grouped_batch.append(current_batch)
|
||||
return grouped_batch
|
||||
|
||||
|
||||
def update_item_wise_tax_detail(consolidate_tax_row, tax_row):
|
||||
consolidated_tax_detail = json.loads(consolidate_tax_row.item_wise_tax_detail)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import collections
|
||||
import csv
|
||||
from collections import defaultdict
|
||||
from collections import Counter, defaultdict
|
||||
from typing import Dict, List
|
||||
|
||||
import frappe
|
||||
@ -1197,6 +1197,7 @@ def get_reserved_serial_nos_for_pos(kwargs):
|
||||
filters=[
|
||||
["POS Invoice", "consolidated_invoice", "is", "not set"],
|
||||
["POS Invoice", "docstatus", "=", 1],
|
||||
["POS Invoice", "is_return", "=", 0],
|
||||
["POS Invoice Item", "item_code", "=", kwargs.item_code],
|
||||
["POS Invoice", "name", "!=", kwargs.ignore_voucher_no],
|
||||
],
|
||||
@ -1242,8 +1243,14 @@ def get_reserved_serial_nos_for_pos(kwargs):
|
||||
child_doc, parent_doc, ignore_voucher_detail_no=kwargs.get("ignore_voucher_detail_no")
|
||||
)
|
||||
)
|
||||
# Counter is used to create a hashmap of serial nos, which contains count of each serial no
|
||||
# ignore serial nos inlcudes serial nos which are sold and returned
|
||||
# so we need to subtract returned serial nos from ignore serial nos after creating a counter of each
|
||||
|
||||
return list(set(ignore_serial_nos) - set(returned_serial_nos))
|
||||
ignore_serial_nos_counter = Counter(ignore_serial_nos)
|
||||
returned_serial_nos_counter = Counter(returned_serial_nos)
|
||||
|
||||
return list(ignore_serial_nos_counter - returned_serial_nos_counter)
|
||||
|
||||
|
||||
def get_reserved_batches_for_pos(kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user