fix: batched items method giving wrong quantity, so changed it back to previous way

This commit is contained in:
Ritvik Sardana
2023-08-05 11:23:07 +05:30
parent 510543680b
commit dbc000d655
3 changed files with 17 additions and 18 deletions

View File

@@ -276,10 +276,10 @@ class POSInvoice(SalesInvoice):
if self.is_return and entry.amount > 0: if self.is_return and entry.amount > 0:
frappe.throw(_("Row #{0} (Payment Table): Amount must be negative").format(entry.idx)) frappe.throw(_("Row #{0} (Payment Table): Amount must be negative").format(entry.idx))
# if self.is_return: if self.is_return:
# invoice_total = self.rounded_total or self.grand_total invoice_total = self.rounded_total or self.grand_total
# if total_amount_in_payments and total_amount_in_payments < invoice_total: if total_amount_in_payments and total_amount_in_payments < invoice_total:
# frappe.throw(_("Total payments amount can't be greater than {}").format(-invoice_total)) frappe.throw(_("Total payments amount can't be greater than {}").format(-invoice_total))
def validate_loyalty_transaction(self): def validate_loyalty_transaction(self):
if self.redeem_loyalty_points and ( if self.redeem_loyalty_points and (

View File

@@ -83,17 +83,19 @@ class POSInvoiceMergeLog(Document):
pos_invoice_docs = [ pos_invoice_docs = [
frappe.get_cached_doc("POS Invoice", d.pos_invoice) for d in self.pos_invoices 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: returns = [d for d in pos_invoice_docs if d.get("is_return") == 1]
sales_invoice, credit_note = "", "" sales = [d for d in pos_invoice_docs if d.get("is_return") == 0]
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)
self.save() # save consolidated_sales_invoice & consolidated_credit_note ref in merge log sales_invoice, credit_note = "", ""
self.update_pos_invoices(pos_invoice_docs, 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)
def on_cancel(self): def on_cancel(self):
pos_invoice_docs = [ pos_invoice_docs = [
@@ -395,8 +397,7 @@ def split_invoices(invoices):
for d in invoices for d in invoices
if d.is_return and d.return_against if d.is_return and d.return_against
] ]
print(pos_return_docs, invoices, _invoices, sep="-")
# breakpoint()
for pos_invoice in pos_return_docs: for pos_invoice in pos_return_docs:
for item in pos_invoice.items: for item in pos_invoice.items:
if not item.serial_no and not item.serial_and_batch_bundle: if not item.serial_no and not item.serial_and_batch_bundle:

View File

@@ -1215,7 +1215,6 @@ def get_reserved_serial_nos_for_pos(kwargs):
for d in get_serial_batch_ledgers(kwargs.item_code, docstatus=1, name=ids): for d in get_serial_batch_ledgers(kwargs.item_code, docstatus=1, name=ids):
ignore_serial_nos.append(d.serial_no) ignore_serial_nos.append(d.serial_no)
# Will be deprecated in v16
returned_serial_nos = [] returned_serial_nos = []
for pos_invoice in pos_invoices: for pos_invoice in pos_invoices:
if pos_invoice.serial_no: if pos_invoice.serial_no:
@@ -1244,8 +1243,7 @@ def get_reserved_serial_nos_for_pos(kwargs):
) )
) )
# Counter is used to create a hashmap of serial nos, which contains count of each serial 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 subtract returned serial nos from ignore serial nos after creating a counter of each to get the items which we need to ignore(which are sold)
# so we need to subtract returned serial nos from ignore serial nos after creating a counter of each
ignore_serial_nos_counter = Counter(ignore_serial_nos) ignore_serial_nos_counter = Counter(ignore_serial_nos)
returned_serial_nos_counter = Counter(returned_serial_nos) returned_serial_nos_counter = Counter(returned_serial_nos)