chore: Merge branch 'version-15-hotfix'

This commit is contained in:
Khushi Rawat
2024-12-17 11:20:39 +05:30
3 changed files with 44 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ cd ~ || exit
sudo apt update
sudo apt remove mysql-server mysql-client
sudo apt install libcups2-dev redis-server mariadb-client-10.6
sudo apt install libcups2-dev redis-server mariadb-client
pip install frappe-bench
@@ -44,13 +44,9 @@ fi
install_whktml() {
if [ "$(lsb_release -rs)" = "22.04" ]; then
wget -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt install /tmp/wkhtmltox.deb
else
echo "Please update this script to support wkhtmltopdf for $(lsb_release -ds)"
exit 1
fi
wget -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt install /tmp/wkhtmltox.deb
}
install_whktml &
wkpid=$!

View File

@@ -132,6 +132,7 @@ class POSInvoiceMergeLog(Document):
self.update_pos_invoices(pos_invoice_docs)
self.serial_and_batch_bundle_reference_for_pos_invoice()
self.cancel_linked_invoices()
self.delink_serial_and_batch_bundle()
def process_merging_into_sales_invoice(self, data):
sales_invoice = self.get_new_sales_invoice()
@@ -319,6 +320,38 @@ class POSInvoiceMergeLog(Document):
for table_name in ["items", "packed_items"]:
pos_invoice.set_serial_and_batch_bundle(table_name)
def delink_serial_and_batch_bundle(self):
bundles = self.get_serial_and_batch_bundles()
if not bundles:
return
sle_table = frappe.qb.DocType("Stock Ledger Entry")
query = (
frappe.qb.update(sle_table)
.set(sle_table.serial_and_batch_bundle, None)
.where(sle_table.serial_and_batch_bundle.isin(bundles) & sle_table.is_cancelled == 1)
)
query.run()
def get_serial_and_batch_bundles(self):
pos_invoices = []
for d in self.pos_invoices:
pos_invoices.append(d.pos_invoice)
if pos_invoices:
return frappe.get_all(
"POS Invoice Item",
filters={
"docstatus": 1,
"parent": ["in", pos_invoices],
"serial_and_batch_bundle": ["is", "set"],
},
pluck="serial_and_batch_bundle",
)
return []
def cancel_linked_invoices(self):
for si_name in [self.consolidated_invoice, self.consolidated_credit_note]:
if not si_name:
@@ -503,6 +536,9 @@ def cancel_merge_logs(merge_logs, closing_entry=None):
try:
for log in merge_logs:
merge_log = frappe.get_doc("POS Invoice Merge Log", log)
if merge_log.docstatus == 2:
continue
merge_log.flags.ignore_permissions = True
merge_log.cancel()

View File

@@ -505,9 +505,9 @@ class SerialandBatchBundle(Document):
elif (d.incoming_rate == rate) and d.qty and d.stock_value_difference:
continue
d.incoming_rate = rate
d.incoming_rate = flt(rate)
if d.qty:
d.stock_value_difference = d.qty * d.incoming_rate
d.stock_value_difference = flt(d.qty) * d.incoming_rate
if save:
d.db_set(
@@ -519,6 +519,8 @@ class SerialandBatchBundle(Document):
if not self.voucher_no or self.voucher_no != row.parent:
values_to_set["voucher_no"] = row.parent
self.db_set("is_cancelled", 0)
if self.voucher_type != parent.doctype:
values_to_set["voucher_type"] = parent.doctype